refactor: 重构项目接口与API调用体系,统一类型管理
1. 合并拆分的API类型定义到统一的api/interface.ts文件 2. 删除旧的api/client.ts与api/types.ts文件 3. 重构所有页面与组件的API调用方式,统一使用api/index.ts导出的接口 4. 调整组件文件结构,将分散的组件按模块整理 5. 统一类型导入路径,移除冗余的类型重复定义
This commit is contained in:
21
src/components/RequestLogTable/index.tsx
Normal file
21
src/components/RequestLogTable/index.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Table, Tag } from "@arco-design/web-react";
|
||||
import type { RequestLogTableProps } from "./interface";
|
||||
|
||||
export function RequestLogTable({ data, loading }: RequestLogTableProps) {
|
||||
return (
|
||||
<Table
|
||||
rowKey="requestId"
|
||||
loading={loading}
|
||||
data={data}
|
||||
pagination={false}
|
||||
columns={[
|
||||
{ title: "请求 ID", dataIndex: "requestId", ellipsis: true },
|
||||
{ title: "方法", dataIndex: "method", width: 100, render: (value) => <Tag>{value}</Tag> },
|
||||
{ title: "路径", dataIndex: "path", ellipsis: true },
|
||||
{ title: "状态", dataIndex: "statusCode", width: 100, render: (value) => <Tag color={value < 400 ? "green" : "red"}>{value}</Tag> },
|
||||
{ title: "耗时", dataIndex: "costMs", width: 100, render: (value) => String(value) + "ms" },
|
||||
{ title: "消息", dataIndex: "message", width: 180 },
|
||||
]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
6
src/components/RequestLogTable/interface.ts
Normal file
6
src/components/RequestLogTable/interface.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { RequestLog } from "../../api";
|
||||
|
||||
export type RequestLogTableProps = {
|
||||
data: RequestLog[];
|
||||
loading: boolean;
|
||||
};
|
||||
Reference in New Issue
Block a user