refactor: 迁移 UI 组件库从 Ant Design 至 TDesign
- 替换 antd 为 tdesign-react 作为主要 UI 组件库 - 引入 Recharts 替代 @ant-design/charts 实现图表功能 - 移除主题系统相关代码(ThemeContext、themes 目录) - 更新所有组件以适配 TDesign 组件 API - 更新测试用例以匹配新的组件实现 - 新增 TDesign 和 Recharts 集成规范文档
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Button, Table, Tag, Popconfirm, Space } from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { Button, Table, Tag, Popconfirm, Space } from 'tdesign-react';
|
||||
import type { PrimaryTableCol } from 'tdesign-react/es/table/type';
|
||||
import type { Model } from '@/types';
|
||||
import { useModels, useDeleteModel } from '@/hooks/useModels';
|
||||
|
||||
@@ -13,39 +13,35 @@ export function ModelTable({ providerId, onAdd, onEdit }: ModelTableProps) {
|
||||
const { data: models = [], isLoading } = useModels(providerId);
|
||||
const deleteModel = useDeleteModel();
|
||||
|
||||
const columns: ColumnsType<Model> = [
|
||||
const columns: PrimaryTableCol<Model>[] = [
|
||||
{
|
||||
title: '模型名称',
|
||||
dataIndex: 'modelName',
|
||||
key: 'modelName',
|
||||
ellipsis: { showTitle: true },
|
||||
colKey: 'modelName',
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'enabled',
|
||||
key: 'enabled',
|
||||
render: (enabled: boolean) =>
|
||||
enabled ? <Tag color="green">启用</Tag> : <Tag color="red">禁用</Tag>,
|
||||
colKey: 'enabled',
|
||||
width: 80,
|
||||
cell: ({ row }) =>
|
||||
row.enabled ? <Tag theme="success">启用</Tag> : <Tag theme="danger">禁用</Tag>,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
colKey: 'action',
|
||||
width: 120,
|
||||
render: (_, record) => (
|
||||
cell: ({ row }) => (
|
||||
<Space>
|
||||
{onEdit && (
|
||||
<Button variant="link" size="small" onClick={() => onEdit(record)}>
|
||||
<Button variant="text" size="small" onClick={() => onEdit(row)}>
|
||||
编辑
|
||||
</Button>
|
||||
)}
|
||||
<Popconfirm
|
||||
title="确定要删除这个模型吗?"
|
||||
onConfirm={() => deleteModel.mutate(record.id)}
|
||||
okText="确定"
|
||||
cancelText="取消"
|
||||
content="确定要删除这个模型吗?"
|
||||
onConfirm={() => deleteModel.mutate(row.id)}
|
||||
>
|
||||
<Button variant="link" color="danger" size="small">
|
||||
<Button variant="text" theme="danger" size="small">
|
||||
删除
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
@@ -59,19 +55,19 @@ export function ModelTable({ providerId, onAdd, onEdit }: ModelTableProps) {
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 8 }}>
|
||||
<span style={{ fontWeight: 500 }}>关联模型 ({models.length})</span>
|
||||
{onAdd && (
|
||||
<Button variant="link" size="small" onClick={onAdd}>
|
||||
<Button variant="text" size="small" onClick={onAdd}>
|
||||
添加模型
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<Table<Model>
|
||||
columns={columns}
|
||||
dataSource={models}
|
||||
data={models}
|
||||
rowKey="id"
|
||||
loading={isLoading}
|
||||
pagination={false}
|
||||
pagination={undefined}
|
||||
size="small"
|
||||
locale={{ emptyText: '暂无模型,点击上方按钮添加' }}
|
||||
empty="暂无模型,点击上方按钮添加"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user