fix(host): 修掉会杀死 DSH 的 resolveModelInfo unhandled rejection;按真实事件结构(event.data)重写镜像映射;标题栏与指标显示打磨
This commit is contained in:
+28
-11
@@ -82,18 +82,27 @@
|
||||
|
||||
#title {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: var(--title-font);
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
letter-spacing: .2px;
|
||||
}
|
||||
|
||||
#titleText {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
#title small {
|
||||
flex: 0 0 auto;
|
||||
color: var(--fg-dim);
|
||||
font-weight: 400;
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
.tbtn {
|
||||
@@ -472,7 +481,7 @@
|
||||
<div id="app">
|
||||
<div id="bar">
|
||||
<div class="dot wait" id="dot"></div>
|
||||
<div id="title">DSH 悬浮窗<small id="sub">未连接</small></div>
|
||||
<div id="title"><span id="titleText">DSH 悬浮窗</span><small id="sub">未连接</small></div>
|
||||
<button class="tbtn" id="bPin" title="固定位置">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round">
|
||||
<path d="M9 4h6l-1 6 3 3v1H7v-1l3-3-1-6z" />
|
||||
@@ -650,18 +659,26 @@
|
||||
if (msg.type === 'cmd') return handleCmd(msg.cmd)
|
||||
if (msg.metrics) metrics(msg.metrics)
|
||||
if (msg.messages) messages(msg.messages)
|
||||
if (msg.title) $('title').firstChild.textContent = msg.title
|
||||
if (msg.title) {
|
||||
const t = String(msg.title).slice(0, 42)
|
||||
$('titleText').textContent = 'DSH · ' + t
|
||||
}
|
||||
}
|
||||
|
||||
function metrics(m) {
|
||||
$('m-turn').textContent = m.turns ?? '—'
|
||||
$('m-step').textContent = m.steps ?? '—'
|
||||
$('m-tps').textContent = (m.tps ?? 0).toFixed ? (m.tps ?? 0).toFixed(1) : '—'
|
||||
$('m-mtok').textContent = ((m.tokens ?? 0) / 1e6).toFixed(3)
|
||||
$('m-tps').textContent = m.tps == null ? '—' : Number(m.tps).toFixed(1)
|
||||
$('m-mtok').textContent = m.tokens == null ? '—' : (m.tokens / 1e6).toFixed(3)
|
||||
$('m-cache').textContent = m.cacheHit == null ? '—' : Math.round(m.cacheHit * 100) + '%'
|
||||
const p = Math.max(0, Math.min(1, m.contextUsed ?? 0))
|
||||
$('m-ctxbar').style.right = (100 - p * 100) + '%'
|
||||
$('m-ctx').textContent = Math.round(p * 100) + '%'
|
||||
if (m.contextUsed == null) {
|
||||
$('m-ctxbar').style.right = '100%'
|
||||
$('m-ctx').textContent = '—'
|
||||
} else {
|
||||
const p = Math.max(0, Math.min(1, m.contextUsed))
|
||||
$('m-ctxbar').style.right = (100 - p * 100) + '%'
|
||||
$('m-ctx').textContent = Math.round(p * 100) + '%'
|
||||
}
|
||||
}
|
||||
|
||||
function messages(list) {
|
||||
|
||||
Reference in New Issue
Block a user