diff --git a/src/components/features/QuickPhraseItem.tsx b/src/components/features/QuickPhraseItem.tsx new file mode 100644 index 0000000..385bf65 --- /dev/null +++ b/src/components/features/QuickPhraseItem.tsx @@ -0,0 +1,123 @@ +'use client'; + +import { useState } from 'react'; +import * as LucideIcons from 'lucide-react'; +import type { QuickPhrase } from '@/types'; +import { cn } from '@/lib/utils'; +import { Tooltip } from '@/components/ui/Tooltip'; + +interface QuickPhraseItemProps { + phrase: QuickPhrase; + onSelect: (phrase: QuickPhrase) => void; + onEdit?: (phrase: QuickPhrase) => void; + onDelete?: (id: string) => void; + showActions?: boolean; +} + +/** + * 快捷短语列表项组件 + */ +export function QuickPhraseItem({ + phrase, + onSelect, + onEdit, + onDelete, + showActions = true, +}: QuickPhraseItemProps) { + const [isHovered, setIsHovered] = useState(false); + + // 获取图标组件 + const IconComponent = phrase.icon + ? (LucideIcons[phrase.icon as keyof typeof LucideIcons] as React.ComponentType<{ size?: number; className?: string }>) + : LucideIcons.MessageSquare; + + // 截断内容预览(最多显示 50 个字符) + const contentPreview = phrase.content.length > 50 + ? phrase.content.substring(0, 50) + '...' + : phrase.content; + + const handleSelect = () => { + onSelect(phrase); + }; + + const handleEdit = (e: React.MouseEvent) => { + e.stopPropagation(); + onEdit?.(phrase); + }; + + const handleDelete = (e: React.MouseEvent) => { + e.stopPropagation(); + onDelete?.(phrase.id); + }; + + return ( +
暂无快捷短语
+点击上方按钮添加
+暂无快捷短语
+点击上方 + 添加
+