fix(hermes): stabilize chat health banner

This commit is contained in:
晴天
2026-05-25 07:44:56 +08:00
parent c41340a9e0
commit f4f65449f8
3 changed files with 35 additions and 1 deletions

View File

@@ -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

View File

@@ -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 {

View File

@@ -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')
})