'use client'; import { Card, CardMedia, Box, Chip, Typography, Tooltip, IconButton } from '@mui/material'; import VisibilityIcon from '@mui/icons-material/Visibility'; import DeleteIcon from '@mui/icons-material/Delete'; import AssessmentIcon from '@mui/icons-material/Assessment'; import { useTranslation } from 'react-i18next'; import { imageDatasetStyles } from '../styles/imageDatasetStyles'; export default function ImageDatasetCard({ dataset, onClick, onView = () => {}, onDelete = () => {}, onEvaluate = () => {} }) { const { t } = useTranslation(); const getAnswerText = () => { if (!dataset.answer) return t('imageDatasets.noAnswer', '暂无答案'); if (dataset.answerType === 'label') { try { const labels = JSON.parse(dataset.answer); return `${t('imageDatasets.labels', '标签')}: ${labels.join(', ')}`; } catch { return dataset.answer; } } return dataset.answer; }; const getAnswerTypeLabel = type => { switch (type) { case 'label': return t('imageDatasets.typeLabel', '标签'); case 'custom_format': return t('imageDatasets.typeCustom', '自定义'); default: return t('imageDatasets.typeText', '文本'); } }; const getAnswerTypeColor = type => { switch (type) { case 'label': return 'secondary'; case 'custom_format': return 'info'; default: return 'primary'; } }; const getScoreLabel = () => { if (!dataset.score || dataset.score === 0) { return t('imageDatasets.unscored', '未评分'); } return dataset.score; }; return ( {/* 图片区域 */} {/* 悬停遮罩 */} {/* 问题内容 - 底部,毛玻璃背景 */} {dataset.question} {/* 内容区域 - 标签和操作按钮 */} {/* 左侧:所有标签 */} ⭐} label={getScoreLabel()} size="small" color={dataset.score && dataset.score > 0 ? 'warning' : 'default'} sx={{ fontSize: '0.7rem', height: 20 }} /> {/* 右侧:操作按钮 - 不同颜色 */} { e.stopPropagation(); onView(dataset.id); }} sx={{ p: 0.5, borderRadius: 1, color: '#1976d2', '&:hover': { backgroundColor: 'rgba(25, 118, 210, 0.1)' } }} > { e.stopPropagation(); onEvaluate(dataset.id); }} sx={{ p: 0.5, borderRadius: 1, color: '#f57c00', '&:hover': { backgroundColor: 'rgba(245, 124, 0, 0.1)' } }} > { e.stopPropagation(); onDelete(dataset.id); }} sx={{ p: 0.5, borderRadius: 1, color: '#d32f2f', '&:hover': { backgroundColor: 'rgba(211, 47, 47, 0.1)' } }} > ); }