From f4f65449f8bc8341182a729e75a505cf2a536e60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E5=A4=A9?= Date: Mon, 25 May 2026 07:44:56 +0800 Subject: [PATCH] fix(hermes): stabilize chat health banner --- src/engines/hermes/pages/chat.js | 1 + src/engines/hermes/style/hermes.css | 9 ++++++++- tests/hermes-chat-ui.test.js | 26 ++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/hermes-chat-ui.test.js diff --git a/src/engines/hermes/pages/chat.js b/src/engines/hermes/pages/chat.js index c5e2696..bb73baa 100644 --- a/src/engines/hermes/pages/chat.js +++ b/src/engines/hermes/pages/chat.js @@ -19,6 +19,7 @@ import { api, invalidate } from '../../../lib/tauri-api.js' import { toast } from '../../../components/toast.js' import { showConfirm } from '../../../components/modal.js' import { getChatStore, getSourceLabel } from '../lib/chat-store.js' +import { svgIcon } from '../lib/svg-icons.js' import { t } from '../../../lib/i18n.js' // ----------------------------------------------------------- helpers diff --git a/src/engines/hermes/style/hermes.css b/src/engines/hermes/style/hermes.css index 40bbab3..214fef2 100644 --- a/src/engines/hermes/style/hermes.css +++ b/src/engines/hermes/style/hermes.css @@ -4617,14 +4617,21 @@ body[data-active-engine="hermes"][data-theme="dark"] { } [data-engine="hermes"] .hm-chat-health-action { flex-shrink: 0; - padding: 4px 12px; + min-width: 44px; + min-height: 44px; + padding: 0 14px; border-radius: 999px; color: inherit; text-decoration: none; font-weight: 500; font-size: 12px; + line-height: 1.2; border: 1px solid currentColor; background: transparent; + display: inline-flex; + align-items: center; + justify-content: center; + box-sizing: border-box; transition: background 0.16s ease, color 0.16s ease; } [data-engine="hermes"] .hm-chat-health-action:hover { diff --git a/tests/hermes-chat-ui.test.js b/tests/hermes-chat-ui.test.js new file mode 100644 index 0000000..d9e4158 --- /dev/null +++ b/tests/hermes-chat-ui.test.js @@ -0,0 +1,26 @@ +import test from 'node:test' +import assert from 'node:assert/strict' +import { readFileSync } from 'node:fs' + +const source = readFileSync(new URL('../src/engines/hermes/pages/chat.js', import.meta.url), 'utf8') +const css = readFileSync(new URL('../src/engines/hermes/style/hermes.css', import.meta.url), 'utf8') + +function cssBlock(selector) { + const escaped = selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + return css.match(new RegExp(`${escaped}\\s*\\{([^}]*)\\}`))?.[1] || '' +} + +test('Hermes 聊天页健康提示使用 svgIcon 时必须导入图标工具', () => { + assert.match(source, /svgIcon\('alert-triangle'/, '缺少健康提示图标渲染') + assert.match( + source, + /import\s+\{\s*svgIcon\s*\}\s+from\s+['"]\.\.\/lib\/svg-icons\.js['"]/, + 'chat.js 使用 svgIcon 前必须导入 Hermes 图标工具', + ) +}) + +test('Hermes 聊天页健康提示操作入口必须满足移动端触控尺寸', () => { + const block = cssBlock('[data-engine="hermes"] .hm-chat-health-action') + assert.match(block, /min-height:\s*44px/, '健康提示操作入口高度必须至少 44px') + assert.match(block, /min-width:\s*44px/, '健康提示操作入口宽度必须至少 44px') +})