'use client';
import {
Box,
Typography,
IconButton,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
Chip,
Divider,
useTheme,
alpha,
Tooltip,
Checkbox,
TablePagination,
TextField,
Card,
CircularProgress
} from '@mui/material';
import DeleteIcon from '@mui/icons-material/Delete';
import VisibilityIcon from '@mui/icons-material/Visibility';
import AssessmentIcon from '@mui/icons-material/Assessment';
import StarIcon from '@mui/icons-material/Star';
import { useTranslation } from 'react-i18next';
import { getRatingConfigI18n, formatScore } from '@/components/datasets/utils/ratingUtils';
// 数据集列表组件
const DatasetList = ({
datasets,
onViewDetails,
onDelete,
onEvaluate,
page,
rowsPerPage,
onPageChange,
onRowsPerPageChange,
total,
selectedIds,
onSelectAll,
onSelectItem,
evaluatingIds = [],
loading = false
}) => {
const theme = useTheme();
const { t } = useTranslation();
const bgColor = theme.palette.mode === 'dark' ? theme.palette.primary.dark : theme.palette.primary.light;
const color =
theme.palette.mode === 'dark'
? theme.palette.getContrastText(theme.palette.primary.main)
: theme.palette.getContrastText(theme.palette.primary.contrastText);
const RatingChip = ({ score }) => {
const config = getRatingConfigI18n(score, t);
return (
}
label={`${formatScore(score)} ${config.label}`}
size="small"
sx={{
backgroundColor: config.backgroundColor,
color: config.color,
fontWeight: 'medium',
'& .MuiChip-icon': {
color: config.color
}
}}
/>
);
};
return (
0 && selectedIds.length < total}
checked={total > 0 && selectedIds.length === total}
onChange={onSelectAll}
/>
{t('datasets.question')}
{t('datasets.rating', '评分')}
{t('datasets.model')}
{t('datasets.domainTag')}
{t('datasets.createdAt')}
{t('common.actions')}
{datasets.map((dataset, index) => (
<>
onViewDetails(dataset.id)}
>
{
e.stopPropagation();
onSelectItem(dataset.id);
}}
onClick={e => e.stopPropagation()}
/>
{dataset.question}
{dataset.confirmed && (
)}
{dataset.questionLabel ? (
) : (
{t('datasets.noTag')}
)}
{new Date(dataset.createAt).toLocaleDateString('zh-CN')}
{
e.stopPropagation();
onViewDetails(dataset.id);
}}
sx={{
color: theme.palette.primary.main,
'&:hover': { backgroundColor: alpha(theme.palette.primary.main, 0.1) }
}}
>
{
e.stopPropagation();
onEvaluate && onEvaluate(dataset);
}}
sx={{
color: theme.palette.secondary.main,
'&:hover': { backgroundColor: alpha(theme.palette.secondary.main, 0.1) }
}}
>
{evaluatingIds.includes(dataset.id) ? (
) : (
)}
{
e.stopPropagation();
onDelete(dataset);
}}
sx={{
color: theme.palette.error.main,
'&:hover': { backgroundColor: alpha(theme.palette.error.main, 0.1) }
}}
>
>
))}
{datasets.length === 0 && (
{t('datasets.noData')}
)}
{loading && (
{t('datasets.loading')}
)}
t('datasets.pagination', { from, to, count })}
sx={{
'.MuiTablePagination-selectLabel, .MuiTablePagination-displayedRows': {
fontWeight: 'medium'
},
border: 'none'
}}
/>
{t('common.jumpTo')}:
{
if (e.key === 'Enter') {
const pageNum = parseInt(e.target.value, 10);
if (pageNum >= 1 && pageNum <= Math.ceil(total / rowsPerPage)) {
onPageChange(null, pageNum - 1);
e.target.value = '';
}
}
}}
/>
);
};
export default DatasetList;