1
0

feat: 前端适配后端新接口

适配后端统一模型 ID、协议字段、UUID 自动生成和结构化错误响应:

- 类型定义:Provider 新增 protocol 字段,Model 新增 unifiedId,CreateModelInput 移除 id
- API 客户端:提取结构化错误响应中的错误码
- 供应商管理:添加协议选择下拉框和表格列
- 模型管理:移除 ID 输入,显示统一模型 ID(只读)
- Hooks:错误码映射为友好中文消息
- 测试:所有组件测试通过,mock 数据适配新字段
- 文档:更新 README 说明协议字段和统一模型 ID
This commit is contained in:
2026-04-21 20:49:37 +08:00
parent 24f03595a7
commit feff97acbd
28 changed files with 547 additions and 78 deletions

View File

@@ -3,6 +3,7 @@ export interface Provider {
name: string;
apiKey: string;
baseUrl: string;
protocol: 'openai' | 'anthropic';
enabled: boolean;
createdAt: string;
updatedAt: string;
@@ -14,6 +15,7 @@ export interface Model {
modelName: string;
enabled: boolean;
createdAt: string;
unifiedId?: string;
}
export interface UsageStats {
@@ -29,6 +31,7 @@ export interface CreateProviderInput {
name: string;
apiKey: string;
baseUrl: string;
protocol: 'openai' | 'anthropic';
enabled: boolean;
}
@@ -36,11 +39,11 @@ export interface UpdateProviderInput {
name?: string;
apiKey?: string;
baseUrl?: string;
protocol?: 'openai' | 'anthropic';
enabled?: boolean;
}
export interface CreateModelInput {
id: string;
providerId: string;
modelName: string;
enabled: boolean;
@@ -61,13 +64,21 @@ export interface StatsQueryParams {
export class ApiError extends Error {
status: number;
code?: string;
constructor(
status: number,
message: string,
code?: string,
) {
super(message);
this.name = 'ApiError';
this.status = status;
this.code = code;
}
}
export interface ApiErrorResponse {
error: string;
code?: string;
}