mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-05-06 20:02:49 +08:00
fix(models): 获取模型列表 404 改为友好提示 + 助手侧走后端绕 CORS
场景:部分服务商(如某些厂商的 Anthropic 兼容接口)不提供 /models 列表接口, 之前会直接显示 HTTP 404 Not Found / Failed to fetch 等技术错误,用户体验差。 - Rust list_remote_models:识别 404/405/501 作为"不支持自动获取"场景, 返回带 [NOT_SUPPORTED] 前缀的友好错误,而非裸 HTTP 状态码 - 模型配置页「获取列表」:识别 [NOT_SUPPORTED] 后弹出引导对话框, 点击「模型」按钮直接进入手动添加流程 - 助手设置页「获取列表」:改为走 Rust 后端 api.listRemoteModels, 原先直接用前端 fetch 会被 WebView CORS 拦截(provider 不返回 CORS 头), 改走后端既绕开 CORS 又能获得一致的友好提示 - Web 模式 dev-api.js 同步 404 识别逻辑,保证桌面 / Web 行为一致 - 补齐 models.fetchNotSupported / assistant.fetchNotSupported 多语言文案
This commit is contained in:
@@ -5119,6 +5119,11 @@ const handlers = {
|
||||
}
|
||||
clearTimeout(timeout)
|
||||
if (!resp.ok) {
|
||||
// 404/405/501 = 服务商不支持 /models 接口,给用户友好提示
|
||||
const code = resp.status
|
||||
if (code === 404 || code === 405 || code === 501) {
|
||||
throw new Error('[NOT_SUPPORTED] 该服务商不支持自动获取模型列表,请手动输入模型 ID')
|
||||
}
|
||||
const text = await resp.text().catch(() => '')
|
||||
let msg = `HTTP ${resp.status}`
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user