import { Button, Table, Tag, Popconfirm, Space } from 'tdesign-react' import { useModels, useDeleteModel } from '@/hooks/useModels' import type { Model } from '@/types' import type { PrimaryTableCol } from 'tdesign-react/es/table/type' interface ModelTableProps { providerId: string onAdd?: () => void onEdit?: (model: Model) => void } export function ModelTable({ providerId, onAdd, onEdit }: ModelTableProps) { const { data: models = [], isLoading } = useModels(providerId) const deleteModel = useDeleteModel() const columns: PrimaryTableCol[] = [ { title: '统一模型 ID', colKey: 'unifiedId', width: 250, ellipsis: true, cell: ({ row }) => row.unifiedId || `${row.providerId}/${row.modelName}`, }, { title: '模型名称', colKey: 'modelName', ellipsis: true, }, { title: '状态', colKey: 'enabled', width: 80, cell: ({ row }) => row.enabled ? ( 启用 ) : ( 禁用 ), }, { title: '操作', colKey: 'action', width: 120, cell: ({ row }) => ( {onEdit && ( )} deleteModel.mutate(row.id)}> ), }, ] return (
关联模型 ({models.length}) {onAdd && ( )}
columns={columns} data={models} rowKey='id' loading={isLoading} stripe pagination={undefined} size='small' empty='暂无模型,点击上方按钮添加' />
) }