mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
fix(panel): remove range-switch font flicker and simplify rate popover
- Drop transparent-container opacity animations on ConsumptionView and TrendAreaChart range switches that forced DirectWrite grayscale AA transitions, and pool trend X-axis ticks, grid lines, and heatmap cells in-place - Remove the redundant weekly quota summary row, internal hairlines, and bottom note from the QuotaPoolsWidget empirical burn-rate popover
This commit is contained in:
+125
-268
@@ -1463,9 +1463,6 @@ const I18N_MESSAGES_ZH_CN = Object.freeze({
|
|||||||
'quota.ratePopTitle': '实测倍率预估',
|
'quota.ratePopTitle': '实测倍率预估',
|
||||||
'quota.ratePopAccountScope': '{account}',
|
'quota.ratePopAccountScope': '{account}',
|
||||||
'quota.ratePopAccountCurrent': '当前账号',
|
'quota.ratePopAccountCurrent': '当前账号',
|
||||||
'quota.ratePopWkCapTitle': '预测周额度',
|
|
||||||
'quota.ratePopWkCapPrelim': '· 初估',
|
|
||||||
'quota.ratePopWkCapPartial': '· {ready}/{total} 池',
|
|
||||||
'quota.ratePopPoolFallback': '池综合均值',
|
'quota.ratePopPoolFallback': '池综合均值',
|
||||||
'quota.ratePopEq5hLabel': '5h 满池',
|
'quota.ratePopEq5hLabel': '5h 满池',
|
||||||
'quota.ratePopEqWkLabel': '周限满池',
|
'quota.ratePopEqWkLabel': '周限满池',
|
||||||
@@ -1474,7 +1471,6 @@ const I18N_MESSAGES_ZH_CN = Object.freeze({
|
|||||||
'quota.ratePopPrelimSlope': '斜率初估',
|
'quota.ratePopPrelimSlope': '斜率初估',
|
||||||
'quota.ratePopPrelimCycle': '周期初估',
|
'quota.ratePopPrelimCycle': '周期初估',
|
||||||
'quota.ratePopEmpty': '暂未采集到足够的单模型干净样本(周限满 2% 或单模型满 3 次无抖动扣费后自动生成)。',
|
'quota.ratePopEmpty': '暂未采集到足够的单模型干净样本(周限满 2% 或单模型满 3 次无抖动扣费后自动生成)。',
|
||||||
'quota.ratePopNote': '按净消耗及精确计价折算,同池最省为 1x,按账号隔离。',
|
|
||||||
'quota.ratePopSharedBadge': '共享活跃',
|
'quota.ratePopSharedBadge': '共享活跃',
|
||||||
'quota.ratePopSharedBadgeTip': '最近 15 分钟内检测到同池外部消耗,新增预占将在二次验证后展示',
|
'quota.ratePopSharedBadgeTip': '最近 15 分钟内检测到同池外部消耗,新增预占将在二次验证后展示',
|
||||||
'quota.ratePopExternalDetail': '检测到家庭组 / 其他设备消耗(已排除约 {detail}),不计入预占',
|
'quota.ratePopExternalDetail': '检测到家庭组 / 其他设备消耗(已排除约 {detail}),不计入预占',
|
||||||
@@ -2366,9 +2362,6 @@ const I18N_MESSAGES_EN_US = Object.freeze({
|
|||||||
'quota.ratePopTitle': 'Estimated Burn Rates',
|
'quota.ratePopTitle': 'Estimated Burn Rates',
|
||||||
'quota.ratePopAccountScope': '{account}',
|
'quota.ratePopAccountScope': '{account}',
|
||||||
'quota.ratePopAccountCurrent': 'Current account',
|
'quota.ratePopAccountCurrent': 'Current account',
|
||||||
'quota.ratePopWkCapTitle': 'Est. Weekly Quota',
|
|
||||||
'quota.ratePopWkCapPrelim': '· est.',
|
|
||||||
'quota.ratePopWkCapPartial': '· {ready}/{total} pools',
|
|
||||||
'quota.ratePopPoolFallback': 'Pool average',
|
'quota.ratePopPoolFallback': 'Pool average',
|
||||||
'quota.ratePopEq5hLabel': '5h full',
|
'quota.ratePopEq5hLabel': '5h full',
|
||||||
'quota.ratePopEqWkLabel': 'Weekly full',
|
'quota.ratePopEqWkLabel': 'Weekly full',
|
||||||
@@ -2377,7 +2370,6 @@ const I18N_MESSAGES_EN_US = Object.freeze({
|
|||||||
'quota.ratePopPrelimSlope': 'slope est.',
|
'quota.ratePopPrelimSlope': 'slope est.',
|
||||||
'quota.ratePopPrelimCycle': 'cycle est.',
|
'quota.ratePopPrelimCycle': 'cycle est.',
|
||||||
'quota.ratePopEmpty': 'Not enough clean samples yet (unlocks at 2% weekly burn or 3 clean single-model steps).',
|
'quota.ratePopEmpty': 'Not enough clean samples yet (unlocks at 2% weekly burn or 3 clean single-model steps).',
|
||||||
'quota.ratePopNote': 'Measured from net burn & priced steps; lowest in pool = 1x. Account isolated.',
|
|
||||||
'quota.ratePopSharedBadge': 'Shared active',
|
'quota.ratePopSharedBadge': 'Shared active',
|
||||||
'quota.ratePopSharedBadgeTip': 'External pool usage seen within 15 min; new reservations display after verification',
|
'quota.ratePopSharedBadgeTip': 'External pool usage seen within 15 min; new reservations display after verification',
|
||||||
'quota.ratePopExternalDetail': 'Family group / other-device usage detected (~{detail} excluded from reservations)',
|
'quota.ratePopExternalDetail': 'Family group / other-device usage detected (~{detail} excluded from reservations)',
|
||||||
@@ -14244,8 +14236,6 @@ function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
|||||||
let hoveredCellEl = null;
|
let hoveredCellEl = null;
|
||||||
let lastPointer = null;
|
let lastPointer = null;
|
||||||
let lastRenderSig = '';
|
let lastRenderSig = '';
|
||||||
let lastTickLabelsSig = '';
|
|
||||||
let hasRenderedOnce = false;
|
|
||||||
let hasRenderedLineOnce = false;
|
let hasRenderedLineOnce = false;
|
||||||
let peakReadyArmed = false;
|
let peakReadyArmed = false;
|
||||||
let peakReadyRaf = 0;
|
let peakReadyRaf = 0;
|
||||||
@@ -14253,40 +14243,13 @@ function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
|||||||
let morphRafId = 0;
|
let morphRafId = 0;
|
||||||
let committedSegs = [];
|
let committedSegs = [];
|
||||||
let liveMorphSegs = null;
|
let liveMorphSegs = null;
|
||||||
const transientClassTimers = new Map();
|
const vGridLinePool = [];
|
||||||
|
const xAxisTickPool = [];
|
||||||
|
const hmMonthPool = [];
|
||||||
|
const hmCellPool = [];
|
||||||
|
|
||||||
const CURVE_MORPH_DURATION_MS = 240;
|
const CURVE_MORPH_DURATION_MS = 240;
|
||||||
|
|
||||||
function cleanupTransientClass(el) {
|
|
||||||
const rec = transientClassTimers.get(el);
|
|
||||||
if (!rec) return;
|
|
||||||
clearTimeout(rec.tid);
|
|
||||||
el?.removeEventListener?.('animationend', rec.onEnd);
|
|
||||||
el?.classList?.remove(rec.cls);
|
|
||||||
transientClassTimers.delete(el);
|
|
||||||
}
|
|
||||||
|
|
||||||
function triggerTransientClass(el, cls, fallbackMs = 650) {
|
|
||||||
if (!el || !el.classList) return;
|
|
||||||
cleanupTransientClass(el);
|
|
||||||
el.classList.remove(cls);
|
|
||||||
void el.offsetWidth;
|
|
||||||
const onEnd = (ev) => {
|
|
||||||
if (ev && ev.target && ev.target !== el) return;
|
|
||||||
cleanupTransientClass(el);
|
|
||||||
};
|
|
||||||
const tid = setTimeout(() => cleanupTransientClass(el), fallbackMs);
|
|
||||||
transientClassTimers.set(el, { cls, tid, onEnd });
|
|
||||||
el.addEventListener?.('animationend', onEnd);
|
|
||||||
el.classList.add(cls);
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearAllTransientTimers() {
|
|
||||||
for (const el of Array.from(transientClassTimers.keys())) {
|
|
||||||
cleanupTransientClass(el);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function cancelCurveMorph() {
|
function cancelCurveMorph() {
|
||||||
if (
|
if (
|
||||||
morphRafId &&
|
morphRafId &&
|
||||||
@@ -14912,7 +14875,6 @@ function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
|||||||
cancelTipTrackRaf();
|
cancelTipTrackRaf();
|
||||||
cancelCurveMorph();
|
cancelCurveMorph();
|
||||||
cancelPeakReadyRaf();
|
cancelPeakReadyRaf();
|
||||||
clearAllTransientTimers();
|
|
||||||
plotStage.removeEventListener('mousemove', handlePointerMove);
|
plotStage.removeEventListener('mousemove', handlePointerMove);
|
||||||
plotStage.removeEventListener('click', handleLineClick);
|
plotStage.removeEventListener('click', handleLineClick);
|
||||||
plotStage.removeEventListener('mouseleave', clearHover);
|
plotStage.removeEventListener('mouseleave', clearHover);
|
||||||
@@ -14961,14 +14923,6 @@ function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
|||||||
patchAttr(plotStage, 'hidden', useHeatmap);
|
patchAttr(plotStage, 'hidden', useHeatmap);
|
||||||
patchAttr(xAxisEl, 'hidden', useHeatmap);
|
patchAttr(xAxisEl, 'hidden', useHeatmap);
|
||||||
patchAttr(heatmapStage, 'hidden', !useHeatmap);
|
patchAttr(heatmapStage, 'hidden', !useHeatmap);
|
||||||
if (hasRenderedOnce && modeChanged && canAnimateInBrowser()) {
|
|
||||||
if (useHeatmap) {
|
|
||||||
triggerTransientClass(heatmapStage, 'is-stage-entering');
|
|
||||||
} else {
|
|
||||||
triggerTransientClass(plotStage, 'is-stage-entering');
|
|
||||||
triggerTransientClass(xAxisEl, 'is-switching');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!useHeatmap) {
|
if (!useHeatmap) {
|
||||||
syncViewWidth();
|
syncViewWidth();
|
||||||
@@ -15042,51 +14996,97 @@ function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
|||||||
patchStyleVar(hmBodyEl, '--hm-weeks', String(totalWeeks));
|
patchStyleVar(hmBodyEl, '--hm-weeks', String(totalWeeks));
|
||||||
patchStyleVar(hmBodyEl, '--hm-gap', `${gapPx}px`);
|
patchStyleVar(hmBodyEl, '--hm-gap', `${gapPx}px`);
|
||||||
|
|
||||||
// 重建顶部对齐月份标签
|
// 就地增量补丁顶部对齐月份标签,避免文字节点销毁重建
|
||||||
while (hmMonthsEl.firstChild) hmMonthsEl.removeChild(hmMonthsEl.firstChild);
|
|
||||||
const monthTicks = buildHeatmapMonthTicks(slots, firstDow, totalWeeks);
|
const monthTicks = buildHeatmapMonthTicks(slots, firstDow, totalWeeks);
|
||||||
for (const mt of monthTicks) {
|
for (let i = 0; i < monthTicks.length; i++) {
|
||||||
const mEl = h('span', { className: 'trend-hm-month text-mono', text: mt.text });
|
const mt = monthTicks[i];
|
||||||
|
let mEl = hmMonthPool[i];
|
||||||
|
if (!mEl) {
|
||||||
|
mEl = h('span', { className: 'trend-hm-month text-mono' });
|
||||||
|
hmMonthPool.push(mEl);
|
||||||
|
}
|
||||||
|
patchText(mEl, mt.text);
|
||||||
patchStyleVar(mEl, '--hm-col', String(mt.col));
|
patchStyleVar(mEl, '--hm-col', String(mt.col));
|
||||||
hmMonthsEl.appendChild(mEl);
|
if (hmMonthsEl.children[i] !== mEl) {
|
||||||
|
hmMonthsEl.insertBefore(mEl, hmMonthsEl.children[i] || null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (hmMonthsEl.children.length > monthTicks.length) {
|
||||||
|
hmMonthsEl.removeChild(hmMonthsEl.lastChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重建 7 行 × N 周列的每日小格子(一格一天),使用 DocumentFragment 一次性批量挂载减少重排
|
// 就地增量复用 7 行 × N 周列的每日小格子,首次批量新增节点使用 DocumentFragment 挂载
|
||||||
while (hmGridEl.firstChild) hmGridEl.removeChild(hmGridEl.firstChild);
|
|
||||||
hoveredCellEl = null;
|
|
||||||
currentCellEls = new Array(slots.length);
|
currentCellEls = new Array(slots.length);
|
||||||
const gridFrag =
|
const prevMountedCount = hmGridEl.children.length;
|
||||||
typeof document !== 'undefined' && typeof document.createDocumentFragment === 'function'
|
const newCellsFrag =
|
||||||
|
totalCells > prevMountedCount &&
|
||||||
|
typeof document !== 'undefined' &&
|
||||||
|
typeof document.createDocumentFragment === 'function'
|
||||||
? document.createDocumentFragment()
|
? document.createDocumentFragment()
|
||||||
: null;
|
: null;
|
||||||
const gridTarget = gridFrag || hmGridEl;
|
|
||||||
|
|
||||||
for (let pad = 0; pad < firstDow; pad++) {
|
for (let nodeIdx = 0; nodeIdx < totalCells; nodeIdx++) {
|
||||||
gridTarget.appendChild(
|
let cellEl = hmCellPool[nodeIdx];
|
||||||
h('span', { className: 'trend-hm-cell is-pad', 'aria-hidden': 'true' })
|
if (!cellEl) {
|
||||||
);
|
cellEl = h('span', { className: 'trend-hm-cell' });
|
||||||
|
hmCellPool.push(cellEl);
|
||||||
}
|
}
|
||||||
|
if (nodeIdx < firstDow) {
|
||||||
for (let i = 0; i < slots.length; i++) {
|
patchClasses(cellEl, {
|
||||||
|
'is-pad': true,
|
||||||
|
'is-hovered': false,
|
||||||
|
'lv-0': false,
|
||||||
|
'lv-1': false,
|
||||||
|
'lv-2': false,
|
||||||
|
'lv-3': false,
|
||||||
|
'lv-4': false,
|
||||||
|
});
|
||||||
|
patchAttr(cellEl, 'aria-hidden', 'true');
|
||||||
|
patchAttr(cellEl, 'role', null);
|
||||||
|
patchAttr(cellEl, 'data-slot-idx', null);
|
||||||
|
patchAttr(cellEl, 'data-hm-col', null);
|
||||||
|
patchAttr(cellEl, 'data-hm-row', null);
|
||||||
|
} else {
|
||||||
|
const i = nodeIdx - firstDow;
|
||||||
const slot = slots[i];
|
const slot = slots[i];
|
||||||
const tok = safeSlotTokens(slot?.tokens);
|
const tok = safeSlotTokens(slot?.tokens);
|
||||||
const lv = resolveHeatmapLevel(tok, thresholds);
|
const lv = resolveHeatmapLevel(tok, thresholds);
|
||||||
const gridPos = firstDow + i;
|
const col = Math.floor(nodeIdx / 7);
|
||||||
const col = Math.floor(gridPos / 7);
|
const row = nodeIdx % 7;
|
||||||
const row = gridPos % 7;
|
patchClasses(cellEl, {
|
||||||
const cellEl = h('span', {
|
'is-pad': false,
|
||||||
className: `trend-hm-cell lv-${lv}`,
|
'is-hovered': hoveredIdx === i,
|
||||||
'data-slot-idx': String(i),
|
'lv-0': lv === 0,
|
||||||
'data-hm-col': String(col),
|
'lv-1': lv === 1,
|
||||||
'data-hm-row': String(row),
|
'lv-2': lv === 2,
|
||||||
role: 'gridcell',
|
'lv-3': lv === 3,
|
||||||
|
'lv-4': lv === 4,
|
||||||
});
|
});
|
||||||
gridTarget.appendChild(cellEl);
|
patchAttr(cellEl, 'aria-hidden', null);
|
||||||
|
patchAttr(cellEl, 'role', 'gridcell');
|
||||||
|
patchAttr(cellEl, 'data-slot-idx', String(i));
|
||||||
|
patchAttr(cellEl, 'data-hm-col', String(col));
|
||||||
|
patchAttr(cellEl, 'data-hm-row', String(row));
|
||||||
currentCellEls[i] = cellEl;
|
currentCellEls[i] = cellEl;
|
||||||
}
|
}
|
||||||
if (gridFrag) {
|
if (nodeIdx < prevMountedCount) {
|
||||||
hmGridEl.appendChild(gridFrag);
|
if (hmGridEl.children[nodeIdx] !== cellEl) {
|
||||||
|
hmGridEl.insertBefore(cellEl, hmGridEl.children[nodeIdx] || null);
|
||||||
}
|
}
|
||||||
|
} else if (newCellsFrag) {
|
||||||
|
newCellsFrag.appendChild(cellEl);
|
||||||
|
} else {
|
||||||
|
hmGridEl.appendChild(cellEl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newCellsFrag) {
|
||||||
|
hmGridEl.appendChild(newCellsFrag);
|
||||||
|
}
|
||||||
|
while (hmGridEl.children.length > totalCells) {
|
||||||
|
hmGridEl.removeChild(hmGridEl.lastChild);
|
||||||
|
}
|
||||||
|
hoveredCellEl =
|
||||||
|
hoveredIdx >= 0 && hoveredIdx < slots.length ? currentCellEls[hoveredIdx] || null : null;
|
||||||
|
|
||||||
if (typeof requestAnimationFrame === 'function') {
|
if (typeof requestAnimationFrame === 'function') {
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
@@ -15114,7 +15114,6 @@ function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
|||||||
} else if (hoveredIdx >= 0) {
|
} else if (hoveredIdx >= 0) {
|
||||||
showHeatmapHoverAtIndex(hoveredIdx, currentCellEls[hoveredIdx], lastPointer);
|
showHeatmapHoverAtIndex(hoveredIdx, currentCellEls[hoveredIdx], lastPointer);
|
||||||
}
|
}
|
||||||
hasRenderedOnce = true;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15175,21 +15174,11 @@ function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
|||||||
}
|
}
|
||||||
hasRenderedLineOnce = true;
|
hasRenderedLineOnce = true;
|
||||||
|
|
||||||
// 渲染对齐底部刻度的垂直参考网格线及 X 轴标签(起止标签严格左右贴边)
|
// 就地增量补丁垂直参考网格线及底部 X 轴标签,保持文字常驻不重排不闪烁
|
||||||
const tickIndices = computeTickIndices(slots);
|
const tickIndices = computeTickIndices(slots);
|
||||||
const nextTickLabelsSig = tickIndices
|
|
||||||
.map((tIdx) => `${tIdx}:${slots[tIdx]?.label || ''}`)
|
|
||||||
.join('|');
|
|
||||||
const ticksChanged =
|
|
||||||
hasRenderedOnce &&
|
|
||||||
!modeChanged &&
|
|
||||||
lastTickLabelsSig !== '' &&
|
|
||||||
nextTickLabelsSig !== lastTickLabelsSig;
|
|
||||||
lastTickLabelsSig = nextTickLabelsSig;
|
|
||||||
|
|
||||||
while (vGridGroup.firstChild) vGridGroup.removeChild(vGridGroup.firstChild);
|
|
||||||
while (xAxisEl.firstChild) xAxisEl.removeChild(xAxisEl.firstChild);
|
|
||||||
tickElsByIdx = new Map();
|
tickElsByIdx = new Map();
|
||||||
|
let vLineCount = 0;
|
||||||
|
let tickCount = 0;
|
||||||
|
|
||||||
for (let i = 0; i < tickIndices.length; i++) {
|
for (let i = 0; i < tickIndices.length; i++) {
|
||||||
const tIdx = tickIndices[i];
|
const tIdx = tickIndices[i];
|
||||||
@@ -15198,34 +15187,57 @@ function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
|||||||
if (!pt || !slot) continue;
|
if (!pt || !slot) continue;
|
||||||
|
|
||||||
if (i > 0 && i < tickIndices.length - 1) {
|
if (i > 0 && i < tickIndices.length - 1) {
|
||||||
const vLine = document.createElementNS(SVG_NS, 'line');
|
let vLine = vGridLinePool[vLineCount];
|
||||||
vLine.setAttribute('x1', pt.x.toFixed(1));
|
if (!vLine) {
|
||||||
|
vLine = document.createElementNS(SVG_NS, 'line');
|
||||||
vLine.setAttribute('y1', '16');
|
vLine.setAttribute('y1', '16');
|
||||||
vLine.setAttribute('x2', pt.x.toFixed(1));
|
|
||||||
vLine.setAttribute('y2', String(BOTTOM_Y));
|
vLine.setAttribute('y2', String(BOTTOM_Y));
|
||||||
vGridGroup.appendChild(vLine);
|
vGridLinePool.push(vLine);
|
||||||
|
}
|
||||||
|
const xFixed = pt.x.toFixed(1);
|
||||||
|
patchAttr(vLine, 'x1', xFixed);
|
||||||
|
patchAttr(vLine, 'x2', xFixed);
|
||||||
|
if (vGridGroup.children[vLineCount] !== vLine) {
|
||||||
|
vGridGroup.insertBefore(vLine, vGridGroup.children[vLineCount] || null);
|
||||||
|
}
|
||||||
|
vLineCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isFirst = !isSingle && i === 0;
|
const isFirst = !isSingle && i === 0;
|
||||||
const isLast = !isSingle && i === tickIndices.length - 1;
|
const isLast = !isSingle && i === tickIndices.length - 1;
|
||||||
const pct = isFirst ? 0 : isLast ? 100 : (pt.x / viewW) * 100;
|
const pct = isFirst ? 0 : isLast ? 100 : (pt.x / viewW) * 100;
|
||||||
const tickEl = h('span', {
|
let tickRec = xAxisTickPool[tickCount];
|
||||||
className: `trend-x-tick text-mono${isFirst ? ' is-start' : isLast ? ' is-end' : ''}`,
|
if (!tickRec) {
|
||||||
text: slot.label || '',
|
const el = h('span', { className: 'trend-x-tick text-mono' });
|
||||||
title: formatTrendSlotFullLabel(slot) || slot.label || '',
|
const rec = { el, slotIdx: tIdx };
|
||||||
});
|
el.onclick = () => {
|
||||||
patchStyleVar(tickEl, '--tick-x', `${pct.toFixed(2)}%`);
|
|
||||||
tickEl.onclick = () => {
|
|
||||||
lastPointer = null;
|
lastPointer = null;
|
||||||
showLineHoverAtIndex(tIdx);
|
showLineHoverAtIndex(rec.slotIdx);
|
||||||
};
|
};
|
||||||
xAxisEl.appendChild(tickEl);
|
tickRec = rec;
|
||||||
tickElsByIdx.set(tIdx, tickEl);
|
xAxisTickPool.push(tickRec);
|
||||||
|
}
|
||||||
|
tickRec.slotIdx = tIdx;
|
||||||
|
patchClasses(tickRec.el, {
|
||||||
|
'is-start': isFirst,
|
||||||
|
'is-end': isLast,
|
||||||
|
'is-hovered': hoveredIdx === tIdx,
|
||||||
|
});
|
||||||
|
patchText(tickRec.el, slot.label || '');
|
||||||
|
patchAttr(tickRec.el, 'title', formatTrendSlotFullLabel(slot) || slot.label || '');
|
||||||
|
patchStyleVar(tickRec.el, '--tick-x', `${pct.toFixed(2)}%`);
|
||||||
|
if (xAxisEl.children[tickCount] !== tickRec.el) {
|
||||||
|
xAxisEl.insertBefore(tickRec.el, xAxisEl.children[tickCount] || null);
|
||||||
|
}
|
||||||
|
tickElsByIdx.set(tIdx, tickRec.el);
|
||||||
|
tickCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ticksChanged && canAnimateInBrowser()) {
|
while (vGridGroup.children.length > vLineCount) {
|
||||||
triggerTransientClass(xAxisEl, 'is-switching');
|
vGridGroup.removeChild(vGridGroup.lastChild);
|
||||||
triggerTransientClass(vGridGroup, 'is-switching');
|
}
|
||||||
|
while (xAxisEl.children.length > tickCount) {
|
||||||
|
xAxisEl.removeChild(xAxisEl.lastChild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15259,7 +15271,6 @@ function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
|||||||
} else if (hoveredIdx >= 0) {
|
} else if (hoveredIdx >= 0) {
|
||||||
showLineHoverAtIndex(hoveredIdx, lastPointer);
|
showLineHoverAtIndex(hoveredIdx, lastPointer);
|
||||||
}
|
}
|
||||||
hasRenderedOnce = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { el: chartWrap, update, destroy };
|
return { el: chartWrap, update, destroy };
|
||||||
@@ -19598,88 +19609,6 @@ function formatPoolFullCapRef(eqUsd, eqTok) {
|
|||||||
return usdStr;
|
return usdStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveWeeklyCapacitySummary(quotas) {
|
|
||||||
if (!quotas || typeof quotas !== 'object') return null;
|
|
||||||
if (quotas.weekly?.isOfficial === false) return null;
|
|
||||||
const direct = quotas.weeklyCapacityEstimate;
|
|
||||||
if (direct && typeof direct === 'object') {
|
|
||||||
if (
|
|
||||||
direct.status === 'custom_mode' ||
|
|
||||||
!Number.isFinite(Number(direct.totalEqWeeklyUsd)) ||
|
|
||||||
Number(direct.totalEqWeeklyUsd) <= 0
|
|
||||||
) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return direct;
|
|
||||||
}
|
|
||||||
|
|
||||||
const rawPools = Array.isArray(quotas.pools) ? quotas.pools : [];
|
|
||||||
const candidatePools = rawPools.filter(
|
|
||||||
(p) =>
|
|
||||||
p &&
|
|
||||||
(p.hasWeekly ||
|
|
||||||
p.weeklyUsedPct != null ||
|
|
||||||
Number.isFinite(p.rateEstimate?.eqFullWeeklyUsd))
|
|
||||||
);
|
|
||||||
const targetPools = candidatePools.length > 0 ? candidatePools : rawPools;
|
|
||||||
if (targetPools.length === 0) return null;
|
|
||||||
|
|
||||||
let sumUsd = 0;
|
|
||||||
let sumTokens = 0;
|
|
||||||
let readyPoolCount = 0;
|
|
||||||
let tokenReadyPoolCount = 0;
|
|
||||||
let hasPreliminary = false;
|
|
||||||
|
|
||||||
for (const p of targetPools) {
|
|
||||||
const est = p?.rateEstimate && typeof p.rateEstimate === 'object' ? p.rateEstimate : null;
|
|
||||||
let eqUsd =
|
|
||||||
Number.isFinite(est?.eqFullWeeklyUsd) && est.eqFullWeeklyUsd > 0
|
|
||||||
? Number(est.eqFullWeeklyUsd)
|
|
||||||
: null;
|
|
||||||
let eqTok =
|
|
||||||
Number.isFinite(est?.eqFullWeeklyTokens) && est.eqFullWeeklyTokens > 0
|
|
||||||
? Math.round(Number(est.eqFullWeeklyTokens))
|
|
||||||
: null;
|
|
||||||
if (eqUsd === null && Array.isArray(est?.models) && est.models.length > 0) {
|
|
||||||
const wkModels = est.models.filter(
|
|
||||||
(m) => Number.isFinite(m?.eqFullWeeklyUsd) && m.eqFullWeeklyUsd > 0
|
|
||||||
);
|
|
||||||
if (wkModels.length > 0) {
|
|
||||||
eqUsd =
|
|
||||||
wkModels.reduce((acc, m) => acc + Number(m.eqFullWeeklyUsd), 0) / wkModels.length;
|
|
||||||
const tokModels = wkModels.filter(
|
|
||||||
(m) => Number.isFinite(m?.eqFullWeeklyTokens) && m.eqFullWeeklyTokens > 0
|
|
||||||
);
|
|
||||||
if (tokModels.length === wkModels.length) {
|
|
||||||
eqTok = Math.round(
|
|
||||||
tokModels.reduce((acc, m) => acc + Number(m.eqFullWeeklyTokens), 0) / tokModels.length
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (eqUsd !== null) {
|
|
||||||
readyPoolCount += 1;
|
|
||||||
sumUsd += eqUsd;
|
|
||||||
if (est?.isPreliminaryWeekly) hasPreliminary = true;
|
|
||||||
if (eqTok !== null) {
|
|
||||||
tokenReadyPoolCount += 1;
|
|
||||||
sumTokens += eqTok;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (readyPoolCount === 0) return null;
|
|
||||||
const totalPoolCount = targetPools.length;
|
|
||||||
return {
|
|
||||||
status: readyPoolCount < totalPoolCount ? 'partial' : 'ready',
|
|
||||||
totalEqWeeklyUsd: +sumUsd.toFixed(1),
|
|
||||||
totalEqWeeklyTokens: tokenReadyPoolCount === readyPoolCount ? Math.round(sumTokens) : null,
|
|
||||||
readyPoolCount,
|
|
||||||
totalPoolCount,
|
|
||||||
hasPreliminary,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatRatePerUsdValue(rate) {
|
function formatRatePerUsdValue(rate) {
|
||||||
const num = Number(rate);
|
const num = Number(rate);
|
||||||
if (!Number.isFinite(num) || num <= 0) return '--';
|
if (!Number.isFinite(num) || num <= 0) return '--';
|
||||||
@@ -19804,13 +19733,11 @@ function createRateModelCard({
|
|||||||
function buildRatePopoverSig(data) {
|
function buildRatePopoverSig(data) {
|
||||||
const locale = getEffectiveLocale();
|
const locale = getEffectiveLocale();
|
||||||
const acct = String(data?.account?.email || data?.account?.name || '').trim();
|
const acct = String(data?.account?.email || data?.account?.name || '').trim();
|
||||||
const isOfficial = data?.quotas?.weekly?.isOfficial !== false;
|
|
||||||
const wkCapSig = JSON.stringify(data?.quotas?.weeklyCapacityEstimate || null);
|
|
||||||
const pools = Array.isArray(data?.quotas?.pools) ? data.quotas.pools : [];
|
const pools = Array.isArray(data?.quotas?.pools) ? data.quotas.pools : [];
|
||||||
const poolSig = pools
|
const poolSig = pools
|
||||||
.map((p) => `${p.poolKey || ''}:${p.poolLabel || ''}:${JSON.stringify(p.rateEstimate || null)}`)
|
.map((p) => `${p.poolKey || ''}:${p.poolLabel || ''}:${JSON.stringify(p.rateEstimate || null)}`)
|
||||||
.join('|');
|
.join('|');
|
||||||
return `${locale}|${acct}|${isOfficial}|${wkCapSig}|${poolSig}`;
|
return `${locale}|${acct}|${poolSig}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QuotaPoolsWidget = defineComponent({
|
const QuotaPoolsWidget = defineComponent({
|
||||||
@@ -19828,32 +19755,7 @@ const QuotaPoolsWidget = defineComponent({
|
|||||||
className: 'quota-rate-pop-account',
|
className: 'quota-rate-pop-account',
|
||||||
text: t('quota.ratePopAccountCurrent'),
|
text: t('quota.ratePopAccountCurrent'),
|
||||||
});
|
});
|
||||||
const ratePopWkLabelEl = h('span', { text: t('quota.ratePopWkCapTitle') });
|
|
||||||
const ratePopWkSubEl = h('span', {
|
|
||||||
className: 'quota-rate-wk-sub',
|
|
||||||
hidden: true,
|
|
||||||
text: '',
|
|
||||||
});
|
|
||||||
const ratePopWkUsdEl = h('span', { className: 'quota-rate-wk-usd text-mono', text: '--' });
|
|
||||||
const ratePopWkTokEl = h('span', {
|
|
||||||
className: 'quota-rate-wk-tok text-mono',
|
|
||||||
hidden: true,
|
|
||||||
text: '',
|
|
||||||
});
|
|
||||||
const ratePopWkSummaryEl = h(
|
|
||||||
'div',
|
|
||||||
{ className: 'quota-rate-wk-summary', hidden: true },
|
|
||||||
[
|
|
||||||
h('span', { className: 'quota-rate-wk-k' }, [ratePopWkLabelEl, ratePopWkSubEl]),
|
|
||||||
h('span', { className: 'quota-rate-wk-v' }, [ratePopWkUsdEl, ratePopWkTokEl]),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
ratePopWkSummaryEl.hidden = true;
|
|
||||||
const ratePopBodyEl = h('div', { className: 'quota-rate-pop-body' });
|
const ratePopBodyEl = h('div', { className: 'quota-rate-pop-body' });
|
||||||
const ratePopNoteEl = h('div', {
|
|
||||||
className: 'quota-rate-pop-note',
|
|
||||||
text: t('quota.ratePopNote'),
|
|
||||||
});
|
|
||||||
const ratePopoverEl = h(
|
const ratePopoverEl = h(
|
||||||
'div',
|
'div',
|
||||||
{
|
{
|
||||||
@@ -19863,9 +19765,7 @@ const QuotaPoolsWidget = defineComponent({
|
|||||||
},
|
},
|
||||||
[
|
[
|
||||||
h('div', { className: 'quota-rate-pop-head' }, [ratePopTitleEl, ratePopAccountEl]),
|
h('div', { className: 'quota-rate-pop-head' }, [ratePopTitleEl, ratePopAccountEl]),
|
||||||
ratePopWkSummaryEl,
|
|
||||||
ratePopBodyEl,
|
ratePopBodyEl,
|
||||||
ratePopNoteEl,
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
ratePopoverEl.hidden = true;
|
ratePopoverEl.hidden = true;
|
||||||
@@ -19943,7 +19843,6 @@ const QuotaPoolsWidget = defineComponent({
|
|||||||
lastRatePopSig = sig;
|
lastRatePopSig = sig;
|
||||||
|
|
||||||
patchText(ratePopTitleEl, t('quota.ratePopTitle'));
|
patchText(ratePopTitleEl, t('quota.ratePopTitle'));
|
||||||
patchText(ratePopNoteEl, t('quota.ratePopNote'));
|
|
||||||
patchAttr(rateHelpBtn, 'aria-label', t('quota.rateHelpAria'));
|
patchAttr(rateHelpBtn, 'aria-label', t('quota.rateHelpAria'));
|
||||||
|
|
||||||
const acctMasked = maskAccountLabel(data?.account?.email || data?.account?.name || '');
|
const acctMasked = maskAccountLabel(data?.account?.email || data?.account?.name || '');
|
||||||
@@ -19955,38 +19854,6 @@ const QuotaPoolsWidget = defineComponent({
|
|||||||
);
|
);
|
||||||
patchAttr(ratePopAccountEl, 'title', acctMasked || null);
|
patchAttr(ratePopAccountEl, 'title', acctMasked || null);
|
||||||
|
|
||||||
const wkCap = resolveWeeklyCapacitySummary(data?.quotas);
|
|
||||||
if (wkCap) {
|
|
||||||
ratePopWkSummaryEl.hidden = false;
|
|
||||||
patchAttr(ratePopWkSummaryEl, 'hidden', false);
|
|
||||||
patchText(ratePopWkLabelEl, t('quota.ratePopWkCapTitle'));
|
|
||||||
const wkSubText =
|
|
||||||
wkCap.status === 'partial' && Number(wkCap.totalPoolCount) > 0
|
|
||||||
? t('quota.ratePopWkCapPartial', {
|
|
||||||
ready: Number(wkCap.readyPoolCount) || 0,
|
|
||||||
total: Number(wkCap.totalPoolCount) || 0,
|
|
||||||
})
|
|
||||||
: wkCap.hasPreliminary
|
|
||||||
? t('quota.ratePopWkCapPrelim')
|
|
||||||
: '';
|
|
||||||
ratePopWkSubEl.hidden = !wkSubText;
|
|
||||||
patchAttr(ratePopWkSubEl, 'hidden', !wkSubText);
|
|
||||||
patchText(ratePopWkSubEl, wkSubText);
|
|
||||||
patchText(ratePopWkUsdEl, `≈ ${formatRateEqUsd(wkCap.totalEqWeeklyUsd)}`);
|
|
||||||
const hasWkTok =
|
|
||||||
Number.isFinite(Number(wkCap.totalEqWeeklyTokens)) &&
|
|
||||||
Number(wkCap.totalEqWeeklyTokens) > 0;
|
|
||||||
ratePopWkTokEl.hidden = !hasWkTok;
|
|
||||||
patchAttr(ratePopWkTokEl, 'hidden', !hasWkTok);
|
|
||||||
patchText(
|
|
||||||
ratePopWkTokEl,
|
|
||||||
hasWkTok ? `· ${formatTokens(Number(wkCap.totalEqWeeklyTokens))}` : ''
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
ratePopWkSummaryEl.hidden = true;
|
|
||||||
patchAttr(ratePopWkSummaryEl, 'hidden', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (ratePopBodyEl.firstChild) {
|
while (ratePopBodyEl.firstChild) {
|
||||||
ratePopBodyEl.removeChild(ratePopBodyEl.firstChild);
|
ratePopBodyEl.removeChild(ratePopBodyEl.firstChild);
|
||||||
}
|
}
|
||||||
@@ -30473,11 +30340,7 @@ const ConsumptionView = defineComponent({
|
|||||||
let lastAnimatedRankingKey = '';
|
let lastAnimatedRankingKey = '';
|
||||||
let lastAnimatedSortSig = '';
|
let lastAnimatedSortSig = '';
|
||||||
const consAnimTimers = new Map();
|
const consAnimTimers = new Map();
|
||||||
const TRANSIENT_CONS_CLASSES = [
|
const TRANSIENT_CONS_CLASSES = ['is-bars-revealing'];
|
||||||
'is-range-switching',
|
|
||||||
'is-tab-entering',
|
|
||||||
'is-bars-revealing',
|
|
||||||
];
|
|
||||||
|
|
||||||
function cleanupConsAnim(el) {
|
function cleanupConsAnim(el) {
|
||||||
const rec = consAnimTimers.get(el);
|
const rec = consAnimTimers.get(el);
|
||||||
@@ -32295,13 +32158,7 @@ const ConsumptionView = defineComponent({
|
|||||||
!tabSwitched &&
|
!tabSwitched &&
|
||||||
nextSortSig !== lastAnimatedSortSig;
|
nextSortSig !== lastAnimatedSortSig;
|
||||||
|
|
||||||
if (rangeSwitched) {
|
if (tabSwitched || sortSwitched) {
|
||||||
triggerConsAnim(unifiedMatrixEl, 'is-range-switching');
|
|
||||||
triggerConsAnim(activeRankingEl, 'is-range-switching');
|
|
||||||
triggerConsAnim(sourcesListEl, 'is-range-switching');
|
|
||||||
} else if (tabSwitched) {
|
|
||||||
triggerConsAnim(activeRankingEl, 'is-tab-entering');
|
|
||||||
} else if (sortSwitched) {
|
|
||||||
triggerConsAnim(activeRankingEl, 'is-bars-revealing');
|
triggerConsAnim(activeRankingEl, 'is-bars-revealing');
|
||||||
}
|
}
|
||||||
if (!hasCompletedInitialDraw) {
|
if (!hasCompletedInitialDraw) {
|
||||||
|
|||||||
@@ -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=1795504410473">
|
<link rel="stylesheet" href="/styles.css?v=1795515788175">
|
||||||
<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=1795504410473"></script>
|
<script src="/app.js?v=1795515788175"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -553,8 +553,6 @@ export function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
|||||||
let hoveredCellEl = null;
|
let hoveredCellEl = null;
|
||||||
let lastPointer = null;
|
let lastPointer = null;
|
||||||
let lastRenderSig = '';
|
let lastRenderSig = '';
|
||||||
let lastTickLabelsSig = '';
|
|
||||||
let hasRenderedOnce = false;
|
|
||||||
let hasRenderedLineOnce = false;
|
let hasRenderedLineOnce = false;
|
||||||
let peakReadyArmed = false;
|
let peakReadyArmed = false;
|
||||||
let peakReadyRaf = 0;
|
let peakReadyRaf = 0;
|
||||||
@@ -562,40 +560,13 @@ export function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
|||||||
let morphRafId = 0;
|
let morphRafId = 0;
|
||||||
let committedSegs = [];
|
let committedSegs = [];
|
||||||
let liveMorphSegs = null;
|
let liveMorphSegs = null;
|
||||||
const transientClassTimers = new Map();
|
const vGridLinePool = [];
|
||||||
|
const xAxisTickPool = [];
|
||||||
|
const hmMonthPool = [];
|
||||||
|
const hmCellPool = [];
|
||||||
|
|
||||||
const CURVE_MORPH_DURATION_MS = 240;
|
const CURVE_MORPH_DURATION_MS = 240;
|
||||||
|
|
||||||
function cleanupTransientClass(el) {
|
|
||||||
const rec = transientClassTimers.get(el);
|
|
||||||
if (!rec) return;
|
|
||||||
clearTimeout(rec.tid);
|
|
||||||
el?.removeEventListener?.('animationend', rec.onEnd);
|
|
||||||
el?.classList?.remove(rec.cls);
|
|
||||||
transientClassTimers.delete(el);
|
|
||||||
}
|
|
||||||
|
|
||||||
function triggerTransientClass(el, cls, fallbackMs = 650) {
|
|
||||||
if (!el || !el.classList) return;
|
|
||||||
cleanupTransientClass(el);
|
|
||||||
el.classList.remove(cls);
|
|
||||||
void el.offsetWidth;
|
|
||||||
const onEnd = (ev) => {
|
|
||||||
if (ev && ev.target && ev.target !== el) return;
|
|
||||||
cleanupTransientClass(el);
|
|
||||||
};
|
|
||||||
const tid = setTimeout(() => cleanupTransientClass(el), fallbackMs);
|
|
||||||
transientClassTimers.set(el, { cls, tid, onEnd });
|
|
||||||
el.addEventListener?.('animationend', onEnd);
|
|
||||||
el.classList.add(cls);
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearAllTransientTimers() {
|
|
||||||
for (const el of Array.from(transientClassTimers.keys())) {
|
|
||||||
cleanupTransientClass(el);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function cancelCurveMorph() {
|
function cancelCurveMorph() {
|
||||||
if (
|
if (
|
||||||
morphRafId &&
|
morphRafId &&
|
||||||
@@ -1221,7 +1192,6 @@ export function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
|||||||
cancelTipTrackRaf();
|
cancelTipTrackRaf();
|
||||||
cancelCurveMorph();
|
cancelCurveMorph();
|
||||||
cancelPeakReadyRaf();
|
cancelPeakReadyRaf();
|
||||||
clearAllTransientTimers();
|
|
||||||
plotStage.removeEventListener('mousemove', handlePointerMove);
|
plotStage.removeEventListener('mousemove', handlePointerMove);
|
||||||
plotStage.removeEventListener('click', handleLineClick);
|
plotStage.removeEventListener('click', handleLineClick);
|
||||||
plotStage.removeEventListener('mouseleave', clearHover);
|
plotStage.removeEventListener('mouseleave', clearHover);
|
||||||
@@ -1270,14 +1240,6 @@ export function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
|||||||
patchAttr(plotStage, 'hidden', useHeatmap);
|
patchAttr(plotStage, 'hidden', useHeatmap);
|
||||||
patchAttr(xAxisEl, 'hidden', useHeatmap);
|
patchAttr(xAxisEl, 'hidden', useHeatmap);
|
||||||
patchAttr(heatmapStage, 'hidden', !useHeatmap);
|
patchAttr(heatmapStage, 'hidden', !useHeatmap);
|
||||||
if (hasRenderedOnce && modeChanged && canAnimateInBrowser()) {
|
|
||||||
if (useHeatmap) {
|
|
||||||
triggerTransientClass(heatmapStage, 'is-stage-entering');
|
|
||||||
} else {
|
|
||||||
triggerTransientClass(plotStage, 'is-stage-entering');
|
|
||||||
triggerTransientClass(xAxisEl, 'is-switching');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!useHeatmap) {
|
if (!useHeatmap) {
|
||||||
syncViewWidth();
|
syncViewWidth();
|
||||||
@@ -1351,51 +1313,97 @@ export function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
|||||||
patchStyleVar(hmBodyEl, '--hm-weeks', String(totalWeeks));
|
patchStyleVar(hmBodyEl, '--hm-weeks', String(totalWeeks));
|
||||||
patchStyleVar(hmBodyEl, '--hm-gap', `${gapPx}px`);
|
patchStyleVar(hmBodyEl, '--hm-gap', `${gapPx}px`);
|
||||||
|
|
||||||
// 重建顶部对齐月份标签
|
// 就地增量补丁顶部对齐月份标签,避免文字节点销毁重建
|
||||||
while (hmMonthsEl.firstChild) hmMonthsEl.removeChild(hmMonthsEl.firstChild);
|
|
||||||
const monthTicks = buildHeatmapMonthTicks(slots, firstDow, totalWeeks);
|
const monthTicks = buildHeatmapMonthTicks(slots, firstDow, totalWeeks);
|
||||||
for (const mt of monthTicks) {
|
for (let i = 0; i < monthTicks.length; i++) {
|
||||||
const mEl = h('span', { className: 'trend-hm-month text-mono', text: mt.text });
|
const mt = monthTicks[i];
|
||||||
|
let mEl = hmMonthPool[i];
|
||||||
|
if (!mEl) {
|
||||||
|
mEl = h('span', { className: 'trend-hm-month text-mono' });
|
||||||
|
hmMonthPool.push(mEl);
|
||||||
|
}
|
||||||
|
patchText(mEl, mt.text);
|
||||||
patchStyleVar(mEl, '--hm-col', String(mt.col));
|
patchStyleVar(mEl, '--hm-col', String(mt.col));
|
||||||
hmMonthsEl.appendChild(mEl);
|
if (hmMonthsEl.children[i] !== mEl) {
|
||||||
|
hmMonthsEl.insertBefore(mEl, hmMonthsEl.children[i] || null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (hmMonthsEl.children.length > monthTicks.length) {
|
||||||
|
hmMonthsEl.removeChild(hmMonthsEl.lastChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重建 7 行 × N 周列的每日小格子(一格一天),使用 DocumentFragment 一次性批量挂载减少重排
|
// 就地增量复用 7 行 × N 周列的每日小格子,首次批量新增节点使用 DocumentFragment 挂载
|
||||||
while (hmGridEl.firstChild) hmGridEl.removeChild(hmGridEl.firstChild);
|
|
||||||
hoveredCellEl = null;
|
|
||||||
currentCellEls = new Array(slots.length);
|
currentCellEls = new Array(slots.length);
|
||||||
const gridFrag =
|
const prevMountedCount = hmGridEl.children.length;
|
||||||
typeof document !== 'undefined' && typeof document.createDocumentFragment === 'function'
|
const newCellsFrag =
|
||||||
|
totalCells > prevMountedCount &&
|
||||||
|
typeof document !== 'undefined' &&
|
||||||
|
typeof document.createDocumentFragment === 'function'
|
||||||
? document.createDocumentFragment()
|
? document.createDocumentFragment()
|
||||||
: null;
|
: null;
|
||||||
const gridTarget = gridFrag || hmGridEl;
|
|
||||||
|
|
||||||
for (let pad = 0; pad < firstDow; pad++) {
|
for (let nodeIdx = 0; nodeIdx < totalCells; nodeIdx++) {
|
||||||
gridTarget.appendChild(
|
let cellEl = hmCellPool[nodeIdx];
|
||||||
h('span', { className: 'trend-hm-cell is-pad', 'aria-hidden': 'true' })
|
if (!cellEl) {
|
||||||
);
|
cellEl = h('span', { className: 'trend-hm-cell' });
|
||||||
|
hmCellPool.push(cellEl);
|
||||||
}
|
}
|
||||||
|
if (nodeIdx < firstDow) {
|
||||||
for (let i = 0; i < slots.length; i++) {
|
patchClasses(cellEl, {
|
||||||
|
'is-pad': true,
|
||||||
|
'is-hovered': false,
|
||||||
|
'lv-0': false,
|
||||||
|
'lv-1': false,
|
||||||
|
'lv-2': false,
|
||||||
|
'lv-3': false,
|
||||||
|
'lv-4': false,
|
||||||
|
});
|
||||||
|
patchAttr(cellEl, 'aria-hidden', 'true');
|
||||||
|
patchAttr(cellEl, 'role', null);
|
||||||
|
patchAttr(cellEl, 'data-slot-idx', null);
|
||||||
|
patchAttr(cellEl, 'data-hm-col', null);
|
||||||
|
patchAttr(cellEl, 'data-hm-row', null);
|
||||||
|
} else {
|
||||||
|
const i = nodeIdx - firstDow;
|
||||||
const slot = slots[i];
|
const slot = slots[i];
|
||||||
const tok = safeSlotTokens(slot?.tokens);
|
const tok = safeSlotTokens(slot?.tokens);
|
||||||
const lv = resolveHeatmapLevel(tok, thresholds);
|
const lv = resolveHeatmapLevel(tok, thresholds);
|
||||||
const gridPos = firstDow + i;
|
const col = Math.floor(nodeIdx / 7);
|
||||||
const col = Math.floor(gridPos / 7);
|
const row = nodeIdx % 7;
|
||||||
const row = gridPos % 7;
|
patchClasses(cellEl, {
|
||||||
const cellEl = h('span', {
|
'is-pad': false,
|
||||||
className: `trend-hm-cell lv-${lv}`,
|
'is-hovered': hoveredIdx === i,
|
||||||
'data-slot-idx': String(i),
|
'lv-0': lv === 0,
|
||||||
'data-hm-col': String(col),
|
'lv-1': lv === 1,
|
||||||
'data-hm-row': String(row),
|
'lv-2': lv === 2,
|
||||||
role: 'gridcell',
|
'lv-3': lv === 3,
|
||||||
|
'lv-4': lv === 4,
|
||||||
});
|
});
|
||||||
gridTarget.appendChild(cellEl);
|
patchAttr(cellEl, 'aria-hidden', null);
|
||||||
|
patchAttr(cellEl, 'role', 'gridcell');
|
||||||
|
patchAttr(cellEl, 'data-slot-idx', String(i));
|
||||||
|
patchAttr(cellEl, 'data-hm-col', String(col));
|
||||||
|
patchAttr(cellEl, 'data-hm-row', String(row));
|
||||||
currentCellEls[i] = cellEl;
|
currentCellEls[i] = cellEl;
|
||||||
}
|
}
|
||||||
if (gridFrag) {
|
if (nodeIdx < prevMountedCount) {
|
||||||
hmGridEl.appendChild(gridFrag);
|
if (hmGridEl.children[nodeIdx] !== cellEl) {
|
||||||
|
hmGridEl.insertBefore(cellEl, hmGridEl.children[nodeIdx] || null);
|
||||||
}
|
}
|
||||||
|
} else if (newCellsFrag) {
|
||||||
|
newCellsFrag.appendChild(cellEl);
|
||||||
|
} else {
|
||||||
|
hmGridEl.appendChild(cellEl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newCellsFrag) {
|
||||||
|
hmGridEl.appendChild(newCellsFrag);
|
||||||
|
}
|
||||||
|
while (hmGridEl.children.length > totalCells) {
|
||||||
|
hmGridEl.removeChild(hmGridEl.lastChild);
|
||||||
|
}
|
||||||
|
hoveredCellEl =
|
||||||
|
hoveredIdx >= 0 && hoveredIdx < slots.length ? currentCellEls[hoveredIdx] || null : null;
|
||||||
|
|
||||||
if (typeof requestAnimationFrame === 'function') {
|
if (typeof requestAnimationFrame === 'function') {
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
@@ -1423,7 +1431,6 @@ export function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
|||||||
} else if (hoveredIdx >= 0) {
|
} else if (hoveredIdx >= 0) {
|
||||||
showHeatmapHoverAtIndex(hoveredIdx, currentCellEls[hoveredIdx], lastPointer);
|
showHeatmapHoverAtIndex(hoveredIdx, currentCellEls[hoveredIdx], lastPointer);
|
||||||
}
|
}
|
||||||
hasRenderedOnce = true;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1484,21 +1491,11 @@ export function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
|||||||
}
|
}
|
||||||
hasRenderedLineOnce = true;
|
hasRenderedLineOnce = true;
|
||||||
|
|
||||||
// 渲染对齐底部刻度的垂直参考网格线及 X 轴标签(起止标签严格左右贴边)
|
// 就地增量补丁垂直参考网格线及底部 X 轴标签,保持文字常驻不重排不闪烁
|
||||||
const tickIndices = computeTickIndices(slots);
|
const tickIndices = computeTickIndices(slots);
|
||||||
const nextTickLabelsSig = tickIndices
|
|
||||||
.map((tIdx) => `${tIdx}:${slots[tIdx]?.label || ''}`)
|
|
||||||
.join('|');
|
|
||||||
const ticksChanged =
|
|
||||||
hasRenderedOnce &&
|
|
||||||
!modeChanged &&
|
|
||||||
lastTickLabelsSig !== '' &&
|
|
||||||
nextTickLabelsSig !== lastTickLabelsSig;
|
|
||||||
lastTickLabelsSig = nextTickLabelsSig;
|
|
||||||
|
|
||||||
while (vGridGroup.firstChild) vGridGroup.removeChild(vGridGroup.firstChild);
|
|
||||||
while (xAxisEl.firstChild) xAxisEl.removeChild(xAxisEl.firstChild);
|
|
||||||
tickElsByIdx = new Map();
|
tickElsByIdx = new Map();
|
||||||
|
let vLineCount = 0;
|
||||||
|
let tickCount = 0;
|
||||||
|
|
||||||
for (let i = 0; i < tickIndices.length; i++) {
|
for (let i = 0; i < tickIndices.length; i++) {
|
||||||
const tIdx = tickIndices[i];
|
const tIdx = tickIndices[i];
|
||||||
@@ -1507,34 +1504,57 @@ export function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
|||||||
if (!pt || !slot) continue;
|
if (!pt || !slot) continue;
|
||||||
|
|
||||||
if (i > 0 && i < tickIndices.length - 1) {
|
if (i > 0 && i < tickIndices.length - 1) {
|
||||||
const vLine = document.createElementNS(SVG_NS, 'line');
|
let vLine = vGridLinePool[vLineCount];
|
||||||
vLine.setAttribute('x1', pt.x.toFixed(1));
|
if (!vLine) {
|
||||||
|
vLine = document.createElementNS(SVG_NS, 'line');
|
||||||
vLine.setAttribute('y1', '16');
|
vLine.setAttribute('y1', '16');
|
||||||
vLine.setAttribute('x2', pt.x.toFixed(1));
|
|
||||||
vLine.setAttribute('y2', String(BOTTOM_Y));
|
vLine.setAttribute('y2', String(BOTTOM_Y));
|
||||||
vGridGroup.appendChild(vLine);
|
vGridLinePool.push(vLine);
|
||||||
|
}
|
||||||
|
const xFixed = pt.x.toFixed(1);
|
||||||
|
patchAttr(vLine, 'x1', xFixed);
|
||||||
|
patchAttr(vLine, 'x2', xFixed);
|
||||||
|
if (vGridGroup.children[vLineCount] !== vLine) {
|
||||||
|
vGridGroup.insertBefore(vLine, vGridGroup.children[vLineCount] || null);
|
||||||
|
}
|
||||||
|
vLineCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isFirst = !isSingle && i === 0;
|
const isFirst = !isSingle && i === 0;
|
||||||
const isLast = !isSingle && i === tickIndices.length - 1;
|
const isLast = !isSingle && i === tickIndices.length - 1;
|
||||||
const pct = isFirst ? 0 : isLast ? 100 : (pt.x / viewW) * 100;
|
const pct = isFirst ? 0 : isLast ? 100 : (pt.x / viewW) * 100;
|
||||||
const tickEl = h('span', {
|
let tickRec = xAxisTickPool[tickCount];
|
||||||
className: `trend-x-tick text-mono${isFirst ? ' is-start' : isLast ? ' is-end' : ''}`,
|
if (!tickRec) {
|
||||||
text: slot.label || '',
|
const el = h('span', { className: 'trend-x-tick text-mono' });
|
||||||
title: formatTrendSlotFullLabel(slot) || slot.label || '',
|
const rec = { el, slotIdx: tIdx };
|
||||||
});
|
el.onclick = () => {
|
||||||
patchStyleVar(tickEl, '--tick-x', `${pct.toFixed(2)}%`);
|
|
||||||
tickEl.onclick = () => {
|
|
||||||
lastPointer = null;
|
lastPointer = null;
|
||||||
showLineHoverAtIndex(tIdx);
|
showLineHoverAtIndex(rec.slotIdx);
|
||||||
};
|
};
|
||||||
xAxisEl.appendChild(tickEl);
|
tickRec = rec;
|
||||||
tickElsByIdx.set(tIdx, tickEl);
|
xAxisTickPool.push(tickRec);
|
||||||
|
}
|
||||||
|
tickRec.slotIdx = tIdx;
|
||||||
|
patchClasses(tickRec.el, {
|
||||||
|
'is-start': isFirst,
|
||||||
|
'is-end': isLast,
|
||||||
|
'is-hovered': hoveredIdx === tIdx,
|
||||||
|
});
|
||||||
|
patchText(tickRec.el, slot.label || '');
|
||||||
|
patchAttr(tickRec.el, 'title', formatTrendSlotFullLabel(slot) || slot.label || '');
|
||||||
|
patchStyleVar(tickRec.el, '--tick-x', `${pct.toFixed(2)}%`);
|
||||||
|
if (xAxisEl.children[tickCount] !== tickRec.el) {
|
||||||
|
xAxisEl.insertBefore(tickRec.el, xAxisEl.children[tickCount] || null);
|
||||||
|
}
|
||||||
|
tickElsByIdx.set(tIdx, tickRec.el);
|
||||||
|
tickCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ticksChanged && canAnimateInBrowser()) {
|
while (vGridGroup.children.length > vLineCount) {
|
||||||
triggerTransientClass(xAxisEl, 'is-switching');
|
vGridGroup.removeChild(vGridGroup.lastChild);
|
||||||
triggerTransientClass(vGridGroup, 'is-switching');
|
}
|
||||||
|
while (xAxisEl.children.length > tickCount) {
|
||||||
|
xAxisEl.removeChild(xAxisEl.lastChild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1568,7 +1588,6 @@ export function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
|||||||
} else if (hoveredIdx >= 0) {
|
} else if (hoveredIdx >= 0) {
|
||||||
showLineHoverAtIndex(hoveredIdx, lastPointer);
|
showLineHoverAtIndex(hoveredIdx, lastPointer);
|
||||||
}
|
}
|
||||||
hasRenderedOnce = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { el: chartWrap, update, destroy };
|
return { el: chartWrap, update, destroy };
|
||||||
|
|||||||
@@ -424,88 +424,6 @@ function formatPoolFullCapRef(eqUsd, eqTok) {
|
|||||||
return usdStr;
|
return usdStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveWeeklyCapacitySummary(quotas) {
|
|
||||||
if (!quotas || typeof quotas !== 'object') return null;
|
|
||||||
if (quotas.weekly?.isOfficial === false) return null;
|
|
||||||
const direct = quotas.weeklyCapacityEstimate;
|
|
||||||
if (direct && typeof direct === 'object') {
|
|
||||||
if (
|
|
||||||
direct.status === 'custom_mode' ||
|
|
||||||
!Number.isFinite(Number(direct.totalEqWeeklyUsd)) ||
|
|
||||||
Number(direct.totalEqWeeklyUsd) <= 0
|
|
||||||
) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return direct;
|
|
||||||
}
|
|
||||||
|
|
||||||
const rawPools = Array.isArray(quotas.pools) ? quotas.pools : [];
|
|
||||||
const candidatePools = rawPools.filter(
|
|
||||||
(p) =>
|
|
||||||
p &&
|
|
||||||
(p.hasWeekly ||
|
|
||||||
p.weeklyUsedPct != null ||
|
|
||||||
Number.isFinite(p.rateEstimate?.eqFullWeeklyUsd))
|
|
||||||
);
|
|
||||||
const targetPools = candidatePools.length > 0 ? candidatePools : rawPools;
|
|
||||||
if (targetPools.length === 0) return null;
|
|
||||||
|
|
||||||
let sumUsd = 0;
|
|
||||||
let sumTokens = 0;
|
|
||||||
let readyPoolCount = 0;
|
|
||||||
let tokenReadyPoolCount = 0;
|
|
||||||
let hasPreliminary = false;
|
|
||||||
|
|
||||||
for (const p of targetPools) {
|
|
||||||
const est = p?.rateEstimate && typeof p.rateEstimate === 'object' ? p.rateEstimate : null;
|
|
||||||
let eqUsd =
|
|
||||||
Number.isFinite(est?.eqFullWeeklyUsd) && est.eqFullWeeklyUsd > 0
|
|
||||||
? Number(est.eqFullWeeklyUsd)
|
|
||||||
: null;
|
|
||||||
let eqTok =
|
|
||||||
Number.isFinite(est?.eqFullWeeklyTokens) && est.eqFullWeeklyTokens > 0
|
|
||||||
? Math.round(Number(est.eqFullWeeklyTokens))
|
|
||||||
: null;
|
|
||||||
if (eqUsd === null && Array.isArray(est?.models) && est.models.length > 0) {
|
|
||||||
const wkModels = est.models.filter(
|
|
||||||
(m) => Number.isFinite(m?.eqFullWeeklyUsd) && m.eqFullWeeklyUsd > 0
|
|
||||||
);
|
|
||||||
if (wkModels.length > 0) {
|
|
||||||
eqUsd =
|
|
||||||
wkModels.reduce((acc, m) => acc + Number(m.eqFullWeeklyUsd), 0) / wkModels.length;
|
|
||||||
const tokModels = wkModels.filter(
|
|
||||||
(m) => Number.isFinite(m?.eqFullWeeklyTokens) && m.eqFullWeeklyTokens > 0
|
|
||||||
);
|
|
||||||
if (tokModels.length === wkModels.length) {
|
|
||||||
eqTok = Math.round(
|
|
||||||
tokModels.reduce((acc, m) => acc + Number(m.eqFullWeeklyTokens), 0) / tokModels.length
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (eqUsd !== null) {
|
|
||||||
readyPoolCount += 1;
|
|
||||||
sumUsd += eqUsd;
|
|
||||||
if (est?.isPreliminaryWeekly) hasPreliminary = true;
|
|
||||||
if (eqTok !== null) {
|
|
||||||
tokenReadyPoolCount += 1;
|
|
||||||
sumTokens += eqTok;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (readyPoolCount === 0) return null;
|
|
||||||
const totalPoolCount = targetPools.length;
|
|
||||||
return {
|
|
||||||
status: readyPoolCount < totalPoolCount ? 'partial' : 'ready',
|
|
||||||
totalEqWeeklyUsd: +sumUsd.toFixed(1),
|
|
||||||
totalEqWeeklyTokens: tokenReadyPoolCount === readyPoolCount ? Math.round(sumTokens) : null,
|
|
||||||
readyPoolCount,
|
|
||||||
totalPoolCount,
|
|
||||||
hasPreliminary,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatRatePerUsdValue(rate) {
|
function formatRatePerUsdValue(rate) {
|
||||||
const num = Number(rate);
|
const num = Number(rate);
|
||||||
if (!Number.isFinite(num) || num <= 0) return '--';
|
if (!Number.isFinite(num) || num <= 0) return '--';
|
||||||
@@ -630,13 +548,11 @@ function createRateModelCard({
|
|||||||
function buildRatePopoverSig(data) {
|
function buildRatePopoverSig(data) {
|
||||||
const locale = getEffectiveLocale();
|
const locale = getEffectiveLocale();
|
||||||
const acct = String(data?.account?.email || data?.account?.name || '').trim();
|
const acct = String(data?.account?.email || data?.account?.name || '').trim();
|
||||||
const isOfficial = data?.quotas?.weekly?.isOfficial !== false;
|
|
||||||
const wkCapSig = JSON.stringify(data?.quotas?.weeklyCapacityEstimate || null);
|
|
||||||
const pools = Array.isArray(data?.quotas?.pools) ? data.quotas.pools : [];
|
const pools = Array.isArray(data?.quotas?.pools) ? data.quotas.pools : [];
|
||||||
const poolSig = pools
|
const poolSig = pools
|
||||||
.map((p) => `${p.poolKey || ''}:${p.poolLabel || ''}:${JSON.stringify(p.rateEstimate || null)}`)
|
.map((p) => `${p.poolKey || ''}:${p.poolLabel || ''}:${JSON.stringify(p.rateEstimate || null)}`)
|
||||||
.join('|');
|
.join('|');
|
||||||
return `${locale}|${acct}|${isOfficial}|${wkCapSig}|${poolSig}`;
|
return `${locale}|${acct}|${poolSig}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const QuotaPoolsWidget = defineComponent({
|
export const QuotaPoolsWidget = defineComponent({
|
||||||
@@ -654,32 +570,7 @@ export const QuotaPoolsWidget = defineComponent({
|
|||||||
className: 'quota-rate-pop-account',
|
className: 'quota-rate-pop-account',
|
||||||
text: t('quota.ratePopAccountCurrent'),
|
text: t('quota.ratePopAccountCurrent'),
|
||||||
});
|
});
|
||||||
const ratePopWkLabelEl = h('span', { text: t('quota.ratePopWkCapTitle') });
|
|
||||||
const ratePopWkSubEl = h('span', {
|
|
||||||
className: 'quota-rate-wk-sub',
|
|
||||||
hidden: true,
|
|
||||||
text: '',
|
|
||||||
});
|
|
||||||
const ratePopWkUsdEl = h('span', { className: 'quota-rate-wk-usd text-mono', text: '--' });
|
|
||||||
const ratePopWkTokEl = h('span', {
|
|
||||||
className: 'quota-rate-wk-tok text-mono',
|
|
||||||
hidden: true,
|
|
||||||
text: '',
|
|
||||||
});
|
|
||||||
const ratePopWkSummaryEl = h(
|
|
||||||
'div',
|
|
||||||
{ className: 'quota-rate-wk-summary', hidden: true },
|
|
||||||
[
|
|
||||||
h('span', { className: 'quota-rate-wk-k' }, [ratePopWkLabelEl, ratePopWkSubEl]),
|
|
||||||
h('span', { className: 'quota-rate-wk-v' }, [ratePopWkUsdEl, ratePopWkTokEl]),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
ratePopWkSummaryEl.hidden = true;
|
|
||||||
const ratePopBodyEl = h('div', { className: 'quota-rate-pop-body' });
|
const ratePopBodyEl = h('div', { className: 'quota-rate-pop-body' });
|
||||||
const ratePopNoteEl = h('div', {
|
|
||||||
className: 'quota-rate-pop-note',
|
|
||||||
text: t('quota.ratePopNote'),
|
|
||||||
});
|
|
||||||
const ratePopoverEl = h(
|
const ratePopoverEl = h(
|
||||||
'div',
|
'div',
|
||||||
{
|
{
|
||||||
@@ -689,9 +580,7 @@ export const QuotaPoolsWidget = defineComponent({
|
|||||||
},
|
},
|
||||||
[
|
[
|
||||||
h('div', { className: 'quota-rate-pop-head' }, [ratePopTitleEl, ratePopAccountEl]),
|
h('div', { className: 'quota-rate-pop-head' }, [ratePopTitleEl, ratePopAccountEl]),
|
||||||
ratePopWkSummaryEl,
|
|
||||||
ratePopBodyEl,
|
ratePopBodyEl,
|
||||||
ratePopNoteEl,
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
ratePopoverEl.hidden = true;
|
ratePopoverEl.hidden = true;
|
||||||
@@ -769,7 +658,6 @@ export const QuotaPoolsWidget = defineComponent({
|
|||||||
lastRatePopSig = sig;
|
lastRatePopSig = sig;
|
||||||
|
|
||||||
patchText(ratePopTitleEl, t('quota.ratePopTitle'));
|
patchText(ratePopTitleEl, t('quota.ratePopTitle'));
|
||||||
patchText(ratePopNoteEl, t('quota.ratePopNote'));
|
|
||||||
patchAttr(rateHelpBtn, 'aria-label', t('quota.rateHelpAria'));
|
patchAttr(rateHelpBtn, 'aria-label', t('quota.rateHelpAria'));
|
||||||
|
|
||||||
const acctMasked = maskAccountLabel(data?.account?.email || data?.account?.name || '');
|
const acctMasked = maskAccountLabel(data?.account?.email || data?.account?.name || '');
|
||||||
@@ -781,38 +669,6 @@ export const QuotaPoolsWidget = defineComponent({
|
|||||||
);
|
);
|
||||||
patchAttr(ratePopAccountEl, 'title', acctMasked || null);
|
patchAttr(ratePopAccountEl, 'title', acctMasked || null);
|
||||||
|
|
||||||
const wkCap = resolveWeeklyCapacitySummary(data?.quotas);
|
|
||||||
if (wkCap) {
|
|
||||||
ratePopWkSummaryEl.hidden = false;
|
|
||||||
patchAttr(ratePopWkSummaryEl, 'hidden', false);
|
|
||||||
patchText(ratePopWkLabelEl, t('quota.ratePopWkCapTitle'));
|
|
||||||
const wkSubText =
|
|
||||||
wkCap.status === 'partial' && Number(wkCap.totalPoolCount) > 0
|
|
||||||
? t('quota.ratePopWkCapPartial', {
|
|
||||||
ready: Number(wkCap.readyPoolCount) || 0,
|
|
||||||
total: Number(wkCap.totalPoolCount) || 0,
|
|
||||||
})
|
|
||||||
: wkCap.hasPreliminary
|
|
||||||
? t('quota.ratePopWkCapPrelim')
|
|
||||||
: '';
|
|
||||||
ratePopWkSubEl.hidden = !wkSubText;
|
|
||||||
patchAttr(ratePopWkSubEl, 'hidden', !wkSubText);
|
|
||||||
patchText(ratePopWkSubEl, wkSubText);
|
|
||||||
patchText(ratePopWkUsdEl, `≈ ${formatRateEqUsd(wkCap.totalEqWeeklyUsd)}`);
|
|
||||||
const hasWkTok =
|
|
||||||
Number.isFinite(Number(wkCap.totalEqWeeklyTokens)) &&
|
|
||||||
Number(wkCap.totalEqWeeklyTokens) > 0;
|
|
||||||
ratePopWkTokEl.hidden = !hasWkTok;
|
|
||||||
patchAttr(ratePopWkTokEl, 'hidden', !hasWkTok);
|
|
||||||
patchText(
|
|
||||||
ratePopWkTokEl,
|
|
||||||
hasWkTok ? `· ${formatTokens(Number(wkCap.totalEqWeeklyTokens))}` : ''
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
ratePopWkSummaryEl.hidden = true;
|
|
||||||
patchAttr(ratePopWkSummaryEl, 'hidden', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (ratePopBodyEl.firstChild) {
|
while (ratePopBodyEl.firstChild) {
|
||||||
ratePopBodyEl.removeChild(ratePopBodyEl.firstChild);
|
ratePopBodyEl.removeChild(ratePopBodyEl.firstChild);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,9 +204,6 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
|
|||||||
'quota.ratePopTitle': 'Estimated Burn Rates',
|
'quota.ratePopTitle': 'Estimated Burn Rates',
|
||||||
'quota.ratePopAccountScope': '{account}',
|
'quota.ratePopAccountScope': '{account}',
|
||||||
'quota.ratePopAccountCurrent': 'Current account',
|
'quota.ratePopAccountCurrent': 'Current account',
|
||||||
'quota.ratePopWkCapTitle': 'Est. Weekly Quota',
|
|
||||||
'quota.ratePopWkCapPrelim': '· est.',
|
|
||||||
'quota.ratePopWkCapPartial': '· {ready}/{total} pools',
|
|
||||||
'quota.ratePopPoolFallback': 'Pool average',
|
'quota.ratePopPoolFallback': 'Pool average',
|
||||||
'quota.ratePopEq5hLabel': '5h full',
|
'quota.ratePopEq5hLabel': '5h full',
|
||||||
'quota.ratePopEqWkLabel': 'Weekly full',
|
'quota.ratePopEqWkLabel': 'Weekly full',
|
||||||
@@ -215,7 +212,6 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
|
|||||||
'quota.ratePopPrelimSlope': 'slope est.',
|
'quota.ratePopPrelimSlope': 'slope est.',
|
||||||
'quota.ratePopPrelimCycle': 'cycle est.',
|
'quota.ratePopPrelimCycle': 'cycle est.',
|
||||||
'quota.ratePopEmpty': 'Not enough clean samples yet (unlocks at 2% weekly burn or 3 clean single-model steps).',
|
'quota.ratePopEmpty': 'Not enough clean samples yet (unlocks at 2% weekly burn or 3 clean single-model steps).',
|
||||||
'quota.ratePopNote': 'Measured from net burn & priced steps; lowest in pool = 1x. Account isolated.',
|
|
||||||
'quota.ratePopSharedBadge': 'Shared active',
|
'quota.ratePopSharedBadge': 'Shared active',
|
||||||
'quota.ratePopSharedBadgeTip': 'External pool usage seen within 15 min; new reservations display after verification',
|
'quota.ratePopSharedBadgeTip': 'External pool usage seen within 15 min; new reservations display after verification',
|
||||||
'quota.ratePopExternalDetail': 'Family group / other-device usage detected (~{detail} excluded from reservations)',
|
'quota.ratePopExternalDetail': 'Family group / other-device usage detected (~{detail} excluded from reservations)',
|
||||||
|
|||||||
@@ -204,9 +204,6 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
|
|||||||
'quota.ratePopTitle': '实测倍率预估',
|
'quota.ratePopTitle': '实测倍率预估',
|
||||||
'quota.ratePopAccountScope': '{account}',
|
'quota.ratePopAccountScope': '{account}',
|
||||||
'quota.ratePopAccountCurrent': '当前账号',
|
'quota.ratePopAccountCurrent': '当前账号',
|
||||||
'quota.ratePopWkCapTitle': '预测周额度',
|
|
||||||
'quota.ratePopWkCapPrelim': '· 初估',
|
|
||||||
'quota.ratePopWkCapPartial': '· {ready}/{total} 池',
|
|
||||||
'quota.ratePopPoolFallback': '池综合均值',
|
'quota.ratePopPoolFallback': '池综合均值',
|
||||||
'quota.ratePopEq5hLabel': '5h 满池',
|
'quota.ratePopEq5hLabel': '5h 满池',
|
||||||
'quota.ratePopEqWkLabel': '周限满池',
|
'quota.ratePopEqWkLabel': '周限满池',
|
||||||
@@ -215,7 +212,6 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
|
|||||||
'quota.ratePopPrelimSlope': '斜率初估',
|
'quota.ratePopPrelimSlope': '斜率初估',
|
||||||
'quota.ratePopPrelimCycle': '周期初估',
|
'quota.ratePopPrelimCycle': '周期初估',
|
||||||
'quota.ratePopEmpty': '暂未采集到足够的单模型干净样本(周限满 2% 或单模型满 3 次无抖动扣费后自动生成)。',
|
'quota.ratePopEmpty': '暂未采集到足够的单模型干净样本(周限满 2% 或单模型满 3 次无抖动扣费后自动生成)。',
|
||||||
'quota.ratePopNote': '按净消耗及精确计价折算,同池最省为 1x,按账号隔离。',
|
|
||||||
'quota.ratePopSharedBadge': '共享活跃',
|
'quota.ratePopSharedBadge': '共享活跃',
|
||||||
'quota.ratePopSharedBadgeTip': '最近 15 分钟内检测到同池外部消耗,新增预占将在二次验证后展示',
|
'quota.ratePopSharedBadgeTip': '最近 15 分钟内检测到同池外部消耗,新增预占将在二次验证后展示',
|
||||||
'quota.ratePopExternalDetail': '检测到家庭组 / 其他设备消耗(已排除约 {detail}),不计入预占',
|
'quota.ratePopExternalDetail': '检测到家庭组 / 其他设备消耗(已排除约 {detail}),不计入预占',
|
||||||
|
|||||||
@@ -840,20 +840,17 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[data-modern-ui="true"] .step-anomaly-tip-list,
|
[data-modern-ui="true"] .step-anomaly-tip-list,
|
||||||
[data-modern-ui="true"] .step-anomaly-tip-hint,
|
[data-modern-ui="true"] .step-anomaly-tip-hint {
|
||||||
[data-modern-ui="true"] .quota-rate-pop-head,
|
|
||||||
[data-modern-ui="true"] .quota-rate-wk-summary,
|
|
||||||
[data-modern-ui="true"] .quota-rate-pool-group + .quota-rate-pool-group,
|
|
||||||
[data-modern-ui="true"] .quota-rate-model-row + .quota-rate-model-row,
|
|
||||||
[data-modern-ui="true"] .quota-rate-pop-note,
|
|
||||||
:host([data-modern-ui="true"]) .quota-rate-pop-head,
|
|
||||||
:host([data-modern-ui="true"]) .quota-rate-wk-summary,
|
|
||||||
:host([data-modern-ui="true"]) .quota-rate-pool-group + .quota-rate-pool-group,
|
|
||||||
:host([data-modern-ui="true"]) .quota-rate-model-row + .quota-rate-model-row,
|
|
||||||
:host([data-modern-ui="true"]) .quota-rate-pop-note {
|
|
||||||
border-color: var(--modern-surface-hover);
|
border-color: var(--modern-surface-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[data-modern-ui="true"] .quota-rate-shared-badge,
|
||||||
|
[data-modern-ui="true"] .quota-rate-ext-banner,
|
||||||
|
:host([data-modern-ui="true"]) .quota-rate-shared-badge,
|
||||||
|
:host([data-modern-ui="true"]) .quota-rate-ext-banner {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
[data-modern-ui="true"] .trend-tooltip:not(.is-hm-top):not(.is-hm-bottom):not(.is-rich-breakdown) {
|
[data-modern-ui="true"] .trend-tooltip:not(.is-hm-top):not(.is-hm-bottom):not(.is-rich-breakdown) {
|
||||||
top: 2px;
|
top: 2px;
|
||||||
bottom: auto;
|
bottom: auto;
|
||||||
|
|||||||
@@ -406,36 +406,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.trend-peak-pill.is-ready {
|
.trend-peak-pill.is-ready {
|
||||||
transition:
|
transition: left 240ms cubic-bezier(0.22, 1, 0.36, 1);
|
||||||
left 240ms cubic-bezier(0.22, 1, 0.36, 1),
|
|
||||||
opacity 180ms cubic-bezier(0.22, 1, 0.36, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes anim-cons-axis-fade {
|
|
||||||
from {
|
|
||||||
opacity: 0.3;
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes anim-cons-stage-in {
|
|
||||||
from {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes anim-cons-content-switch {
|
|
||||||
from {
|
|
||||||
opacity: 0.52;
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes anim-cons-bar-grow {
|
@keyframes anim-cons-bar-grow {
|
||||||
@@ -447,25 +418,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.trend-x-axis.is-switching,
|
|
||||||
.trend-v-grid.is-switching {
|
|
||||||
animation: anim-cons-axis-fade 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
||||||
}
|
|
||||||
|
|
||||||
.trend-plot-stage.is-stage-entering,
|
|
||||||
.trend-heatmap-stage.is-stage-entering,
|
|
||||||
.cons-item-list.is-tab-entering,
|
|
||||||
.cons-ranking-empty.is-tab-entering {
|
|
||||||
animation: anim-cons-stage-in 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cons-unified-matrix.is-range-switching,
|
|
||||||
.cons-item-list.is-range-switching,
|
|
||||||
.cons-ranking-empty.is-range-switching {
|
|
||||||
animation: anim-cons-content-switch 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cons-item-list.is-tab-entering .progress-track,
|
|
||||||
.cons-item-list.is-bars-revealing .progress-track {
|
.cons-item-list.is-bars-revealing .progress-track {
|
||||||
transform-origin: left center;
|
transform-origin: left center;
|
||||||
animation: anim-cons-bar-grow 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
|
animation: anim-cons-bar-grow 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
|
||||||
@@ -478,15 +430,6 @@
|
|||||||
.trend-hm-cell {
|
.trend-hm-cell {
|
||||||
transition: none !important;
|
transition: none !important;
|
||||||
}
|
}
|
||||||
.trend-x-axis.is-switching,
|
|
||||||
.trend-v-grid.is-switching,
|
|
||||||
.trend-plot-stage.is-stage-entering,
|
|
||||||
.trend-heatmap-stage.is-stage-entering,
|
|
||||||
.cons-item-list.is-tab-entering,
|
|
||||||
.cons-ranking-empty.is-tab-entering,
|
|
||||||
.cons-unified-matrix.is-range-switching,
|
|
||||||
.cons-item-list.is-range-switching,
|
|
||||||
.cons-ranking-empty.is-range-switching,
|
|
||||||
.cons-item-list.is-bars-revealing .progress-track {
|
.cons-item-list.is-bars-revealing .progress-track {
|
||||||
animation: none !important;
|
animation: none !important;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -699,8 +699,6 @@
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
padding-bottom: 6px;
|
|
||||||
border-bottom: 1px solid var(--border-hairline);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.quota-rate-pop-title {
|
.quota-rate-pop-title {
|
||||||
@@ -721,65 +719,10 @@
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.quota-rate-wk-summary {
|
|
||||||
display: flex;
|
|
||||||
align-items: baseline;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 8px;
|
|
||||||
min-width: 0;
|
|
||||||
padding-bottom: 7px;
|
|
||||||
border-bottom: 1px solid var(--border-hairline);
|
|
||||||
}
|
|
||||||
|
|
||||||
.quota-rate-wk-summary[hidden] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.quota-rate-wk-k {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: baseline;
|
|
||||||
gap: 5px;
|
|
||||||
min-width: 0;
|
|
||||||
font-size: var(--fs-sm);
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.quota-rate-wk-sub {
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
font-size: var(--fs-2xs);
|
|
||||||
font-weight: 400;
|
|
||||||
color: var(--text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.quota-rate-wk-v {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: baseline;
|
|
||||||
gap: 4px;
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
white-space: nowrap;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.quota-rate-wk-usd {
|
|
||||||
font-size: var(--fs-md);
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.quota-rate-wk-tok {
|
|
||||||
font-size: var(--fs-xs);
|
|
||||||
font-weight: 400;
|
|
||||||
color: var(--text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.quota-rate-pop-body {
|
.quota-rate-pop-body {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 8px;
|
gap: 10px;
|
||||||
max-height: min(300px, 58vh);
|
max-height: min(300px, 58vh);
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
@@ -792,11 +735,6 @@
|
|||||||
gap: 5px;
|
gap: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.quota-rate-pool-group + .quota-rate-pool-group {
|
|
||||||
padding-top: 7px;
|
|
||||||
border-top: 1px solid var(--border-hairline);
|
|
||||||
}
|
|
||||||
|
|
||||||
.quota-rate-pool-head {
|
.quota-rate-pool-head {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -845,7 +783,7 @@
|
|||||||
.quota-rate-model-list {
|
.quota-rate-model-list {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 7px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.quota-rate-model-row {
|
.quota-rate-model-row {
|
||||||
@@ -855,11 +793,6 @@
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.quota-rate-model-row + .quota-rate-model-row {
|
|
||||||
padding-top: 7px;
|
|
||||||
border-top: 1px solid var(--border-hairline);
|
|
||||||
}
|
|
||||||
|
|
||||||
.quota-rate-row-top {
|
.quota-rate-row-top {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: baseline;
|
align-items: baseline;
|
||||||
@@ -960,14 +893,6 @@
|
|||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.quota-rate-pop-note {
|
|
||||||
padding-top: 6px;
|
|
||||||
border-top: 1px solid var(--border-hairline);
|
|
||||||
font-size: var(--fs-2xs);
|
|
||||||
line-height: 1.45;
|
|
||||||
color: var(--text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --- 4. 上下文双列图例网格 (Context 10-Channel Legend Grid) --- */
|
/* --- 4. 上下文双列图例网格 (Context 10-Channel Legend Grid) --- */
|
||||||
.ctx-legend-grid {
|
.ctx-legend-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
|||||||
@@ -406,11 +406,7 @@ export const ConsumptionView = defineComponent({
|
|||||||
let lastAnimatedRankingKey = '';
|
let lastAnimatedRankingKey = '';
|
||||||
let lastAnimatedSortSig = '';
|
let lastAnimatedSortSig = '';
|
||||||
const consAnimTimers = new Map();
|
const consAnimTimers = new Map();
|
||||||
const TRANSIENT_CONS_CLASSES = [
|
const TRANSIENT_CONS_CLASSES = ['is-bars-revealing'];
|
||||||
'is-range-switching',
|
|
||||||
'is-tab-entering',
|
|
||||||
'is-bars-revealing',
|
|
||||||
];
|
|
||||||
|
|
||||||
function cleanupConsAnim(el) {
|
function cleanupConsAnim(el) {
|
||||||
const rec = consAnimTimers.get(el);
|
const rec = consAnimTimers.get(el);
|
||||||
@@ -2228,13 +2224,7 @@ export const ConsumptionView = defineComponent({
|
|||||||
!tabSwitched &&
|
!tabSwitched &&
|
||||||
nextSortSig !== lastAnimatedSortSig;
|
nextSortSig !== lastAnimatedSortSig;
|
||||||
|
|
||||||
if (rangeSwitched) {
|
if (tabSwitched || sortSwitched) {
|
||||||
triggerConsAnim(unifiedMatrixEl, 'is-range-switching');
|
|
||||||
triggerConsAnim(activeRankingEl, 'is-range-switching');
|
|
||||||
triggerConsAnim(sourcesListEl, 'is-range-switching');
|
|
||||||
} else if (tabSwitched) {
|
|
||||||
triggerConsAnim(activeRankingEl, 'is-tab-entering');
|
|
||||||
} else if (sortSwitched) {
|
|
||||||
triggerConsAnim(activeRankingEl, 'is-bars-revealing');
|
triggerConsAnim(activeRankingEl, 'is-bars-revealing');
|
||||||
}
|
}
|
||||||
if (!hasCompletedInitialDraw) {
|
if (!hasCompletedInitialDraw) {
|
||||||
|
|||||||
+11
-146
@@ -2417,8 +2417,6 @@ html[data-standalone="true"] .app-shell {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
padding-bottom: 6px;
|
|
||||||
border-bottom: 1px solid var(--border-hairline);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.quota-rate-pop-title {
|
.quota-rate-pop-title {
|
||||||
@@ -2439,65 +2437,10 @@ html[data-standalone="true"] .app-shell {
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.quota-rate-wk-summary {
|
|
||||||
display: flex;
|
|
||||||
align-items: baseline;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 8px;
|
|
||||||
min-width: 0;
|
|
||||||
padding-bottom: 7px;
|
|
||||||
border-bottom: 1px solid var(--border-hairline);
|
|
||||||
}
|
|
||||||
|
|
||||||
.quota-rate-wk-summary[hidden] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.quota-rate-wk-k {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: baseline;
|
|
||||||
gap: 5px;
|
|
||||||
min-width: 0;
|
|
||||||
font-size: var(--fs-sm);
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.quota-rate-wk-sub {
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
font-size: var(--fs-2xs);
|
|
||||||
font-weight: 400;
|
|
||||||
color: var(--text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.quota-rate-wk-v {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: baseline;
|
|
||||||
gap: 4px;
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
white-space: nowrap;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.quota-rate-wk-usd {
|
|
||||||
font-size: var(--fs-md);
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.quota-rate-wk-tok {
|
|
||||||
font-size: var(--fs-xs);
|
|
||||||
font-weight: 400;
|
|
||||||
color: var(--text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.quota-rate-pop-body {
|
.quota-rate-pop-body {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 8px;
|
gap: 10px;
|
||||||
max-height: min(300px, 58vh);
|
max-height: min(300px, 58vh);
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
@@ -2510,11 +2453,6 @@ html[data-standalone="true"] .app-shell {
|
|||||||
gap: 5px;
|
gap: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.quota-rate-pool-group + .quota-rate-pool-group {
|
|
||||||
padding-top: 7px;
|
|
||||||
border-top: 1px solid var(--border-hairline);
|
|
||||||
}
|
|
||||||
|
|
||||||
.quota-rate-pool-head {
|
.quota-rate-pool-head {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -2563,7 +2501,7 @@ html[data-standalone="true"] .app-shell {
|
|||||||
.quota-rate-model-list {
|
.quota-rate-model-list {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 7px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.quota-rate-model-row {
|
.quota-rate-model-row {
|
||||||
@@ -2573,11 +2511,6 @@ html[data-standalone="true"] .app-shell {
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.quota-rate-model-row + .quota-rate-model-row {
|
|
||||||
padding-top: 7px;
|
|
||||||
border-top: 1px solid var(--border-hairline);
|
|
||||||
}
|
|
||||||
|
|
||||||
.quota-rate-row-top {
|
.quota-rate-row-top {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: baseline;
|
align-items: baseline;
|
||||||
@@ -2678,14 +2611,6 @@ html[data-standalone="true"] .app-shell {
|
|||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.quota-rate-pop-note {
|
|
||||||
padding-top: 6px;
|
|
||||||
border-top: 1px solid var(--border-hairline);
|
|
||||||
font-size: var(--fs-2xs);
|
|
||||||
line-height: 1.45;
|
|
||||||
color: var(--text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --- 4. 上下文双列图例网格 (Context 10-Channel Legend Grid) --- */
|
/* --- 4. 上下文双列图例网格 (Context 10-Channel Legend Grid) --- */
|
||||||
.ctx-legend-grid {
|
.ctx-legend-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
@@ -3280,36 +3205,7 @@ html[data-standalone="true"] .app-shell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.trend-peak-pill.is-ready {
|
.trend-peak-pill.is-ready {
|
||||||
transition:
|
transition: left 240ms cubic-bezier(0.22, 1, 0.36, 1);
|
||||||
left 240ms cubic-bezier(0.22, 1, 0.36, 1),
|
|
||||||
opacity 180ms cubic-bezier(0.22, 1, 0.36, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes anim-cons-axis-fade {
|
|
||||||
from {
|
|
||||||
opacity: 0.3;
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes anim-cons-stage-in {
|
|
||||||
from {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes anim-cons-content-switch {
|
|
||||||
from {
|
|
||||||
opacity: 0.52;
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes anim-cons-bar-grow {
|
@keyframes anim-cons-bar-grow {
|
||||||
@@ -3321,25 +3217,6 @@ html[data-standalone="true"] .app-shell {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.trend-x-axis.is-switching,
|
|
||||||
.trend-v-grid.is-switching {
|
|
||||||
animation: anim-cons-axis-fade 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
||||||
}
|
|
||||||
|
|
||||||
.trend-plot-stage.is-stage-entering,
|
|
||||||
.trend-heatmap-stage.is-stage-entering,
|
|
||||||
.cons-item-list.is-tab-entering,
|
|
||||||
.cons-ranking-empty.is-tab-entering {
|
|
||||||
animation: anim-cons-stage-in 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cons-unified-matrix.is-range-switching,
|
|
||||||
.cons-item-list.is-range-switching,
|
|
||||||
.cons-ranking-empty.is-range-switching {
|
|
||||||
animation: anim-cons-content-switch 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cons-item-list.is-tab-entering .progress-track,
|
|
||||||
.cons-item-list.is-bars-revealing .progress-track {
|
.cons-item-list.is-bars-revealing .progress-track {
|
||||||
transform-origin: left center;
|
transform-origin: left center;
|
||||||
animation: anim-cons-bar-grow 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
|
animation: anim-cons-bar-grow 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
|
||||||
@@ -3352,15 +3229,6 @@ html[data-standalone="true"] .app-shell {
|
|||||||
.trend-hm-cell {
|
.trend-hm-cell {
|
||||||
transition: none !important;
|
transition: none !important;
|
||||||
}
|
}
|
||||||
.trend-x-axis.is-switching,
|
|
||||||
.trend-v-grid.is-switching,
|
|
||||||
.trend-plot-stage.is-stage-entering,
|
|
||||||
.trend-heatmap-stage.is-stage-entering,
|
|
||||||
.cons-item-list.is-tab-entering,
|
|
||||||
.cons-ranking-empty.is-tab-entering,
|
|
||||||
.cons-unified-matrix.is-range-switching,
|
|
||||||
.cons-item-list.is-range-switching,
|
|
||||||
.cons-ranking-empty.is-range-switching,
|
|
||||||
.cons-item-list.is-bars-revealing .progress-track {
|
.cons-item-list.is-bars-revealing .progress-track {
|
||||||
animation: none !important;
|
animation: none !important;
|
||||||
}
|
}
|
||||||
@@ -8860,20 +8728,17 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[data-modern-ui="true"] .step-anomaly-tip-list,
|
[data-modern-ui="true"] .step-anomaly-tip-list,
|
||||||
[data-modern-ui="true"] .step-anomaly-tip-hint,
|
[data-modern-ui="true"] .step-anomaly-tip-hint {
|
||||||
[data-modern-ui="true"] .quota-rate-pop-head,
|
|
||||||
[data-modern-ui="true"] .quota-rate-wk-summary,
|
|
||||||
[data-modern-ui="true"] .quota-rate-pool-group + .quota-rate-pool-group,
|
|
||||||
[data-modern-ui="true"] .quota-rate-model-row + .quota-rate-model-row,
|
|
||||||
[data-modern-ui="true"] .quota-rate-pop-note,
|
|
||||||
:host([data-modern-ui="true"]) .quota-rate-pop-head,
|
|
||||||
:host([data-modern-ui="true"]) .quota-rate-wk-summary,
|
|
||||||
:host([data-modern-ui="true"]) .quota-rate-pool-group + .quota-rate-pool-group,
|
|
||||||
:host([data-modern-ui="true"]) .quota-rate-model-row + .quota-rate-model-row,
|
|
||||||
:host([data-modern-ui="true"]) .quota-rate-pop-note {
|
|
||||||
border-color: var(--modern-surface-hover);
|
border-color: var(--modern-surface-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[data-modern-ui="true"] .quota-rate-shared-badge,
|
||||||
|
[data-modern-ui="true"] .quota-rate-ext-banner,
|
||||||
|
:host([data-modern-ui="true"]) .quota-rate-shared-badge,
|
||||||
|
:host([data-modern-ui="true"]) .quota-rate-ext-banner {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
[data-modern-ui="true"] .trend-tooltip:not(.is-hm-top):not(.is-hm-bottom):not(.is-rich-breakdown) {
|
[data-modern-ui="true"] .trend-tooltip:not(.is-hm-top):not(.is-hm-bottom):not(.is-rich-breakdown) {
|
||||||
top: 2px;
|
top: 2px;
|
||||||
bottom: auto;
|
bottom: auto;
|
||||||
|
|||||||
@@ -1673,3 +1673,204 @@ test('xlsxBuilder enforces 32,767 UTF-16 cell limit without splitting surrogate
|
|||||||
const cellA3 = cellMatches[1][1];
|
const cellA3 = cellMatches[1][1];
|
||||||
assert.equal(cellA3, 'ok\uFFFDmid\uFFFDend');
|
assert.equal(cellA3, 'ok\uFFFDmid\uFFFDend');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('ConsumptionView and TrendAreaChart patch text DOM nodes in-place without opacity flicker classes on date range switches', async () => {
|
||||||
|
const consCss = fs.readFileSync(
|
||||||
|
fileURLToPath(new URL('../src/styles/views-consumption.css', import.meta.url)),
|
||||||
|
'utf8'
|
||||||
|
);
|
||||||
|
for (const bannedToken of [
|
||||||
|
'is-range-switching',
|
||||||
|
'is-tab-entering',
|
||||||
|
'is-switching',
|
||||||
|
'is-stage-entering',
|
||||||
|
'anim-cons-content-switch',
|
||||||
|
'anim-cons-axis-fade',
|
||||||
|
'anim-cons-stage-in',
|
||||||
|
]) {
|
||||||
|
assert.equal(
|
||||||
|
consCss.includes(bannedToken),
|
||||||
|
false,
|
||||||
|
`Expected views-consumption.css not to contain text-opacity flicker rule "${bannedToken}"`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { createMockDom } = await import('./mock-dom.mjs');
|
||||||
|
const prevDoc = globalThis.document;
|
||||||
|
const prevWin = globalThis.window;
|
||||||
|
const { document } = createMockDom();
|
||||||
|
globalThis.document = document;
|
||||||
|
globalThis.window = {
|
||||||
|
location: { origin: 'http://127.0.0.1:41234', href: 'http://127.0.0.1:41234/' },
|
||||||
|
getComputedStyle: () => ({ overflow: 'visible', overflowX: 'visible', overflowY: 'visible' }),
|
||||||
|
matchMedia: () => ({ matches: false }),
|
||||||
|
requestAnimationFrame: (cb) => setTimeout(() => cb(performance.now()), 0),
|
||||||
|
cancelAnimationFrame: (id) => clearTimeout(id),
|
||||||
|
addEventListener() {},
|
||||||
|
removeEventListener() {},
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { ConsumptionView } = await import('../src/views/ConsumptionView.js');
|
||||||
|
const { telemetryStore } = await import('../src/store/telemetryStore.js');
|
||||||
|
const { uiStore } = await import('../src/store/uiStore.js');
|
||||||
|
const prevTelState = { ...telemetryStore.getState() };
|
||||||
|
const prevUiState = { ...uiStore.getState() };
|
||||||
|
|
||||||
|
uiStore.setState(
|
||||||
|
{ activeView: 'consumption', monitorVisible: true, settingsOpen: false },
|
||||||
|
{ sync: true }
|
||||||
|
);
|
||||||
|
const view = ConsumptionView();
|
||||||
|
document.body.appendChild(view.el);
|
||||||
|
|
||||||
|
const makeRangePayload = (rangeKey, tokBase, labels) => ({
|
||||||
|
settings: { modelDisplayMode: 'short', showUpstreamModel: false, orchestratorIdMode: 'label' },
|
||||||
|
consumption: {
|
||||||
|
revision: 0,
|
||||||
|
selectedRange: {
|
||||||
|
key: rangeKey,
|
||||||
|
label: rangeKey,
|
||||||
|
startMs: 1_760_000_000_000,
|
||||||
|
endMs: 1_760_086_400_000,
|
||||||
|
},
|
||||||
|
account: {
|
||||||
|
totalTokens: tokBase,
|
||||||
|
inputTokens: Math.round(tokBase * 0.2),
|
||||||
|
cacheReadTokens: Math.round(tokBase * 0.7),
|
||||||
|
outputTokens: Math.round(tokBase * 0.1),
|
||||||
|
responseTokens: Math.round(tokBase * 0.07),
|
||||||
|
thinkingTokens: Math.round(tokBase * 0.03),
|
||||||
|
calls: 12,
|
||||||
|
costUsd: 1.25,
|
||||||
|
savedCostUsd: 0.85,
|
||||||
|
cacheHitPct: 77.8,
|
||||||
|
},
|
||||||
|
trendSeries: labels.map((lbl, idx) => ({
|
||||||
|
index: idx,
|
||||||
|
startMs: 1_760_000_000_000 + idx * 3_600_000,
|
||||||
|
endMs: 1_760_000_000_000 + (idx + 1) * 3_600_000,
|
||||||
|
granularity: labels.length > 90 ? 'day' : 'hour',
|
||||||
|
label: lbl,
|
||||||
|
fullLabel: lbl,
|
||||||
|
tokens: 1_000 * (idx + 1),
|
||||||
|
calls: 1,
|
||||||
|
costUsd: 0.05,
|
||||||
|
})),
|
||||||
|
sourcesBreakdown: [
|
||||||
|
{
|
||||||
|
name: 'antigravity',
|
||||||
|
label: 'Antigravity IDE',
|
||||||
|
totalTokens: tokBase,
|
||||||
|
calls: 12,
|
||||||
|
costUsd: 1.25,
|
||||||
|
models: [{ label: 'Claude Opus 4.6', shortName: 'Claude Opus 4.6', totalTokens: tokBase, calls: 12 }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
topConversations: [],
|
||||||
|
topWorkspaces: [],
|
||||||
|
monthlyYear: 2026,
|
||||||
|
monthlySeries: Array.from({ length: 12 }, (_, m) => ({
|
||||||
|
month: m + 1,
|
||||||
|
totalTokens: m === 10 ? tokBase : 0,
|
||||||
|
costUsd: m === 10 ? 1.25 : 0,
|
||||||
|
calls: m === 10 ? 12 : 0,
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
modelBreakdown: [
|
||||||
|
{
|
||||||
|
label: 'Claude Opus 4.6',
|
||||||
|
shortName: 'Claude Opus 4.6',
|
||||||
|
totalTokens: tokBase,
|
||||||
|
inputTokens: Math.round(tokBase * 0.2),
|
||||||
|
cacheReadTokens: Math.round(tokBase * 0.7),
|
||||||
|
responseTokens: Math.round(tokBase * 0.07),
|
||||||
|
thinkingTokens: Math.round(tokBase * 0.03),
|
||||||
|
outputTokens: Math.round(tokBase * 0.1),
|
||||||
|
calls: 12,
|
||||||
|
costUsd: 1.25,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
telemetryStore.setState(
|
||||||
|
{
|
||||||
|
selectedTimeRange: 'today',
|
||||||
|
telemetry: makeRangePayload('today', 100_000, ['00:00', '06:00', '12:00', '18:00']),
|
||||||
|
},
|
||||||
|
{ sync: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
const matrixEl = view.el.querySelector('.cons-unified-matrix');
|
||||||
|
const heroNumEl = view.el.querySelector('.cons-hero-num');
|
||||||
|
const modelRowEl = view.el.querySelector('.cons-item-row');
|
||||||
|
const modelTitleTextEl = modelRowEl.querySelector('.cons-row-title-text');
|
||||||
|
const sourceRowEl = view.el.querySelector('.cons-source-row');
|
||||||
|
const xAxisEl = view.el.querySelector('.trend-x-axis');
|
||||||
|
const initialTicks = xAxisEl.querySelectorAll('.trend-x-tick');
|
||||||
|
assert.equal(initialTicks.length, 4);
|
||||||
|
|
||||||
|
// Switch to 7d: same model, same source, updated numbers & tick labels -> all DOM nodes reused in-place, zero opacity flicker classes
|
||||||
|
telemetryStore.setState(
|
||||||
|
{
|
||||||
|
selectedTimeRange: '7d',
|
||||||
|
telemetry: makeRangePayload('7d', 450_000, ['11/18', '11/20', '11/22', '11/24']),
|
||||||
|
},
|
||||||
|
{ sync: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.equal(view.el.querySelector('.cons-hero-num'), heroNumEl, 'Hero token element persists');
|
||||||
|
assert.equal(view.el.querySelector('.cons-item-row'), modelRowEl, 'Model row element persists');
|
||||||
|
assert.equal(
|
||||||
|
view.el.querySelector('.cons-item-row .cons-row-title-text'),
|
||||||
|
modelTitleTextEl,
|
||||||
|
'Model title text node persists'
|
||||||
|
);
|
||||||
|
assert.equal(view.el.querySelector('.cons-source-row'), sourceRowEl, 'Source row element persists');
|
||||||
|
|
||||||
|
const nextTicks = xAxisEl.querySelectorAll('.trend-x-tick');
|
||||||
|
assert.equal(nextTicks.length, 4);
|
||||||
|
for (let i = 0; i < 4; i++) {
|
||||||
|
assert.equal(nextTicks[i], initialTicks[i], `Trend X-axis tick #${i} reused in-place`);
|
||||||
|
}
|
||||||
|
assert.equal(nextTicks[0].textContent, '11/18');
|
||||||
|
|
||||||
|
for (const cls of ['is-range-switching', 'is-tab-entering', 'is-switching', 'is-stage-entering']) {
|
||||||
|
assert.equal(matrixEl.classList.contains(cls), false);
|
||||||
|
assert.equal(modelRowEl.parentNode.classList.contains(cls), false);
|
||||||
|
assert.equal(sourceRowEl.parentNode.classList.contains(cls), false);
|
||||||
|
assert.equal(xAxisEl.classList.contains(cls), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Switch to >90d heatmap and update counts -> month labels and grid cells reuse pooled nodes in-place
|
||||||
|
const hmLabelsA = Array.from({ length: 95 }, (_, idx) => `08/${String((idx % 28) + 1).padStart(2, '0')}`);
|
||||||
|
telemetryStore.setState(
|
||||||
|
{
|
||||||
|
selectedTimeRange: 'all',
|
||||||
|
telemetry: makeRangePayload('all', 900_000, hmLabelsA),
|
||||||
|
},
|
||||||
|
{ sync: true }
|
||||||
|
);
|
||||||
|
const hmGridEl = view.el.querySelector('.trend-hm-grid');
|
||||||
|
const firstGridCells = [...hmGridEl.children];
|
||||||
|
assert.ok(firstGridCells.length >= 95);
|
||||||
|
|
||||||
|
telemetryStore.setState(
|
||||||
|
{
|
||||||
|
selectedTimeRange: 'all',
|
||||||
|
telemetry: makeRangePayload('all', 950_000, hmLabelsA),
|
||||||
|
},
|
||||||
|
{ sync: true }
|
||||||
|
);
|
||||||
|
const secondGridCells = [...hmGridEl.children];
|
||||||
|
assert.equal(secondGridCells.length, firstGridCells.length);
|
||||||
|
assert.equal(secondGridCells[10], firstGridCells[10], 'Heatmap cell DOM node reused in-place');
|
||||||
|
|
||||||
|
view.destroy();
|
||||||
|
telemetryStore.setState(prevTelState, { sync: true });
|
||||||
|
uiStore.setState(prevUiState, { sync: true });
|
||||||
|
} finally {
|
||||||
|
globalThis.document = prevDoc;
|
||||||
|
globalThis.window = prevWin;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
@@ -2208,7 +2208,7 @@ test('quota-reservation: 3-tier hybrid estimator unlocks cycle_ratio & anchor_sl
|
|||||||
assert.equal(pAfterRestart.get('Claude & GPT').rateEstimate?.eqFullWeeklyTokens, 12_500_000);
|
assert.equal(pAfterRestart.get('Claude & GPT').rateEstimate?.eqFullWeeklyTokens, 12_500_000);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('QuotaPoolsWidget ? popover renders Est. Weekly Quota summary row, preliminary labels, and full-pool token references', async () => {
|
test('QuotaPoolsWidget ? popover renders preliminary labels and full-pool token references without weekly summary row, footer note, or divider rules', async () => {
|
||||||
const { document } = createMockDom();
|
const { document } = createMockDom();
|
||||||
const origDocument = globalThis.document;
|
const origDocument = globalThis.document;
|
||||||
const origWindow = globalThis.window;
|
const origWindow = globalThis.window;
|
||||||
@@ -2231,8 +2231,9 @@ test('QuotaPoolsWidget ? popover renders Est. Weekly Quota summary row, prelimin
|
|||||||
const widget = QuotaPoolsWidget();
|
const widget = QuotaPoolsWidget();
|
||||||
const popover = widget.refs.ratePopoverEl;
|
const popover = widget.refs.ratePopoverEl;
|
||||||
|
|
||||||
// 1. Collecting state: top weekly summary hidden until at least 1 pool has a weekly capacity estimate
|
// 1. Minimalist layout: no redundant weekly summary row or footer note element
|
||||||
assert.equal(popover.querySelector('.quota-rate-wk-summary')?.hidden, true);
|
assert.equal(popover.querySelector('.quota-rate-wk-summary'), null);
|
||||||
|
assert.equal(popover.querySelector('.quota-rate-pop-note'), null);
|
||||||
|
|
||||||
// 2. Partial + Preliminary state (Claude ready via anchor_slope, Gemini still collecting)
|
// 2. Partial + Preliminary state (Claude ready via anchor_slope, Gemini still collecting)
|
||||||
widget.refs.update({
|
widget.refs.update({
|
||||||
@@ -2280,9 +2281,8 @@ test('QuotaPoolsWidget ? popover renders Est. Weekly Quota summary row, prelimin
|
|||||||
minuteTick: 1,
|
minuteTick: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
const wkSummary = popover.querySelector('.quota-rate-wk-summary');
|
assert.doesNotMatch(popover.textContent, /预测周额度/);
|
||||||
assert.equal(wkSummary.hidden, false);
|
assert.doesNotMatch(popover.textContent, /同池最省/);
|
||||||
assert.match(wkSummary.textContent, /预测周额度.*· 1\/2 池.*≈ \$48.*· 9\.9M/);
|
|
||||||
const fallbackRow = popover.querySelector('.quota-rate-model-row.is-fallback');
|
const fallbackRow = popover.querySelector('.quota-rate-model-row.is-fallback');
|
||||||
assert.ok(fallbackRow);
|
assert.ok(fallbackRow);
|
||||||
assert.match(fallbackRow.textContent, /池综合均值/);
|
assert.match(fallbackRow.textContent, /池综合均值/);
|
||||||
@@ -2292,7 +2292,7 @@ test('QuotaPoolsWidget ? popover renders Est. Weekly Quota summary row, prelimin
|
|||||||
const wkRowLeft = widget.refs.poolsListEl.querySelectorAll('.quota-win-left')[1];
|
const wkRowLeft = widget.refs.poolsListEl.querySelectorAll('.quota-win-left')[1];
|
||||||
assert.match(wkRowLeft.getAttribute('title') || '', /满池约 \$48 \(9\.9M\)/);
|
assert.match(wkRowLeft.getAttribute('title') || '', /满池约 \$48 \(9\.9M\)/);
|
||||||
|
|
||||||
// 3. All pools calibrated & ready: sums USD + Tokens cleanly ($50 + $35 = $85, 10.3M + 14.2M = 24.5M)
|
// 3. All pools calibrated & ready: renders per-pool model & fallback cards cleanly
|
||||||
const allReadyData = {
|
const allReadyData = {
|
||||||
account: { email: 'sjee80343@gmail.com', tierName: 'Google AI Pro' },
|
account: { email: 'sjee80343@gmail.com', tierName: 'Google AI Pro' },
|
||||||
quotas: {
|
quotas: {
|
||||||
@@ -2367,33 +2367,21 @@ test('QuotaPoolsWidget ? popover renders Est. Weekly Quota summary row, prelimin
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
widget.refs.update({ data: allReadyData, minuteTick: 2 });
|
widget.refs.update({ data: allReadyData, minuteTick: 2 });
|
||||||
assert.equal(wkSummary.hidden, false);
|
assert.match(popover.textContent, /Claude Sonnet 4\.6.*5h 满池≈ \$50· 10\.3M.*周限满池≈ \$50· 10\.3M/);
|
||||||
assert.equal(wkSummary.querySelector('.quota-rate-wk-sub').hidden, true);
|
assert.match(popover.textContent, /Gemini.*池综合均值.*5h 满池≈ \$35· 14\.2M/);
|
||||||
assert.match(wkSummary.textContent, /预测周额度≈ \$85· 24\.5M/);
|
|
||||||
|
|
||||||
// 4. English locale switch updates weekly summary, model cards, and row title tooltip without reload
|
// 4. English locale switch updates model cards and row title tooltip without reload
|
||||||
setI18nLanguage('en-US');
|
setI18nLanguage('en-US');
|
||||||
widget.refs.update({ data: allReadyData, minuteTick: 3 });
|
widget.refs.update({ data: allReadyData, minuteTick: 3 });
|
||||||
assert.match(wkSummary.textContent, /Est\. Weekly Quota≈ \$85· 24\.5M/);
|
assert.doesNotMatch(popover.textContent, /Est\. Weekly Quota/);
|
||||||
|
assert.doesNotMatch(popover.textContent, /lowest in pool/);
|
||||||
|
assert.match(popover.textContent, /5h full≈ \$50· 10\.3M.*Weekly full≈ \$50· 10\.3M/);
|
||||||
assert.match(
|
assert.match(
|
||||||
widget.refs.poolsListEl.querySelectorAll('.quota-win-left')[1].getAttribute('title') || '',
|
widget.refs.poolsListEl.querySelectorAll('.quota-win-left')[1].getAttribute('title') || '',
|
||||||
/Full ~\$50 \(10\.3M\)/
|
/Full ~\$50 \(10\.3M\)/
|
||||||
);
|
);
|
||||||
|
|
||||||
// 5. Custom local weekly budget mode hides official weekly capacity summary
|
// 5. Pool with 5h-only model card + pool-level preliminary weekly estimate renders supplementary weekly fallback row
|
||||||
widget.refs.update({
|
|
||||||
data: {
|
|
||||||
...allReadyData,
|
|
||||||
quotas: {
|
|
||||||
...allReadyData.quotas,
|
|
||||||
weekly: { isOfficial: false },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
minuteTick: 4,
|
|
||||||
});
|
|
||||||
assert.equal(wkSummary.hidden, true);
|
|
||||||
|
|
||||||
// 6. Pool with 5h-only model card + pool-level preliminary weekly estimate renders supplementary weekly fallback row
|
|
||||||
setI18nLanguage('zh-CN');
|
setI18nLanguage('zh-CN');
|
||||||
widget.refs.update({
|
widget.refs.update({
|
||||||
data: {
|
data: {
|
||||||
@@ -2443,8 +2431,6 @@ test('QuotaPoolsWidget ? popover renders Est. Weekly Quota summary row, prelimin
|
|||||||
},
|
},
|
||||||
minuteTick: 5,
|
minuteTick: 5,
|
||||||
});
|
});
|
||||||
assert.equal(wkSummary.hidden, false);
|
|
||||||
assert.match(wkSummary.textContent, /预测周额度.*· 初估.*≈ \$600.*· 200\.0M/);
|
|
||||||
const mixedRows = popover.querySelectorAll('.quota-rate-model-row');
|
const mixedRows = popover.querySelectorAll('.quota-rate-model-row');
|
||||||
assert.equal(mixedRows.length, 2, 'renders 5h model card + supplementary pool weekly fallback row');
|
assert.equal(mixedRows.length, 2, 'renders 5h model card + supplementary pool weekly fallback row');
|
||||||
assert.match(mixedRows[0].textContent, /Gemini 3\.1 Pro.*5h 满池≈ \$150/);
|
assert.match(mixedRows[0].textContent, /Gemini 3\.1 Pro.*5h 满池≈ \$150/);
|
||||||
|
|||||||
Reference in New Issue
Block a user