fix: 模型管理审查修复与归档

- 修复 registry 测试 ai mock 缺失 createProviderRegistry 导出
- 新增 POST /api/providers/test 支持未保存供应商配置连通性测试
- 供应商表单新增测试连接按钮,新建默认 openai-compatible
- 连通性测试按 ok 展示成功/失败,不再统一 success 样式
- 模型表单新建时也可测试供应商连接
- 模型页使用独立 provider 列表避免分页/搜索影响
- 移除模型管理组件内联 style
- 新增 ProviderTestResultResponse 共享响应类型
- 新增 bun run format:check 脚本
- 补充关键测试覆盖(删除关联、连通性、默认类型、表单测试)
- 更新 docs/user/usage.md、docs/development/*、design.md、tasks.md
- 归档 change 至 openspec/changes/archive/2026-05-29-add-model-management
This commit is contained in:
2026-05-29 14:05:01 +08:00
parent 933c2133f0
commit 48c76e6180
23 changed files with 440 additions and 353 deletions

View File

@@ -6,6 +6,7 @@ import type {
ProviderListResponse,
ProviderResponse,
ProviderTestResponse,
ProviderTestResultResponse,
UpdateProviderRequest,
} from "../../shared/api";
@@ -63,13 +64,27 @@ export async function fetchProviderList(params: {
return response.json() as Promise<ProviderListResponse>;
}
export async function testProviderConfig(data: CreateProviderRequest): Promise<ProviderTestResponse> {
const response = await fetch("/api/providers/test", {
body: JSON.stringify(data),
headers: { "Content-Type": "application/json" },
method: "POST",
});
if (!response.ok) {
const body = (await response.json().catch(() => null)) as null | { error?: string };
throw new Error(body?.error ?? `HTTP ${response.status}`);
}
const result = (await response.json()) as ProviderTestResultResponse;
return result.providerTestResponse;
}
export async function testProviderConnection(id: string): Promise<ProviderTestResponse> {
const response = await fetch(`/api/providers/${id}/test`, { method: "POST" });
if (!response.ok) {
const body = (await response.json().catch(() => null)) as null | { error?: string };
throw new Error(body?.error ?? `HTTP ${response.status}`);
}
const data = (await response.json()) as { providerTestResponse: ProviderTestResponse };
const data = (await response.json()) as ProviderTestResultResponse;
return data.providerTestResponse;
}
@@ -138,6 +153,12 @@ export function useProviderList(params: { keyword?: string; page?: number; pageS
});
}
export function useTestProviderConfig() {
return useMutation({
mutationFn: testProviderConfig,
});
}
export function useTestProviderConnection() {
return useMutation({
mutationFn: testProviderConnection,