refactor(web): 前端目录重构 — consoles/pages → layouts/features + shared

- consoles/admin/ → layouts/admin-layout/
- consoles/workbench/ → layouts/workbench-layout/ + features/chat/
- pages/ → features/ (dashboard, models, projects, not-found)
- components/ → shared/components/
- hooks/ → shared/hooks/
- utils/ → shared/utils/
- 更新所有 import 路径 (src/web/ + tests/web/)
- 更新开发文档 (README.md, frontend.md, architecture.md)
This commit is contained in:
2026-06-02 23:17:28 +08:00
parent 1f05f259d0
commit b1dec691e9
76 changed files with 249 additions and 111 deletions

View File

@@ -0,0 +1,85 @@
import type { ColumnsType } from "antd/es/table";
import { DeleteOutlined, EditOutlined } from "@ant-design/icons";
import { App as AntApp, Button, Popconfirm, Space, Table } from "antd";
import type { Provider, ProviderListResponse } from "../../../../shared/api";
interface ProviderTableProps {
data: ProviderListResponse | undefined;
loading: boolean;
onDelete: (id: string) => Promise<unknown>;
onEdit: (provider: Provider) => void;
onPageChange: (page: number, pageSize: number) => void;
page: number;
pageSize: number;
}
const TYPE_LABELS: Record<Provider["type"], string> = {
anthropic: "Anthropic",
openai: "OpenAI",
"openai-compatible": "OpenAI 兼容",
};
const COLUMNS: ColumnsType<Provider> = [
{ dataIndex: "name", ellipsis: true, title: "名称", width: 180 },
{
dataIndex: "type",
render: (value: Provider["type"]) => TYPE_LABELS[value] ?? value,
title: "类型",
width: 140,
},
{ dataIndex: "baseUrl", ellipsis: true, title: "Base URL" },
];
export function ProviderTable({ data, loading, onDelete, onEdit, onPageChange, page, pageSize }: ProviderTableProps) {
const { message } = AntApp.useApp();
const handleDelete = async (id: string) => {
try {
await onDelete(id);
message.success("供应商已删除");
} catch (err: unknown) {
message.error((err as Error).message);
}
};
const operationColumn: ColumnsType<Provider>[number] = {
dataIndex: "op",
render: (_value: unknown, record: Provider) => (
<Space size="small">
<Button icon={<EditOutlined />} onClick={() => onEdit(record)} size="small" type="link">
</Button>
<Popconfirm
description="该供应商下存在模型时无法删除,请先删除或迁移相关模型。"
onConfirm={() => void handleDelete(record.id)}
title="确认删除此供应商?"
>
<Button danger icon={<DeleteOutlined />} size="small" type="link">
</Button>
</Popconfirm>
</Space>
),
title: "操作",
width: 180,
};
return (
<Table
columns={[...COLUMNS, operationColumn]}
dataSource={data?.items ?? []}
loading={loading}
pagination={{
current: page,
hideOnSinglePage: false,
onChange: onPageChange,
pageSize,
showSizeChanger: true,
total: data?.total ?? 0,
}}
rowKey="id"
/>
);
}