import React from 'react'; import { Prompt } from '../../types'; import Card, { CardHeader, CardContent, CardFooter } from '../common/Card'; import Button from '../common/Button'; interface PromptCardProps { prompt: Prompt; onEdit?: () => void; onDelete?: () => void; onExport?: () => void; className?: string; showActions?: boolean; selected?: boolean; onSelect?: () => void; } const PromptCard: React.FC = ({ prompt, onEdit, onDelete, onExport, className = '', showActions = true, selected = false, onSelect }) => { const formatDate = (date: string | Date) => { const dateObj = typeof date === 'string' ? new Date(date) : date; return dateObj.toLocaleDateString('zh-CN', { year: 'numeric', month: 'long', day: 'numeric' }); }; // 截断长内容并添加"查看更多" const truncateContent = (content: string, maxLength: number = 200) => { if (content.length <= maxLength) return content; return `${content.substring(0, maxLength)}...`; }; return ( ) => { e.stopPropagation(); onSelect(); }} > {selected && ( )} ) } /> {/* 添加 max-h-48 (192px) 和 overflow-y-auto 来限制高度并启用滚动 */}
          {truncateContent(prompt.content)}
        
{prompt.tags.length > 0 && (
{prompt.tags.map((tag) => (
{tag}
))}
)}
创建于 {formatDate(prompt.createdAt)}
{showActions && (
{onExport && ( )} {onEdit && ( )} {onDelete && ( )}
)}
); }; export default PromptCard;