feat(panel): unify token breakdown order and flatten tooltip cards

This commit is contained in:
fish
2026-11-21 00:41:53 +09:00
parent 55320df9b7
commit 6411e49ac4
13 changed files with 200 additions and 95 deletions
@@ -1,7 +1,7 @@
/**
* @fileoverview 通用 4 段式 Token 构成比例条组件 (FourSegmentBar).
* 用于在消费概览、热门模型明细及数据来源明细中直观展示:
* 直接输入 (Input)、缓存读取 (Cached)、内容生成 (Output) 与思考推理 (Thinking) 的 Token 占比。
* 用于在消费概览、热门模型明细及模型总览卡片中直观展示:
* 直接输入 (Input)、缓存读取 (Cached)、思考推理 (Thinking)、内容生成 (Output) 的 Token 占比。
*/
import { h, patchStyleVar } from '../../core/domPatch.js';
@@ -18,18 +18,18 @@ import { h, patchStyleVar } from '../../core/domPatch.js';
* responseTokens?: number,
* thinkingTokens?: number
* }) => void
* }} 组件根元素与增量更新方法
* }} 组件根元素及增量更新方法
*/
export function createFourSegmentBar() {
const segInput = h('div', { className: 'progress-seg seg-input' });
const segCached = h('div', { className: 'progress-seg seg-cached' });
const segOutput = h('div', { className: 'progress-seg seg-output' });
const segThinking = h('div', { className: 'progress-seg seg-thinking' });
const segOutput = h('div', { className: 'progress-seg seg-output' });
const el = h('div', { className: 'progress-track cons-seg-bar' }, [
segInput,
segCached,
segOutput,
segThinking,
segOutput,
]);
/**
+1 -1
View File
@@ -231,7 +231,7 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
'cons.cacheRead': 'Cache Read',
'cons.savedCost': 'Saved {cost}',
'cons.outputUsage': 'Output',
'cons.replyAndThink': 'Reply {resp} · Think {think}',
'cons.replyAndThink': 'Think {think} · Reply {resp}',
'cons.trendTitle': 'Usage Trend',
'cons.allTime': 'All Time',
'cons.trendHeatmapHint': 'Daily ({days}d) · Hover for details',
+2 -2
View File
@@ -231,7 +231,7 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
'cons.cacheRead': '缓存读取',
'cons.savedCost': '节省 {cost}',
'cons.outputUsage': '输出用量',
'cons.replyAndThink': '回复 {resp} · 思考 {think}',
'cons.replyAndThink': '思考 {think} · 回复 {resp}',
'cons.trendTitle': '用量趋势',
'cons.allTime': '全部时间',
'cons.trendHeatmapHint': '按日 ({days}天) · 悬停查看',
@@ -296,7 +296,7 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
'steps.modelCallsOnly': '{calls}次',
'steps.modelsSummaryPrefix': '{count} 模型 · ',
'steps.modelPerfFoot': '均速 {tps} · 首字 {ttft} · 缓存 {cache}%',
'steps.modelSplitFoot': '入 {inTok} · 缓 {cacheTok} · 思 {thinkTok} · 正 {respTok}',
'steps.modelSplitFoot': '输入 {inTok} · 缓存 {cacheTok} · 思考 {thinkTok} · 输出 {respTok}',
'steps.fitActiveCardTitle': '{title}(已纳入上方趋势拟合,按住 Ctrl/Shift 点击可多选对比)',
'steps.fitInactiveCardTitle': '点击在上方拟合图查看 {text}(按住 Ctrl/Shift 点击可多选同图对比)',
'steps.turnMediaOnly': '[图片/附件提问]',
+2 -5
View File
@@ -469,12 +469,9 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
border: none;
}
[data-modern-ui="true"] .trend-tip-sub {
background: var(--modern-surface-subtle);
}
[data-modern-ui="true"] .trend-tip-sub,
[data-modern-ui="true"] .trend-tip-cost {
background: var(--modern-surface-subtle);
background: transparent;
}
[data-modern-ui="true"] .cons-pop-models {
+10 -10
View File
@@ -403,13 +403,13 @@
}
.trend-tip-cost {
font-size: var(--fs-sm);
font-size: var(--fs-md);
font-weight: 600;
line-height: 1.2;
padding: 2px 7px;
border-radius: var(--radius-xs);
padding: 0;
border-radius: 0;
color: var(--text-primary);
background: color-mix(in srgb, var(--text-primary) 6%, transparent);
background: transparent;
white-space: nowrap;
flex-shrink: 0;
}
@@ -419,10 +419,10 @@
}
.trend-tip-sub {
padding: 5px 8px;
padding: 2px 0;
border: none;
border-radius: var(--radius-xs);
background: color-mix(in srgb, var(--text-primary) 4.2%, transparent);
border-radius: 0;
background: transparent;
font-size: var(--fs-xs);
line-height: 1.3;
color: var(--text-secondary);
@@ -438,8 +438,8 @@
.trend-tip-sub.is-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 8px;
padding: 6px 8px;
gap: 10px;
padding: 2px 0;
white-space: normal;
overflow: visible;
}
@@ -881,7 +881,7 @@
.trend-tip-sub:not([hidden]) + .cons-pop-models {
border-top: none;
padding-top: 1px;
padding-top: 2px;
margin-top: 0;
}
+17 -7
View File
@@ -1093,17 +1093,27 @@
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 2px 10px;
font-size: var(--fs-sm);
gap: 4px 10px;
font-size: var(--fs-md);
color: var(--text-secondary);
}
.smodel-perf {
color: var(--text-secondary);
white-space: nowrap;
}
.smodel-split {
display: inline-flex;
align-items: center;
flex-wrap: wrap;
gap: 4px 10px;
color: var(--text-secondary);
}
.smodel-split strong {
color: var(--text-primary);
font-weight: 600;
}
.smodel-perf {
margin-left: auto;
font-size: var(--fs-sm);
color: var(--text-muted);
white-space: nowrap;
}
+5 -5
View File
@@ -662,16 +662,16 @@ export const ConsumptionView = defineComponent({
cacheLbl,
cacheVal,
]),
h('span', { className: 'legend-left' }, [
h('span', { className: 'dot-swatch seg-output' }),
outLbl,
outVal,
]),
h('span', { className: 'legend-left' }, [
h('span', { className: 'dot-swatch seg-thinking' }),
thinkLbl,
thinkVal,
]),
h('span', { className: 'legend-left' }, [
h('span', { className: 'dot-swatch seg-output' }),
outLbl,
outVal,
]),
h('span', { className: 'legend-left' }, [
callsLbl,
callsVal,
+50 -12
View File
@@ -21,6 +21,7 @@ import {
formatMetric,
formatSpeedMetric,
formatTokens,
formatTokensPrecise,
formatUsd,
mergeModelsByDisplayName,
normalizeModelDisplayMode,
@@ -1151,8 +1152,37 @@ export const StepsDetailView = defineComponent({
const segBar = createFourSegmentBar();
segBar.el.classList.add('smodel-seg-bar');
const inLbl = h('span', { text: t('cons.footInput') });
const cacheLbl = h('span', { text: t('cons.footCache') });
const thinkLbl = h('span', { text: t('cons.footThinking') });
const outLbl = h('span', { text: t('cons.footOutput') });
const inVal = h('strong', { className: 'text-mono' });
const cacheVal = h('strong', { className: 'text-mono' });
const thinkVal = h('strong', { className: 'text-mono' });
const outVal = h('strong', { className: 'text-mono' });
const splitEl = h('div', { className: 'smodel-split' }, [
h('span', { className: 'legend-left' }, [
h('span', { className: 'dot-swatch seg-input' }),
inLbl,
inVal,
]),
h('span', { className: 'legend-left' }, [
h('span', { className: 'dot-swatch seg-cached' }),
cacheLbl,
cacheVal,
]),
h('span', { className: 'legend-left' }, [
h('span', { className: 'dot-swatch seg-thinking' }),
thinkLbl,
thinkVal,
]),
h('span', { className: 'legend-left' }, [
h('span', { className: 'dot-swatch seg-output' }),
outLbl,
outVal,
]),
]);
const perfEl = h('span', { className: 'smodel-perf text-mono' });
const splitEl = h('span', { className: 'smodel-split text-mono' });
const cardEl = h('div', { className: 'smodel-card' }, [
h('div', { className: 'smodel-head' }, [
@@ -1160,7 +1190,7 @@ export const StepsDetailView = defineComponent({
h('div', { className: 'smodel-totals' }, [tokEl, costEl]),
]),
segBar.el,
h('div', { className: 'smodel-foot' }, [perfEl, splitEl]),
h('div', { className: 'smodel-foot' }, [splitEl, perfEl]),
]);
return {
@@ -1174,6 +1204,14 @@ export const StepsDetailView = defineComponent({
segBar,
perfEl,
splitEl,
inLbl,
cacheLbl,
thinkLbl,
outLbl,
inVal,
cacheVal,
thinkVal,
outVal,
cardTitle: '',
isHoveringAnomaly: false,
},
@@ -1244,7 +1282,7 @@ export const StepsDetailView = defineComponent({
? Math.max(0, Number(m.responseTokens))
: Math.max(0, outTok - thinkTok);
patchText(refs.tokEl, formatTokens(m.totalTokens || 0));
patchText(refs.tokEl, formatTokensPrecise(m.totalTokens || 0));
const costNum = Number(m.costUsd || 0);
const isAllUnpriced =
calls > 0 && Number(m.unpricedCalls || 0) >= calls && !(costNum > 0);
@@ -1275,6 +1313,15 @@ export const StepsDetailView = defineComponent({
? +((cacheTok / promptTok) * 100).toFixed(1)
: 0;
patchText(refs.inLbl, t('cons.footInput'));
patchText(refs.cacheLbl, t('cons.footCache'));
patchText(refs.thinkLbl, t('cons.footThinking'));
patchText(refs.outLbl, t('cons.footOutput'));
patchText(refs.inVal, formatTokensPrecise(inTok));
patchText(refs.cacheVal, formatTokensPrecise(cacheTok));
patchText(refs.thinkVal, formatTokensPrecise(thinkTok));
patchText(refs.outVal, formatTokensPrecise(respTok));
patchText(
refs.perfEl,
t('steps.modelPerfFoot', {
@@ -1283,15 +1330,6 @@ export const StepsDetailView = defineComponent({
cache: resolvedCachePct,
})
);
patchText(
refs.splitEl,
t('steps.modelSplitFoot', {
inTok: formatTokens(inTok),
cacheTok: formatTokens(cacheTok),
thinkTok: formatTokens(thinkTok),
respTok: formatTokens(respTok),
})
);
const isActiveFit =
hasMultipleModels && cardGroupKeys.some((k) => fitActiveKeySet.has(k));