mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
fix(panel): eliminate hover flicker in monthly chart and breakdown rows
- Replace the 3px .monthly-grid column gap with zero-gap column padding and hand off hover across adjacent active months without hiding or restarting the popover fade-in - Wrap the progress bar and model-name footer inside a single .cons-source-hover-zone across client sources, project ranking, and session ranking so crossing the vertical gap keeps the popover and highlight steady
This commit is contained in:
+143
-97
@@ -29873,6 +29873,7 @@ const ConsumptionView = defineComponent({
|
|||||||
});
|
});
|
||||||
|
|
||||||
let activeHoverTargetEl = null;
|
let activeHoverTargetEl = null;
|
||||||
|
let activeHoverPayload = null;
|
||||||
let cachedBreakdownRootRect = null;
|
let cachedBreakdownRootRect = null;
|
||||||
let cachedBreakdownAnchorRect = null;
|
let cachedBreakdownAnchorRect = null;
|
||||||
|
|
||||||
@@ -29889,6 +29890,7 @@ const ConsumptionView = defineComponent({
|
|||||||
function hideBreakdownPopover() {
|
function hideBreakdownPopover() {
|
||||||
cachedBreakdownRootRect = null;
|
cachedBreakdownRootRect = null;
|
||||||
cachedBreakdownAnchorRect = null;
|
cachedBreakdownAnchorRect = null;
|
||||||
|
activeHoverPayload = null;
|
||||||
if (activeHoverTargetEl) {
|
if (activeHoverTargetEl) {
|
||||||
patchClasses(activeHoverTargetEl, { 'is-hovered': false });
|
patchClasses(activeHoverTargetEl, { 'is-hovered': false });
|
||||||
activeHoverTargetEl = null;
|
activeHoverTargetEl = null;
|
||||||
@@ -29964,6 +29966,9 @@ const ConsumptionView = defineComponent({
|
|||||||
hideBreakdownPopover();
|
hideBreakdownPopover();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const wasHidden = breakdownPopoverEl.hasAttribute('hidden');
|
||||||
|
const sameTargetAndPayload =
|
||||||
|
!wasHidden && activeHoverTargetEl === anchorEl && activeHoverPayload === payload;
|
||||||
if (activeHoverTargetEl && activeHoverTargetEl !== anchorEl) {
|
if (activeHoverTargetEl && activeHoverTargetEl !== anchorEl) {
|
||||||
patchClasses(activeHoverTargetEl, { 'is-hovered': false });
|
patchClasses(activeHoverTargetEl, { 'is-hovered': false });
|
||||||
cachedBreakdownAnchorRect = null;
|
cachedBreakdownAnchorRect = null;
|
||||||
@@ -29972,22 +29977,24 @@ const ConsumptionView = defineComponent({
|
|||||||
cachedBreakdownAnchorRect = null;
|
cachedBreakdownAnchorRect = null;
|
||||||
}
|
}
|
||||||
activeHoverTargetEl = anchorEl;
|
activeHoverTargetEl = anchorEl;
|
||||||
|
activeHoverPayload = payload;
|
||||||
patchClasses(anchorEl, { 'is-hovered': true });
|
patchClasses(anchorEl, { 'is-hovered': true });
|
||||||
|
|
||||||
popoverContent.update({
|
if (!sameTargetAndPayload) {
|
||||||
title: payload.title || '—',
|
popoverContent.update({
|
||||||
calls: payload.calls || 0,
|
title: payload.title || '—',
|
||||||
totalTokens: payload.totalTokens || 0,
|
calls: payload.calls || 0,
|
||||||
costText: payload.costText || '$0.00',
|
totalTokens: payload.totalTokens || 0,
|
||||||
inputTokens: payload.inputTokens,
|
costText: payload.costText || '$0.00',
|
||||||
cacheReadTokens: payload.cacheReadTokens,
|
inputTokens: payload.inputTokens,
|
||||||
thinkingTokens: payload.thinkingTokens,
|
cacheReadTokens: payload.cacheReadTokens,
|
||||||
responseTokens: payload.responseTokens,
|
thinkingTokens: payload.thinkingTokens,
|
||||||
outputTokens: payload.outputTokens,
|
responseTokens: payload.responseTokens,
|
||||||
segments: Array.isArray(payload.segments) ? payload.segments : [],
|
outputTokens: payload.outputTokens,
|
||||||
});
|
segments: Array.isArray(payload.segments) ? payload.segments : [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const wasHidden = breakdownPopoverEl.hasAttribute('hidden');
|
|
||||||
patchAttr(breakdownPopoverEl, 'hidden', false);
|
patchAttr(breakdownPopoverEl, 'hidden', false);
|
||||||
positionBreakdownPopover(anchorEl, pointerClientX, pointerClientY);
|
positionBreakdownPopover(anchorEl, pointerClientX, pointerClientY);
|
||||||
if (wasHidden) {
|
if (wasHidden) {
|
||||||
@@ -30010,6 +30017,19 @@ const ConsumptionView = defineComponent({
|
|||||||
return { el: segEl, refs: { segEl } };
|
return { el: segEl, refs: { segEl } };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let monthlyGridEl = null;
|
||||||
|
const monthlyColByEl = new Map();
|
||||||
|
|
||||||
|
function findMonthlyColForNode(node) {
|
||||||
|
let cur = node;
|
||||||
|
while (cur && cur !== monthlyGridEl) {
|
||||||
|
const hit = monthlyColByEl.get(cur);
|
||||||
|
if (hit) return hit;
|
||||||
|
cur = cur.parentNode || null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const monthlyCols = Array.from({ length: 12 }, (_, idx) => {
|
const monthlyCols = Array.from({ length: 12 }, (_, idx) => {
|
||||||
const costText = h('span', { className: 'month-cost text-mono', text: '' });
|
const costText = h('span', { className: 'month-cost text-mono', text: '' });
|
||||||
const stackWrap = h('div', { className: 'month-stack' });
|
const stackWrap = h('div', { className: 'month-stack' });
|
||||||
@@ -30036,6 +30056,9 @@ const ConsumptionView = defineComponent({
|
|||||||
e?.clientY ?? null
|
e?.clientY ?? null
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
if (activeHoverTargetEl && monthlyColByEl.has(activeHoverTargetEl)) {
|
||||||
|
hideBreakdownPopover();
|
||||||
|
}
|
||||||
e?.stopPropagation?.();
|
e?.stopPropagation?.();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -30044,8 +30067,16 @@ const ConsumptionView = defineComponent({
|
|||||||
positionBreakdownPopover(colEl, e?.clientX ?? null, e?.clientY ?? null);
|
positionBreakdownPopover(colEl, e?.clientX ?? null, e?.clientY ?? null);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onMouseLeave: () => {
|
onMouseLeave: (e) => {
|
||||||
if (activeHoverTargetEl === colEl) hideBreakdownPopover();
|
if (activeHoverTargetEl !== colEl) return;
|
||||||
|
const nextEl = e?.relatedTarget || null;
|
||||||
|
if (nextEl) {
|
||||||
|
const nextCol = findMonthlyColForNode(nextEl);
|
||||||
|
if ((nextCol && nextCol.colState.hoverPayload) || nextEl === monthlyGridEl) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hideBreakdownPopover();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
@@ -30055,7 +30086,7 @@ const ConsumptionView = defineComponent({
|
|||||||
tokText,
|
tokText,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
return {
|
const colRec = {
|
||||||
el: colEl,
|
el: colEl,
|
||||||
costText,
|
costText,
|
||||||
stackWrap,
|
stackWrap,
|
||||||
@@ -30064,8 +30095,23 @@ const ConsumptionView = defineComponent({
|
|||||||
tokText,
|
tokText,
|
||||||
colState,
|
colState,
|
||||||
};
|
};
|
||||||
|
monthlyColByEl.set(colEl, colRec);
|
||||||
|
return colRec;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
monthlyGridEl = h(
|
||||||
|
'div',
|
||||||
|
{
|
||||||
|
className: 'monthly-grid',
|
||||||
|
onMouseLeave: () => {
|
||||||
|
if (activeHoverTargetEl && monthlyColByEl.has(activeHoverTargetEl)) {
|
||||||
|
hideBreakdownPopover();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
monthlyCols.map((c) => c.el)
|
||||||
|
);
|
||||||
|
|
||||||
const monthlyPanel = h('section', { className: 'panel' }, [
|
const monthlyPanel = h('section', { className: 'panel' }, [
|
||||||
h('div', { className: 'panel-header' }, [
|
h('div', { className: 'panel-header' }, [
|
||||||
h('span', { className: 'panel-title' }, [
|
h('span', { className: 'panel-title' }, [
|
||||||
@@ -30074,11 +30120,7 @@ const ConsumptionView = defineComponent({
|
|||||||
]),
|
]),
|
||||||
monthlyHoverHint,
|
monthlyHoverHint,
|
||||||
]),
|
]),
|
||||||
h(
|
monthlyGridEl,
|
||||||
'div',
|
|
||||||
{ className: 'monthly-grid' },
|
|
||||||
monthlyCols.map((c) => c.el)
|
|
||||||
),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const scrollInner = h(
|
const scrollInner = h(
|
||||||
@@ -30567,6 +30609,54 @@ const ConsumptionView = defineComponent({
|
|||||||
/**
|
/**
|
||||||
* 创建客户端来源单行 DOM 结构(保留长尾合并分段配色进度条、单行不换行的 Top 2-3 模型速览和右侧总调用数,悬停进度条或速览区弹出完整明细浮层)。
|
* 创建客户端来源单行 DOM 结构(保留长尾合并分段配色进度条、单行不换行的 Top 2-3 模型速览和右侧总调用数,悬停进度条或速览区弹出完整明细浮层)。
|
||||||
*/
|
*/
|
||||||
|
function isNodeInside(root, node) {
|
||||||
|
if (!root || !node) return false;
|
||||||
|
if (typeof root.contains === 'function') return root.contains(node);
|
||||||
|
let cur = node;
|
||||||
|
while (cur) {
|
||||||
|
if (cur === root) return true;
|
||||||
|
cur = cur.parentNode || null;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function attachUnifiedHoverZone(zoneEl, compatTargets, rowState) {
|
||||||
|
zoneEl.addEventListener('mouseenter', (e) => {
|
||||||
|
if (rowState.hoverPayload) {
|
||||||
|
showBreakdownPopover(zoneEl, rowState.hoverPayload, e?.clientX ?? null, e?.clientY ?? null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
zoneEl.addEventListener('mousemove', (e) => {
|
||||||
|
if (rowState.hoverPayload && activeHoverTargetEl === zoneEl) {
|
||||||
|
positionBreakdownPopover(zoneEl, e?.clientX ?? null, e?.clientY ?? null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
zoneEl.addEventListener('mouseleave', () => {
|
||||||
|
if (activeHoverTargetEl === zoneEl) hideBreakdownPopover();
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const childEl of compatTargets) {
|
||||||
|
if (!childEl) continue;
|
||||||
|
childEl.addEventListener('mouseenter', (e) => {
|
||||||
|
if (rowState.hoverPayload) {
|
||||||
|
showBreakdownPopover(zoneEl, rowState.hoverPayload, e?.clientX ?? null, e?.clientY ?? null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
childEl.addEventListener('mousemove', (e) => {
|
||||||
|
if (rowState.hoverPayload && activeHoverTargetEl === zoneEl) {
|
||||||
|
positionBreakdownPopover(zoneEl, e?.clientX ?? null, e?.clientY ?? null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
childEl.addEventListener('mouseleave', (e) => {
|
||||||
|
const nextEl = e?.relatedTarget || null;
|
||||||
|
if (isNodeInside(zoneEl, nextEl)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (activeHoverTargetEl === zoneEl) hideBreakdownPopover();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function createSourceBreakdownRow() {
|
function createSourceBreakdownRow() {
|
||||||
const nameTextEl = h('span', { className: 'cons-row-title-text' });
|
const nameTextEl = h('span', { className: 'cons-row-title-text' });
|
||||||
const nameEl = h('strong', { className: 'cons-row-title' }, [nameTextEl]);
|
const nameEl = h('strong', { className: 'cons-row-title' }, [nameTextEl]);
|
||||||
@@ -30575,26 +30665,7 @@ const ConsumptionView = defineComponent({
|
|||||||
const costEl = h('strong', { className: 'cons-row-cost text-mono' });
|
const costEl = h('strong', { className: 'cons-row-cost text-mono' });
|
||||||
const trackEl = h('div', { className: 'progress-track cons-seg-bar cons-source-model-bar' });
|
const trackEl = h('div', { className: 'progress-track cons-seg-bar cons-source-model-bar' });
|
||||||
const rowState = { hoverPayload: null };
|
const rowState = { hoverPayload: null };
|
||||||
const bindPopoverHover = (targetEl) => ({
|
|
||||||
onMouseEnter: (e) => {
|
|
||||||
if (rowState.hoverPayload) {
|
|
||||||
showBreakdownPopover(
|
|
||||||
targetEl,
|
|
||||||
rowState.hoverPayload,
|
|
||||||
e?.clientX ?? null,
|
|
||||||
e?.clientY ?? null
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onMouseMove: (e) => {
|
|
||||||
if (rowState.hoverPayload && activeHoverTargetEl === targetEl) {
|
|
||||||
positionBreakdownPopover(targetEl, e?.clientX ?? null, e?.clientY ?? null);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onMouseLeave: () => {
|
|
||||||
if (activeHoverTargetEl === targetEl) hideBreakdownPopover();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const barHitEl = h(
|
const barHitEl = h(
|
||||||
'div',
|
'div',
|
||||||
{
|
{
|
||||||
@@ -30602,20 +30673,23 @@ const ConsumptionView = defineComponent({
|
|||||||
},
|
},
|
||||||
[trackEl]
|
[trackEl]
|
||||||
);
|
);
|
||||||
const barHandlers = bindPopoverHover(barHitEl);
|
|
||||||
barHitEl.addEventListener('mouseenter', barHandlers.onMouseEnter);
|
|
||||||
barHitEl.addEventListener('mousemove', barHandlers.onMouseMove);
|
|
||||||
barHitEl.addEventListener('mouseleave', barHandlers.onMouseLeave);
|
|
||||||
|
|
||||||
const topModelsEl = h('div', { className: 'cons-source-top-models', hidden: true });
|
const topModelsEl = h('div', { className: 'cons-source-top-models', hidden: true });
|
||||||
const topHandlers = bindPopoverHover(topModelsEl);
|
|
||||||
topModelsEl.addEventListener('mouseenter', topHandlers.onMouseEnter);
|
|
||||||
topModelsEl.addEventListener('mousemove', topHandlers.onMouseMove);
|
|
||||||
topModelsEl.addEventListener('mouseleave', topHandlers.onMouseLeave);
|
|
||||||
|
|
||||||
const callsLbl = h('span', { text: t('cons.footCalls') });
|
const callsLbl = h('span', { text: t('cons.footCalls') });
|
||||||
const callsVal = h('strong', { className: 'text-mono' });
|
const callsVal = h('strong', { className: 'text-mono' });
|
||||||
|
|
||||||
|
const hoverZoneEl = h('div', { className: 'cons-source-hover-zone' }, [
|
||||||
|
barHitEl,
|
||||||
|
h('div', { className: 'cons-item-foot cons-source-foot' }, [
|
||||||
|
topModelsEl,
|
||||||
|
h('span', { className: 'legend-left cons-calls-stat' }, [
|
||||||
|
callsLbl,
|
||||||
|
callsVal,
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
attachUnifiedHoverZone(hoverZoneEl, [barHitEl, topModelsEl], rowState);
|
||||||
|
|
||||||
const rowEl = h('div', { className: 'cons-item-row cons-source-row' }, [
|
const rowEl = h('div', { className: 'cons-item-row cons-source-row' }, [
|
||||||
h('div', { className: 'panel-header' }, [
|
h('div', { className: 'panel-header' }, [
|
||||||
nameEl,
|
nameEl,
|
||||||
@@ -30625,14 +30699,7 @@ const ConsumptionView = defineComponent({
|
|||||||
costEl,
|
costEl,
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
barHitEl,
|
hoverZoneEl,
|
||||||
h('div', { className: 'cons-item-foot cons-source-foot' }, [
|
|
||||||
topModelsEl,
|
|
||||||
h('span', { className: 'legend-left cons-calls-stat' }, [
|
|
||||||
callsLbl,
|
|
||||||
callsVal,
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -30643,6 +30710,7 @@ const ConsumptionView = defineComponent({
|
|||||||
pctBadge,
|
pctBadge,
|
||||||
totalTokEl,
|
totalTokEl,
|
||||||
costEl,
|
costEl,
|
||||||
|
hoverZoneEl,
|
||||||
barHitEl,
|
barHitEl,
|
||||||
trackEl,
|
trackEl,
|
||||||
topModelsEl,
|
topModelsEl,
|
||||||
@@ -30746,6 +30814,7 @@ const ConsumptionView = defineComponent({
|
|||||||
segments: partitioned,
|
segments: partitioned,
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
|
patchClasses(refs.hoverZoneEl, { 'is-interactive': Boolean(refs.rowState.hoverPayload) });
|
||||||
}
|
}
|
||||||
|
|
||||||
function createTopConversationRow() {
|
function createTopConversationRow() {
|
||||||
@@ -30761,43 +30830,26 @@ const ConsumptionView = defineComponent({
|
|||||||
const trackEl = h('div', { className: 'progress-track cons-seg-bar cons-source-model-bar' });
|
const trackEl = h('div', { className: 'progress-track cons-seg-bar cons-source-model-bar' });
|
||||||
const rowState = { cascadeId: '', canJump: false, hoverPayload: null };
|
const rowState = { cascadeId: '', canJump: false, hoverPayload: null };
|
||||||
|
|
||||||
const bindPopoverHover = (targetEl) => ({
|
|
||||||
onMouseEnter: (e) => {
|
|
||||||
if (rowState.hoverPayload) {
|
|
||||||
showBreakdownPopover(
|
|
||||||
targetEl,
|
|
||||||
rowState.hoverPayload,
|
|
||||||
e?.clientX ?? null,
|
|
||||||
e?.clientY ?? null
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onMouseMove: (e) => {
|
|
||||||
if (rowState.hoverPayload && activeHoverTargetEl === targetEl) {
|
|
||||||
positionBreakdownPopover(targetEl, e?.clientX ?? null, e?.clientY ?? null);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onMouseLeave: () => {
|
|
||||||
if (activeHoverTargetEl === targetEl) hideBreakdownPopover();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const barHitEl = h('div', { className: 'cons-source-bar-hit' }, [trackEl]);
|
const barHitEl = h('div', { className: 'cons-source-bar-hit' }, [trackEl]);
|
||||||
const barHandlers = bindPopoverHover(barHitEl);
|
|
||||||
barHitEl.addEventListener('mouseenter', barHandlers.onMouseEnter);
|
|
||||||
barHitEl.addEventListener('mousemove', barHandlers.onMouseMove);
|
|
||||||
barHitEl.addEventListener('mouseleave', barHandlers.onMouseLeave);
|
|
||||||
|
|
||||||
const topModelsEl = h('div', { className: 'cons-source-top-models', hidden: true });
|
const topModelsEl = h('div', { className: 'cons-source-top-models', hidden: true });
|
||||||
const topHandlers = bindPopoverHover(topModelsEl);
|
|
||||||
topModelsEl.addEventListener('mouseenter', topHandlers.onMouseEnter);
|
|
||||||
topModelsEl.addEventListener('mousemove', topHandlers.onMouseMove);
|
|
||||||
topModelsEl.addEventListener('mouseleave', topHandlers.onMouseLeave);
|
|
||||||
|
|
||||||
const fallbackMetaEl = h('span', { className: 'cons-top-conv-meta', hidden: true });
|
const fallbackMetaEl = h('span', { className: 'cons-top-conv-meta', hidden: true });
|
||||||
const callsLbl = h('span', { text: t('cons.footCalls') });
|
const callsLbl = h('span', { text: t('cons.footCalls') });
|
||||||
const callsVal = h('strong', { className: 'text-mono' });
|
const callsVal = h('strong', { className: 'text-mono' });
|
||||||
|
|
||||||
|
const hoverZoneEl = h('div', { className: 'cons-source-hover-zone' }, [
|
||||||
|
barHitEl,
|
||||||
|
h('div', { className: 'cons-item-foot cons-source-foot' }, [
|
||||||
|
topModelsEl,
|
||||||
|
fallbackMetaEl,
|
||||||
|
h('span', { className: 'legend-left cons-calls-stat' }, [
|
||||||
|
callsLbl,
|
||||||
|
callsVal,
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
attachUnifiedHoverZone(hoverZoneEl, [barHitEl, topModelsEl], rowState);
|
||||||
|
|
||||||
const rowEl = h(
|
const rowEl = h(
|
||||||
'div',
|
'div',
|
||||||
{
|
{
|
||||||
@@ -30825,15 +30877,7 @@ const ConsumptionView = defineComponent({
|
|||||||
costEl,
|
costEl,
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
barHitEl,
|
hoverZoneEl,
|
||||||
h('div', { className: 'cons-item-foot cons-source-foot' }, [
|
|
||||||
topModelsEl,
|
|
||||||
fallbackMetaEl,
|
|
||||||
h('span', { className: 'legend-left cons-calls-stat' }, [
|
|
||||||
callsLbl,
|
|
||||||
callsVal,
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -30847,6 +30891,7 @@ const ConsumptionView = defineComponent({
|
|||||||
pctBadge,
|
pctBadge,
|
||||||
totalTokEl,
|
totalTokEl,
|
||||||
costEl,
|
costEl,
|
||||||
|
hoverZoneEl,
|
||||||
barHitEl,
|
barHitEl,
|
||||||
trackEl,
|
trackEl,
|
||||||
topModelsEl,
|
topModelsEl,
|
||||||
@@ -31004,6 +31049,7 @@ const ConsumptionView = defineComponent({
|
|||||||
segments: partitioned,
|
segments: partitioned,
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
|
patchClasses(refs.hoverZoneEl, { 'is-interactive': Boolean(refs.rowState.hoverPayload) });
|
||||||
}
|
}
|
||||||
|
|
||||||
let latestSlice = null;
|
let latestSlice = null;
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>用量监控</title>
|
<title>用量监控</title>
|
||||||
<link rel="stylesheet" href="/styles.css?v=1795453915976">
|
<link rel="stylesheet" href="/styles.css?v=1795456766440">
|
||||||
<script src="/preload.js"></script>
|
<script src="/preload.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app-root"></div>
|
<div id="app-root"></div>
|
||||||
<script src="/app.js?v=1795453915976"></script>
|
<script src="/app.js?v=1795456766440"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -479,6 +479,8 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
|
|||||||
border-top-color: color-mix(in srgb, var(--text-primary) 8%, transparent);
|
border-top-color: color-mix(in srgb, var(--text-primary) 8%, transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[data-modern-ui="true"] .cons-source-hover-zone.is-interactive:hover .cons-source-model-bar,
|
||||||
|
[data-modern-ui="true"] .cons-source-hover-zone.is-hovered .cons-source-model-bar,
|
||||||
[data-modern-ui="true"] .cons-source-bar-hit:hover .cons-source-model-bar,
|
[data-modern-ui="true"] .cons-source-bar-hit:hover .cons-source-model-bar,
|
||||||
[data-modern-ui="true"] .cons-source-bar-hit.is-hovered .cons-source-model-bar,
|
[data-modern-ui="true"] .cons-source-bar-hit.is-hovered .cons-source-model-bar,
|
||||||
[data-modern-ui="true"] .month-col.is-interactive:hover .month-stack,
|
[data-modern-ui="true"] .month-col.is-interactive:hover .month-stack,
|
||||||
|
|||||||
@@ -891,12 +891,27 @@
|
|||||||
container-type: inline-size;
|
container-type: inline-size;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cons-source-bar-hit {
|
.cons-source-hover-zone {
|
||||||
padding: 5px 0;
|
display: flex;
|
||||||
margin: -5px 0;
|
flex-direction: column;
|
||||||
|
gap: 5px;
|
||||||
|
padding: 4px 0 2px;
|
||||||
|
margin: -4px 0 -2px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cons-source-hover-zone.is-interactive {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cons-source-bar-hit {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
cursor: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cons-source-hover-zone.is-interactive:hover .cons-source-model-bar,
|
||||||
|
.cons-source-hover-zone.is-hovered .cons-source-model-bar,
|
||||||
.cons-source-bar-hit:hover .cons-source-model-bar,
|
.cons-source-bar-hit:hover .cons-source-model-bar,
|
||||||
.cons-source-bar-hit.is-hovered .cons-source-model-bar {
|
.cons-source-bar-hit.is-hovered .cons-source-model-bar {
|
||||||
box-shadow: 0 0 0 1px var(--border-strong);
|
box-shadow: 0 0 0 1px var(--border-strong);
|
||||||
@@ -959,6 +974,8 @@
|
|||||||
transition: color 120ms ease;
|
transition: color 120ms ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cons-source-hover-zone.is-interactive:hover .cons-source-top-name,
|
||||||
|
.cons-source-hover-zone.is-hovered .cons-source-top-name,
|
||||||
.cons-source-top-models:hover .cons-source-top-name,
|
.cons-source-top-models:hover .cons-source-top-name,
|
||||||
.cons-source-top-models.is-hovered .cons-source-top-name {
|
.cons-source-top-models.is-hovered .cons-source-top-name {
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
@@ -1236,17 +1253,20 @@
|
|||||||
/* --- 6. 12 个月垂直堆叠柱状图 (12-Month Stacked Bar Chart) --- */
|
/* --- 6. 12 个月垂直堆叠柱状图 (12-Month Stacked Bar Chart) --- */
|
||||||
.monthly-grid {
|
.monthly-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(12, 1fr);
|
grid-template-columns: repeat(12, minmax(0, 1fr));
|
||||||
gap: 3px;
|
gap: 0;
|
||||||
align-items: end;
|
align-items: stretch;
|
||||||
padding-top: var(--space-2);
|
margin: var(--space-2) -1.5px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.month-col {
|
.month-col {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
gap: 3px;
|
gap: 3px;
|
||||||
|
padding: 0 1.5px;
|
||||||
|
box-sizing: border-box;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -538,6 +538,7 @@ export const ConsumptionView = defineComponent({
|
|||||||
});
|
});
|
||||||
|
|
||||||
let activeHoverTargetEl = null;
|
let activeHoverTargetEl = null;
|
||||||
|
let activeHoverPayload = null;
|
||||||
let cachedBreakdownRootRect = null;
|
let cachedBreakdownRootRect = null;
|
||||||
let cachedBreakdownAnchorRect = null;
|
let cachedBreakdownAnchorRect = null;
|
||||||
|
|
||||||
@@ -554,6 +555,7 @@ export const ConsumptionView = defineComponent({
|
|||||||
function hideBreakdownPopover() {
|
function hideBreakdownPopover() {
|
||||||
cachedBreakdownRootRect = null;
|
cachedBreakdownRootRect = null;
|
||||||
cachedBreakdownAnchorRect = null;
|
cachedBreakdownAnchorRect = null;
|
||||||
|
activeHoverPayload = null;
|
||||||
if (activeHoverTargetEl) {
|
if (activeHoverTargetEl) {
|
||||||
patchClasses(activeHoverTargetEl, { 'is-hovered': false });
|
patchClasses(activeHoverTargetEl, { 'is-hovered': false });
|
||||||
activeHoverTargetEl = null;
|
activeHoverTargetEl = null;
|
||||||
@@ -629,6 +631,9 @@ export const ConsumptionView = defineComponent({
|
|||||||
hideBreakdownPopover();
|
hideBreakdownPopover();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const wasHidden = breakdownPopoverEl.hasAttribute('hidden');
|
||||||
|
const sameTargetAndPayload =
|
||||||
|
!wasHidden && activeHoverTargetEl === anchorEl && activeHoverPayload === payload;
|
||||||
if (activeHoverTargetEl && activeHoverTargetEl !== anchorEl) {
|
if (activeHoverTargetEl && activeHoverTargetEl !== anchorEl) {
|
||||||
patchClasses(activeHoverTargetEl, { 'is-hovered': false });
|
patchClasses(activeHoverTargetEl, { 'is-hovered': false });
|
||||||
cachedBreakdownAnchorRect = null;
|
cachedBreakdownAnchorRect = null;
|
||||||
@@ -637,22 +642,24 @@ export const ConsumptionView = defineComponent({
|
|||||||
cachedBreakdownAnchorRect = null;
|
cachedBreakdownAnchorRect = null;
|
||||||
}
|
}
|
||||||
activeHoverTargetEl = anchorEl;
|
activeHoverTargetEl = anchorEl;
|
||||||
|
activeHoverPayload = payload;
|
||||||
patchClasses(anchorEl, { 'is-hovered': true });
|
patchClasses(anchorEl, { 'is-hovered': true });
|
||||||
|
|
||||||
popoverContent.update({
|
if (!sameTargetAndPayload) {
|
||||||
title: payload.title || '—',
|
popoverContent.update({
|
||||||
calls: payload.calls || 0,
|
title: payload.title || '—',
|
||||||
totalTokens: payload.totalTokens || 0,
|
calls: payload.calls || 0,
|
||||||
costText: payload.costText || '$0.00',
|
totalTokens: payload.totalTokens || 0,
|
||||||
inputTokens: payload.inputTokens,
|
costText: payload.costText || '$0.00',
|
||||||
cacheReadTokens: payload.cacheReadTokens,
|
inputTokens: payload.inputTokens,
|
||||||
thinkingTokens: payload.thinkingTokens,
|
cacheReadTokens: payload.cacheReadTokens,
|
||||||
responseTokens: payload.responseTokens,
|
thinkingTokens: payload.thinkingTokens,
|
||||||
outputTokens: payload.outputTokens,
|
responseTokens: payload.responseTokens,
|
||||||
segments: Array.isArray(payload.segments) ? payload.segments : [],
|
outputTokens: payload.outputTokens,
|
||||||
});
|
segments: Array.isArray(payload.segments) ? payload.segments : [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const wasHidden = breakdownPopoverEl.hasAttribute('hidden');
|
|
||||||
patchAttr(breakdownPopoverEl, 'hidden', false);
|
patchAttr(breakdownPopoverEl, 'hidden', false);
|
||||||
positionBreakdownPopover(anchorEl, pointerClientX, pointerClientY);
|
positionBreakdownPopover(anchorEl, pointerClientX, pointerClientY);
|
||||||
if (wasHidden) {
|
if (wasHidden) {
|
||||||
@@ -675,6 +682,19 @@ export const ConsumptionView = defineComponent({
|
|||||||
return { el: segEl, refs: { segEl } };
|
return { el: segEl, refs: { segEl } };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let monthlyGridEl = null;
|
||||||
|
const monthlyColByEl = new Map();
|
||||||
|
|
||||||
|
function findMonthlyColForNode(node) {
|
||||||
|
let cur = node;
|
||||||
|
while (cur && cur !== monthlyGridEl) {
|
||||||
|
const hit = monthlyColByEl.get(cur);
|
||||||
|
if (hit) return hit;
|
||||||
|
cur = cur.parentNode || null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const monthlyCols = Array.from({ length: 12 }, (_, idx) => {
|
const monthlyCols = Array.from({ length: 12 }, (_, idx) => {
|
||||||
const costText = h('span', { className: 'month-cost text-mono', text: '' });
|
const costText = h('span', { className: 'month-cost text-mono', text: '' });
|
||||||
const stackWrap = h('div', { className: 'month-stack' });
|
const stackWrap = h('div', { className: 'month-stack' });
|
||||||
@@ -701,6 +721,9 @@ export const ConsumptionView = defineComponent({
|
|||||||
e?.clientY ?? null
|
e?.clientY ?? null
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
if (activeHoverTargetEl && monthlyColByEl.has(activeHoverTargetEl)) {
|
||||||
|
hideBreakdownPopover();
|
||||||
|
}
|
||||||
e?.stopPropagation?.();
|
e?.stopPropagation?.();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -709,8 +732,16 @@ export const ConsumptionView = defineComponent({
|
|||||||
positionBreakdownPopover(colEl, e?.clientX ?? null, e?.clientY ?? null);
|
positionBreakdownPopover(colEl, e?.clientX ?? null, e?.clientY ?? null);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onMouseLeave: () => {
|
onMouseLeave: (e) => {
|
||||||
if (activeHoverTargetEl === colEl) hideBreakdownPopover();
|
if (activeHoverTargetEl !== colEl) return;
|
||||||
|
const nextEl = e?.relatedTarget || null;
|
||||||
|
if (nextEl) {
|
||||||
|
const nextCol = findMonthlyColForNode(nextEl);
|
||||||
|
if ((nextCol && nextCol.colState.hoverPayload) || nextEl === monthlyGridEl) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hideBreakdownPopover();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
@@ -720,7 +751,7 @@ export const ConsumptionView = defineComponent({
|
|||||||
tokText,
|
tokText,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
return {
|
const colRec = {
|
||||||
el: colEl,
|
el: colEl,
|
||||||
costText,
|
costText,
|
||||||
stackWrap,
|
stackWrap,
|
||||||
@@ -729,8 +760,23 @@ export const ConsumptionView = defineComponent({
|
|||||||
tokText,
|
tokText,
|
||||||
colState,
|
colState,
|
||||||
};
|
};
|
||||||
|
monthlyColByEl.set(colEl, colRec);
|
||||||
|
return colRec;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
monthlyGridEl = h(
|
||||||
|
'div',
|
||||||
|
{
|
||||||
|
className: 'monthly-grid',
|
||||||
|
onMouseLeave: () => {
|
||||||
|
if (activeHoverTargetEl && monthlyColByEl.has(activeHoverTargetEl)) {
|
||||||
|
hideBreakdownPopover();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
monthlyCols.map((c) => c.el)
|
||||||
|
);
|
||||||
|
|
||||||
const monthlyPanel = h('section', { className: 'panel' }, [
|
const monthlyPanel = h('section', { className: 'panel' }, [
|
||||||
h('div', { className: 'panel-header' }, [
|
h('div', { className: 'panel-header' }, [
|
||||||
h('span', { className: 'panel-title' }, [
|
h('span', { className: 'panel-title' }, [
|
||||||
@@ -739,11 +785,7 @@ export const ConsumptionView = defineComponent({
|
|||||||
]),
|
]),
|
||||||
monthlyHoverHint,
|
monthlyHoverHint,
|
||||||
]),
|
]),
|
||||||
h(
|
monthlyGridEl,
|
||||||
'div',
|
|
||||||
{ className: 'monthly-grid' },
|
|
||||||
monthlyCols.map((c) => c.el)
|
|
||||||
),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const scrollInner = h(
|
const scrollInner = h(
|
||||||
@@ -1232,6 +1274,54 @@ export const ConsumptionView = defineComponent({
|
|||||||
/**
|
/**
|
||||||
* 创建客户端来源单行 DOM 结构(保留长尾合并分段配色进度条、单行不换行的 Top 2-3 模型速览和右侧总调用数,悬停进度条或速览区弹出完整明细浮层)。
|
* 创建客户端来源单行 DOM 结构(保留长尾合并分段配色进度条、单行不换行的 Top 2-3 模型速览和右侧总调用数,悬停进度条或速览区弹出完整明细浮层)。
|
||||||
*/
|
*/
|
||||||
|
function isNodeInside(root, node) {
|
||||||
|
if (!root || !node) return false;
|
||||||
|
if (typeof root.contains === 'function') return root.contains(node);
|
||||||
|
let cur = node;
|
||||||
|
while (cur) {
|
||||||
|
if (cur === root) return true;
|
||||||
|
cur = cur.parentNode || null;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function attachUnifiedHoverZone(zoneEl, compatTargets, rowState) {
|
||||||
|
zoneEl.addEventListener('mouseenter', (e) => {
|
||||||
|
if (rowState.hoverPayload) {
|
||||||
|
showBreakdownPopover(zoneEl, rowState.hoverPayload, e?.clientX ?? null, e?.clientY ?? null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
zoneEl.addEventListener('mousemove', (e) => {
|
||||||
|
if (rowState.hoverPayload && activeHoverTargetEl === zoneEl) {
|
||||||
|
positionBreakdownPopover(zoneEl, e?.clientX ?? null, e?.clientY ?? null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
zoneEl.addEventListener('mouseleave', () => {
|
||||||
|
if (activeHoverTargetEl === zoneEl) hideBreakdownPopover();
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const childEl of compatTargets) {
|
||||||
|
if (!childEl) continue;
|
||||||
|
childEl.addEventListener('mouseenter', (e) => {
|
||||||
|
if (rowState.hoverPayload) {
|
||||||
|
showBreakdownPopover(zoneEl, rowState.hoverPayload, e?.clientX ?? null, e?.clientY ?? null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
childEl.addEventListener('mousemove', (e) => {
|
||||||
|
if (rowState.hoverPayload && activeHoverTargetEl === zoneEl) {
|
||||||
|
positionBreakdownPopover(zoneEl, e?.clientX ?? null, e?.clientY ?? null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
childEl.addEventListener('mouseleave', (e) => {
|
||||||
|
const nextEl = e?.relatedTarget || null;
|
||||||
|
if (isNodeInside(zoneEl, nextEl)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (activeHoverTargetEl === zoneEl) hideBreakdownPopover();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function createSourceBreakdownRow() {
|
function createSourceBreakdownRow() {
|
||||||
const nameTextEl = h('span', { className: 'cons-row-title-text' });
|
const nameTextEl = h('span', { className: 'cons-row-title-text' });
|
||||||
const nameEl = h('strong', { className: 'cons-row-title' }, [nameTextEl]);
|
const nameEl = h('strong', { className: 'cons-row-title' }, [nameTextEl]);
|
||||||
@@ -1240,26 +1330,7 @@ export const ConsumptionView = defineComponent({
|
|||||||
const costEl = h('strong', { className: 'cons-row-cost text-mono' });
|
const costEl = h('strong', { className: 'cons-row-cost text-mono' });
|
||||||
const trackEl = h('div', { className: 'progress-track cons-seg-bar cons-source-model-bar' });
|
const trackEl = h('div', { className: 'progress-track cons-seg-bar cons-source-model-bar' });
|
||||||
const rowState = { hoverPayload: null };
|
const rowState = { hoverPayload: null };
|
||||||
const bindPopoverHover = (targetEl) => ({
|
|
||||||
onMouseEnter: (e) => {
|
|
||||||
if (rowState.hoverPayload) {
|
|
||||||
showBreakdownPopover(
|
|
||||||
targetEl,
|
|
||||||
rowState.hoverPayload,
|
|
||||||
e?.clientX ?? null,
|
|
||||||
e?.clientY ?? null
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onMouseMove: (e) => {
|
|
||||||
if (rowState.hoverPayload && activeHoverTargetEl === targetEl) {
|
|
||||||
positionBreakdownPopover(targetEl, e?.clientX ?? null, e?.clientY ?? null);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onMouseLeave: () => {
|
|
||||||
if (activeHoverTargetEl === targetEl) hideBreakdownPopover();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const barHitEl = h(
|
const barHitEl = h(
|
||||||
'div',
|
'div',
|
||||||
{
|
{
|
||||||
@@ -1267,20 +1338,23 @@ export const ConsumptionView = defineComponent({
|
|||||||
},
|
},
|
||||||
[trackEl]
|
[trackEl]
|
||||||
);
|
);
|
||||||
const barHandlers = bindPopoverHover(barHitEl);
|
|
||||||
barHitEl.addEventListener('mouseenter', barHandlers.onMouseEnter);
|
|
||||||
barHitEl.addEventListener('mousemove', barHandlers.onMouseMove);
|
|
||||||
barHitEl.addEventListener('mouseleave', barHandlers.onMouseLeave);
|
|
||||||
|
|
||||||
const topModelsEl = h('div', { className: 'cons-source-top-models', hidden: true });
|
const topModelsEl = h('div', { className: 'cons-source-top-models', hidden: true });
|
||||||
const topHandlers = bindPopoverHover(topModelsEl);
|
|
||||||
topModelsEl.addEventListener('mouseenter', topHandlers.onMouseEnter);
|
|
||||||
topModelsEl.addEventListener('mousemove', topHandlers.onMouseMove);
|
|
||||||
topModelsEl.addEventListener('mouseleave', topHandlers.onMouseLeave);
|
|
||||||
|
|
||||||
const callsLbl = h('span', { text: t('cons.footCalls') });
|
const callsLbl = h('span', { text: t('cons.footCalls') });
|
||||||
const callsVal = h('strong', { className: 'text-mono' });
|
const callsVal = h('strong', { className: 'text-mono' });
|
||||||
|
|
||||||
|
const hoverZoneEl = h('div', { className: 'cons-source-hover-zone' }, [
|
||||||
|
barHitEl,
|
||||||
|
h('div', { className: 'cons-item-foot cons-source-foot' }, [
|
||||||
|
topModelsEl,
|
||||||
|
h('span', { className: 'legend-left cons-calls-stat' }, [
|
||||||
|
callsLbl,
|
||||||
|
callsVal,
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
attachUnifiedHoverZone(hoverZoneEl, [barHitEl, topModelsEl], rowState);
|
||||||
|
|
||||||
const rowEl = h('div', { className: 'cons-item-row cons-source-row' }, [
|
const rowEl = h('div', { className: 'cons-item-row cons-source-row' }, [
|
||||||
h('div', { className: 'panel-header' }, [
|
h('div', { className: 'panel-header' }, [
|
||||||
nameEl,
|
nameEl,
|
||||||
@@ -1290,14 +1364,7 @@ export const ConsumptionView = defineComponent({
|
|||||||
costEl,
|
costEl,
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
barHitEl,
|
hoverZoneEl,
|
||||||
h('div', { className: 'cons-item-foot cons-source-foot' }, [
|
|
||||||
topModelsEl,
|
|
||||||
h('span', { className: 'legend-left cons-calls-stat' }, [
|
|
||||||
callsLbl,
|
|
||||||
callsVal,
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -1308,6 +1375,7 @@ export const ConsumptionView = defineComponent({
|
|||||||
pctBadge,
|
pctBadge,
|
||||||
totalTokEl,
|
totalTokEl,
|
||||||
costEl,
|
costEl,
|
||||||
|
hoverZoneEl,
|
||||||
barHitEl,
|
barHitEl,
|
||||||
trackEl,
|
trackEl,
|
||||||
topModelsEl,
|
topModelsEl,
|
||||||
@@ -1411,6 +1479,7 @@ export const ConsumptionView = defineComponent({
|
|||||||
segments: partitioned,
|
segments: partitioned,
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
|
patchClasses(refs.hoverZoneEl, { 'is-interactive': Boolean(refs.rowState.hoverPayload) });
|
||||||
}
|
}
|
||||||
|
|
||||||
function createTopConversationRow() {
|
function createTopConversationRow() {
|
||||||
@@ -1426,43 +1495,26 @@ export const ConsumptionView = defineComponent({
|
|||||||
const trackEl = h('div', { className: 'progress-track cons-seg-bar cons-source-model-bar' });
|
const trackEl = h('div', { className: 'progress-track cons-seg-bar cons-source-model-bar' });
|
||||||
const rowState = { cascadeId: '', canJump: false, hoverPayload: null };
|
const rowState = { cascadeId: '', canJump: false, hoverPayload: null };
|
||||||
|
|
||||||
const bindPopoverHover = (targetEl) => ({
|
|
||||||
onMouseEnter: (e) => {
|
|
||||||
if (rowState.hoverPayload) {
|
|
||||||
showBreakdownPopover(
|
|
||||||
targetEl,
|
|
||||||
rowState.hoverPayload,
|
|
||||||
e?.clientX ?? null,
|
|
||||||
e?.clientY ?? null
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onMouseMove: (e) => {
|
|
||||||
if (rowState.hoverPayload && activeHoverTargetEl === targetEl) {
|
|
||||||
positionBreakdownPopover(targetEl, e?.clientX ?? null, e?.clientY ?? null);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onMouseLeave: () => {
|
|
||||||
if (activeHoverTargetEl === targetEl) hideBreakdownPopover();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const barHitEl = h('div', { className: 'cons-source-bar-hit' }, [trackEl]);
|
const barHitEl = h('div', { className: 'cons-source-bar-hit' }, [trackEl]);
|
||||||
const barHandlers = bindPopoverHover(barHitEl);
|
|
||||||
barHitEl.addEventListener('mouseenter', barHandlers.onMouseEnter);
|
|
||||||
barHitEl.addEventListener('mousemove', barHandlers.onMouseMove);
|
|
||||||
barHitEl.addEventListener('mouseleave', barHandlers.onMouseLeave);
|
|
||||||
|
|
||||||
const topModelsEl = h('div', { className: 'cons-source-top-models', hidden: true });
|
const topModelsEl = h('div', { className: 'cons-source-top-models', hidden: true });
|
||||||
const topHandlers = bindPopoverHover(topModelsEl);
|
|
||||||
topModelsEl.addEventListener('mouseenter', topHandlers.onMouseEnter);
|
|
||||||
topModelsEl.addEventListener('mousemove', topHandlers.onMouseMove);
|
|
||||||
topModelsEl.addEventListener('mouseleave', topHandlers.onMouseLeave);
|
|
||||||
|
|
||||||
const fallbackMetaEl = h('span', { className: 'cons-top-conv-meta', hidden: true });
|
const fallbackMetaEl = h('span', { className: 'cons-top-conv-meta', hidden: true });
|
||||||
const callsLbl = h('span', { text: t('cons.footCalls') });
|
const callsLbl = h('span', { text: t('cons.footCalls') });
|
||||||
const callsVal = h('strong', { className: 'text-mono' });
|
const callsVal = h('strong', { className: 'text-mono' });
|
||||||
|
|
||||||
|
const hoverZoneEl = h('div', { className: 'cons-source-hover-zone' }, [
|
||||||
|
barHitEl,
|
||||||
|
h('div', { className: 'cons-item-foot cons-source-foot' }, [
|
||||||
|
topModelsEl,
|
||||||
|
fallbackMetaEl,
|
||||||
|
h('span', { className: 'legend-left cons-calls-stat' }, [
|
||||||
|
callsLbl,
|
||||||
|
callsVal,
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
attachUnifiedHoverZone(hoverZoneEl, [barHitEl, topModelsEl], rowState);
|
||||||
|
|
||||||
const rowEl = h(
|
const rowEl = h(
|
||||||
'div',
|
'div',
|
||||||
{
|
{
|
||||||
@@ -1490,15 +1542,7 @@ export const ConsumptionView = defineComponent({
|
|||||||
costEl,
|
costEl,
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
barHitEl,
|
hoverZoneEl,
|
||||||
h('div', { className: 'cons-item-foot cons-source-foot' }, [
|
|
||||||
topModelsEl,
|
|
||||||
fallbackMetaEl,
|
|
||||||
h('span', { className: 'legend-left cons-calls-stat' }, [
|
|
||||||
callsLbl,
|
|
||||||
callsVal,
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1512,6 +1556,7 @@ export const ConsumptionView = defineComponent({
|
|||||||
pctBadge,
|
pctBadge,
|
||||||
totalTokEl,
|
totalTokEl,
|
||||||
costEl,
|
costEl,
|
||||||
|
hoverZoneEl,
|
||||||
barHitEl,
|
barHitEl,
|
||||||
trackEl,
|
trackEl,
|
||||||
topModelsEl,
|
topModelsEl,
|
||||||
@@ -1669,6 +1714,7 @@ export const ConsumptionView = defineComponent({
|
|||||||
segments: partitioned,
|
segments: partitioned,
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
|
patchClasses(refs.hoverZoneEl, { 'is-interactive': Boolean(refs.rowState.hoverPayload) });
|
||||||
}
|
}
|
||||||
|
|
||||||
let latestSlice = null;
|
let latestSlice = null;
|
||||||
|
|||||||
@@ -3696,12 +3696,27 @@ html[data-standalone="true"] .app-shell {
|
|||||||
container-type: inline-size;
|
container-type: inline-size;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cons-source-bar-hit {
|
.cons-source-hover-zone {
|
||||||
padding: 5px 0;
|
display: flex;
|
||||||
margin: -5px 0;
|
flex-direction: column;
|
||||||
|
gap: 5px;
|
||||||
|
padding: 4px 0 2px;
|
||||||
|
margin: -4px 0 -2px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cons-source-hover-zone.is-interactive {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cons-source-bar-hit {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
cursor: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cons-source-hover-zone.is-interactive:hover .cons-source-model-bar,
|
||||||
|
.cons-source-hover-zone.is-hovered .cons-source-model-bar,
|
||||||
.cons-source-bar-hit:hover .cons-source-model-bar,
|
.cons-source-bar-hit:hover .cons-source-model-bar,
|
||||||
.cons-source-bar-hit.is-hovered .cons-source-model-bar {
|
.cons-source-bar-hit.is-hovered .cons-source-model-bar {
|
||||||
box-shadow: 0 0 0 1px var(--border-strong);
|
box-shadow: 0 0 0 1px var(--border-strong);
|
||||||
@@ -3764,6 +3779,8 @@ html[data-standalone="true"] .app-shell {
|
|||||||
transition: color 120ms ease;
|
transition: color 120ms ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cons-source-hover-zone.is-interactive:hover .cons-source-top-name,
|
||||||
|
.cons-source-hover-zone.is-hovered .cons-source-top-name,
|
||||||
.cons-source-top-models:hover .cons-source-top-name,
|
.cons-source-top-models:hover .cons-source-top-name,
|
||||||
.cons-source-top-models.is-hovered .cons-source-top-name {
|
.cons-source-top-models.is-hovered .cons-source-top-name {
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
@@ -4041,17 +4058,20 @@ html[data-standalone="true"] .app-shell {
|
|||||||
/* --- 6. 12 个月垂直堆叠柱状图 (12-Month Stacked Bar Chart) --- */
|
/* --- 6. 12 个月垂直堆叠柱状图 (12-Month Stacked Bar Chart) --- */
|
||||||
.monthly-grid {
|
.monthly-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(12, 1fr);
|
grid-template-columns: repeat(12, minmax(0, 1fr));
|
||||||
gap: 3px;
|
gap: 0;
|
||||||
align-items: end;
|
align-items: stretch;
|
||||||
padding-top: var(--space-2);
|
margin: var(--space-2) -1.5px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.month-col {
|
.month-col {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
gap: 3px;
|
gap: 3px;
|
||||||
|
padding: 0 1.5px;
|
||||||
|
box-sizing: border-box;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8303,6 +8323,8 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
|
|||||||
border-top-color: color-mix(in srgb, var(--text-primary) 8%, transparent);
|
border-top-color: color-mix(in srgb, var(--text-primary) 8%, transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[data-modern-ui="true"] .cons-source-hover-zone.is-interactive:hover .cons-source-model-bar,
|
||||||
|
[data-modern-ui="true"] .cons-source-hover-zone.is-hovered .cons-source-model-bar,
|
||||||
[data-modern-ui="true"] .cons-source-bar-hit:hover .cons-source-model-bar,
|
[data-modern-ui="true"] .cons-source-bar-hit:hover .cons-source-model-bar,
|
||||||
[data-modern-ui="true"] .cons-source-bar-hit.is-hovered .cons-source-model-bar,
|
[data-modern-ui="true"] .cons-source-bar-hit.is-hovered .cons-source-model-bar,
|
||||||
[data-modern-ui="true"] .month-col.is-interactive:hover .month-stack,
|
[data-modern-ui="true"] .month-col.is-interactive:hover .month-stack,
|
||||||
|
|||||||
@@ -486,25 +486,39 @@ test('ConsumptionView: Top Models color dot + % bar, clutter-free Client Sources
|
|||||||
['输入', '缓存', '思考', '输出']
|
['输入', '缓存', '思考', '输出']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const appHoverZone = sourceRows[0].querySelector('.cons-source-hover-zone');
|
||||||
|
const appTopModelsEl = sourceRows[0].querySelector('.cons-source-top-models');
|
||||||
|
assert.ok(appHoverZone, 'Client source row should wrap bar and top models in a unified hover zone');
|
||||||
|
|
||||||
|
// Moving seamlessly from progress bar into gap / top-models keeps popover visible without flicker
|
||||||
|
appBarHit.dispatchEvent({ type: 'mouseleave', relatedTarget: appHoverZone });
|
||||||
|
assert.equal(popover.hasAttribute('hidden'), false, 'Moving into unified hover zone gap must not hide popover');
|
||||||
|
appBarHit.dispatchEvent({ type: 'mouseleave', relatedTarget: appTopModelsEl });
|
||||||
|
assert.equal(popover.hasAttribute('hidden'), false, 'Moving from bar to model names must not hide popover');
|
||||||
|
|
||||||
appBarHit.dispatchEvent({ type: 'mouseleave' });
|
appBarHit.dispatchEvent({ type: 'mouseleave' });
|
||||||
assert.equal(popover.hasAttribute('hidden'), true);
|
assert.equal(popover.hasAttribute('hidden'), true);
|
||||||
|
|
||||||
const appTopModelsEl = sourceRows[0].querySelector('.cons-source-top-models');
|
|
||||||
appTopModelsEl.dispatchEvent({ type: 'mouseenter', clientX: 90 });
|
appTopModelsEl.dispatchEvent({ type: 'mouseenter', clientX: 90 });
|
||||||
assert.equal(popover.hasAttribute('hidden'), false);
|
assert.equal(popover.hasAttribute('hidden'), false);
|
||||||
assert.equal(popover.querySelector('.trend-tip-time')?.textContent, 'Antigravity App');
|
assert.equal(popover.querySelector('.trend-tip-time')?.textContent, 'Antigravity App');
|
||||||
appTopModelsEl.dispatchEvent({ type: 'mouseleave' });
|
appTopModelsEl.dispatchEvent({ type: 'mouseleave', relatedTarget: appBarHit });
|
||||||
|
assert.equal(popover.hasAttribute('hidden'), false, 'Moving back from model names to bar must not hide popover');
|
||||||
|
appHoverZone.dispatchEvent({ type: 'mouseleave' });
|
||||||
assert.equal(popover.hasAttribute('hidden'), true);
|
assert.equal(popover.hasAttribute('hidden'), true);
|
||||||
|
|
||||||
// Verify single-line non-wrapping CSS rules exist for client source top models
|
// Verify single-line non-wrapping CSS rules and zero-gap hover layout rules
|
||||||
const { readFileSync } = await import('node:fs');
|
const { readFileSync } = await import('node:fs');
|
||||||
const consCss = readFileSync(new URL('../src/styles/views-consumption.css', import.meta.url), 'utf8');
|
const consCss = readFileSync(new URL('../src/styles/views-consumption.css', import.meta.url), 'utf8');
|
||||||
|
assert.match(consCss, /\.cons-source-hover-zone\s*\{[\s\S]*flex-direction:\s*column/);
|
||||||
assert.match(consCss, /\.cons-source-foot\s*\{[\s\S]*flex-wrap:\s*nowrap/);
|
assert.match(consCss, /\.cons-source-foot\s*\{[\s\S]*flex-wrap:\s*nowrap/);
|
||||||
assert.match(consCss, /\.cons-source-top-models\s*\{[\s\S]*flex-wrap:\s*nowrap/);
|
assert.match(consCss, /\.cons-source-top-models\s*\{[\s\S]*flex-wrap:\s*nowrap/);
|
||||||
assert.match(consCss, /@container\s*\(max-width:\s*340px\)\s*\{\s*\.cons-source-top-item:nth-child\(n\s*\+\s*3\)/);
|
assert.match(consCss, /@container\s*\(max-width:\s*340px\)\s*\{\s*\.cons-source-top-item:nth-child\(n\s*\+\s*3\)/);
|
||||||
|
assert.match(consCss, /\.monthly-grid\s*\{[\s\S]*gap:\s*0/);
|
||||||
|
|
||||||
// 3. Monthly Breakdown: old 4-channel legend removed; Nov column renders model-colored vertical segments & unified hover popover
|
// 3. Monthly Breakdown: old 4-channel legend removed; Nov column renders model-colored vertical segments & unified hover popover
|
||||||
assert.equal(view.el.querySelectorAll('.monthly-legend').length, 0);
|
assert.equal(view.el.querySelectorAll('.monthly-legend').length, 0);
|
||||||
|
const monthlyGrid = view.el.querySelector('.monthly-grid');
|
||||||
const monthCols = view.el.querySelectorAll('.month-col');
|
const monthCols = view.el.querySelectorAll('.month-col');
|
||||||
const novCol = monthCols[10];
|
const novCol = monthCols[10];
|
||||||
const novSegs = novCol.querySelectorAll('.month-seg.cons-model-seg');
|
const novSegs = novCol.querySelectorAll('.month-seg.cons-model-seg');
|
||||||
@@ -520,6 +534,16 @@ test('ConsumptionView: Top Models color dot + % bar, clutter-free Client Sources
|
|||||||
assert.equal(popover.querySelectorAll('.cons-pop-model-row').length, 4);
|
assert.equal(popover.querySelectorAll('.cons-pop-model-row').length, 4);
|
||||||
assert.equal(popover.querySelector('.cons-pop-channels')?.hasAttribute('hidden'), false);
|
assert.equal(popover.querySelector('.cons-pop-channels')?.hasAttribute('hidden'), false);
|
||||||
|
|
||||||
|
// Seam/sibling handoff inside monthly-grid keeps popover open; empty month or exiting grid hides it
|
||||||
|
novCol.dispatchEvent({ type: 'mouseleave', relatedTarget: monthlyGrid });
|
||||||
|
assert.equal(popover.hasAttribute('hidden'), false, 'Sub-pixel seam inside monthly-grid must not flicker popover');
|
||||||
|
monthCols[0].dispatchEvent({ type: 'mouseenter' });
|
||||||
|
assert.equal(popover.hasAttribute('hidden'), true, 'Hovering zero-data month must hide popover');
|
||||||
|
novCol.dispatchEvent({ type: 'mouseenter' });
|
||||||
|
assert.equal(popover.hasAttribute('hidden'), false);
|
||||||
|
monthlyGrid.dispatchEvent({ type: 'mouseleave' });
|
||||||
|
assert.equal(popover.hasAttribute('hidden'), true, 'Leaving monthly-grid must hide popover');
|
||||||
|
|
||||||
// 4. Usage Trend: taller 184px viewBox & hovering x-axis tick opens redesigned tooltip (hero TOKEN, 4-seg model bars, no subtitle/dot clutter, bottom 4 channels)
|
// 4. Usage Trend: taller 184px viewBox & hovering x-axis tick opens redesigned tooltip (hero TOKEN, 4-seg model bars, no subtitle/dot clutter, bottom 4 channels)
|
||||||
const trendSvg = view.el.querySelector('.trend-svg');
|
const trendSvg = view.el.querySelector('.trend-svg');
|
||||||
assert.match(trendSvg?.getAttribute('viewBox') || '', /\s184$/);
|
assert.match(trendSvg?.getAttribute('viewBox') || '', /\s184$/);
|
||||||
|
|||||||
Reference in New Issue
Block a user