From b656ce74f898e9ec6da0a6d90350443152f59832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E5=A4=A9?= Date: Thu, 14 May 2026 05:25:08 +0800 Subject: [PATCH] =?UTF-8?q?refactor(hermes):=20UX=20=E5=B0=8F=E7=99=BD?= =?UTF-8?q?=E5=8C=96=20-=20chat.js=20profile=20=E5=88=87=E6=8D=A2=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=94=A8=20humanizeError?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前是 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 添加错误消息时本身已经友好),不需要再改。 --- src/engines/hermes/pages/chat.js | 5 +++-- src/locales/modules/engine.js | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/engines/hermes/pages/chat.js b/src/engines/hermes/pages/chat.js index b831e8d..5544b16 100644 --- a/src/engines/hermes/pages/chat.js +++ b/src/engines/hermes/pages/chat.js @@ -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') } }) }) diff --git a/src/locales/modules/engine.js b/src/locales/modules/engine.js index c721066..1bce34e 100644 --- a/src/locales/modules/engine.js +++ b/src/locales/modules/engine.js @@ -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 实时流式聊天(依赖桌面端事件桥)。请打开桌面客户端使用此功能。',