mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-05-30 04:40:18 +08:00
refactor(hermes): UX 小白化 - chat.js profile 切换错误用 humanizeError
之前是 toast(err?.message || String(err)),raw error 用户看到一堆英文 traceback。
现在用 humanizeError 自动:
- 分类(NETWORK/TIMEOUT/AUTH/NOT_FOUND/PERMISSION/...)
- 友好文案(中英繁三语)
- 自动加 action button(如「打开设置」「重试」「查看文档」)
## 文件
- chat.js: import humanizeError,profile 切换 catch 改 humanizeError(err, t('engine.chatProfileSwitchFailed'))
- i18n: 新增 chatProfileSwitchFailed × 3 语言
## 范围
仅 profile 切换这个高频操作 — 其他 chat-store 路径错误已通过系统消息气泡展示
(chat-store.js 添加错误消息时本身已经友好),不需要再改。
This commit is contained in:
@@ -13,7 +13,8 @@
|
||||
*
|
||||
* State lives in `chat-store.js`; this module only does DOM + events.
|
||||
*/
|
||||
import { t } from '../../../lib/i18n.js'
|
||||
import * as tts from '../../../lib/tts.js'
|
||||
import { humanizeError } from '../../../lib/humanize-error.js'
|
||||
import { api, invalidate } from '../../../lib/tauri-api.js'
|
||||
import { toast } from '../../../components/toast.js'
|
||||
import { showConfirm } from '../../../components/modal.js'
|
||||
@@ -1008,7 +1009,7 @@ export function render() {
|
||||
await store.switchProfile(name)
|
||||
toast(t('engine.chatProfileSwitched').replace('{name}', name), 'success')
|
||||
} catch (err) {
|
||||
toast((err?.message || String(err)), 'error')
|
||||
toast(humanizeError(err, t('engine.chatProfileSwitchFailed') || 'Profile switch failed'), 'error')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -557,6 +557,8 @@ export default {
|
||||
hermesOAuthDeviceTimeout: _('登录超时(10 分钟未完成)', 'Login timed out (10 min)', '登入逾時(10 分鐘未完成)'),
|
||||
hermesOAuthDeviceFailed: _('授权失败', 'Authorization failed', '授權失敗'),
|
||||
hermesOAuthDisconnectFailed: _('断开失败', 'Disconnect failed', '中斷失敗'),
|
||||
// Hermes UX 小白化:chat profile 切换错误
|
||||
chatProfileSwitchFailed: _('切换 Profile 失败', 'Switch profile failed', '切換 Profile 失敗'),
|
||||
// Web 模式(远程浏览器)下流式聊天暂不可用
|
||||
chatWebModeStreamingUnsupported: _(
|
||||
'Web 模式暂不支持 Hermes 实时流式聊天(依赖桌面端事件桥)。请打开桌面客户端使用此功能。',
|
||||
|
||||
Reference in New Issue
Block a user