1
0

refactor: 迁移 UI 组件库从 Ant Design 至 TDesign

- 替换 antd 为 tdesign-react 作为主要 UI 组件库
- 引入 Recharts 替代 @ant-design/charts 实现图表功能
- 移除主题系统相关代码(ThemeContext、themes 目录)
- 更新所有组件以适配 TDesign 组件 API
- 更新测试用例以匹配新的组件实现
- 新增 TDesign 和 Recharts 集成规范文档
This commit is contained in:
2026-04-17 18:22:13 +08:00
parent 6eeb38c15e
commit 2b1c5e96c3
55 changed files with 1622 additions and 2541 deletions

View File

@@ -1,5 +1,5 @@
import { Button, Table, Tag, Popconfirm, Space, Card, Tooltip } from 'antd';
import type { ColumnsType } from 'antd/es/table';
import { Button, Table, Tag, Popconfirm, Space, Card, Tooltip } from 'tdesign-react';
import type { PrimaryTableCol } from 'tdesign-react/es/table/type';
import type { Provider, Model } from '@/types';
import { ModelTable } from './ModelTable';
@@ -28,56 +28,50 @@ export function ProviderTable({
onAddModel,
onEditModel,
}: ProviderTableProps) {
const columns: ColumnsType<Provider> = [
const columns: PrimaryTableCol<Provider>[] = [
{
title: '名称',
dataIndex: 'name',
key: 'name',
colKey: 'name',
width: 180,
ellipsis: { showTitle: true },
ellipsis: true,
},
{
title: 'Base URL',
dataIndex: 'baseUrl',
key: 'baseUrl',
ellipsis: { showTitle: true },
colKey: 'baseUrl',
ellipsis: true,
},
{
title: 'API Key',
dataIndex: 'apiKey',
key: 'apiKey',
colKey: 'apiKey',
width: 120,
ellipsis: { showTitle: true },
render: (key: string | null | undefined) => (
<Tooltip title={maskApiKey(key)}>
<span>{maskApiKey(key)}</span>
ellipsis: true,
cell: ({ row }) => (
<Tooltip content={maskApiKey(row.apiKey)}>
<span>{maskApiKey(row.apiKey)}</span>
</Tooltip>
),
},
{
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: 160,
render: (_, record) => (
cell: ({ row }) => (
<Space>
<Button variant="link" size="small" onClick={() => onEdit(record)}>
<Button variant="text" size="small" onClick={() => onEdit(row)}>
</Button>
<Popconfirm
title="确定要删除这个供应商吗?关联的模型也会被删除。"
onConfirm={() => onDelete(record.id)}
okText="确定"
cancelText="取消"
content="确定要删除这个供应商吗?关联的模型也会被删除。"
onConfirm={() => onDelete(row.id)}
>
<Button variant="link" color="danger" size="small">
<Button variant="text" theme="danger" size="small">
</Button>
</Popconfirm>
@@ -89,29 +83,26 @@ export function ProviderTable({
return (
<Card
title="供应商列表"
extra={
<Button color="primary" variant="solid" onClick={onAdd}>
actions={
<Button theme="primary" onClick={onAdd}>
</Button>
}
>
<Table<Provider>
columns={columns}
dataSource={providers}
data={providers}
rowKey="id"
loading={loading}
expandable={{
expandedRowRender: (record) => (
<ModelTable
providerId={record.id}
onAdd={() => onAddModel(record.id)}
onEdit={onEditModel}
/>
),
}}
pagination={false}
scroll={{ x: 840 }}
locale={{ emptyText: '暂无供应商,点击上方按钮添加' }}
expandedRow={({ row }) => (
<ModelTable
providerId={row.id}
onAdd={() => onAddModel(row.id)}
onEdit={onEditModel}
/>
)}
pagination={undefined}
empty="暂无供应商,点击上方按钮添加"
/>
</Card>
);