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:
+133
-276
@@ -1463,9 +1463,6 @@ const I18N_MESSAGES_ZH_CN = Object.freeze({
|
||||
'quota.ratePopTitle': '实测倍率预估',
|
||||
'quota.ratePopAccountScope': '{account}',
|
||||
'quota.ratePopAccountCurrent': '当前账号',
|
||||
'quota.ratePopWkCapTitle': '预测周额度',
|
||||
'quota.ratePopWkCapPrelim': '· 初估',
|
||||
'quota.ratePopWkCapPartial': '· {ready}/{total} 池',
|
||||
'quota.ratePopPoolFallback': '池综合均值',
|
||||
'quota.ratePopEq5hLabel': '5h 满池',
|
||||
'quota.ratePopEqWkLabel': '周限满池',
|
||||
@@ -1474,7 +1471,6 @@ const I18N_MESSAGES_ZH_CN = Object.freeze({
|
||||
'quota.ratePopPrelimSlope': '斜率初估',
|
||||
'quota.ratePopPrelimCycle': '周期初估',
|
||||
'quota.ratePopEmpty': '暂未采集到足够的单模型干净样本(周限满 2% 或单模型满 3 次无抖动扣费后自动生成)。',
|
||||
'quota.ratePopNote': '按净消耗及精确计价折算,同池最省为 1x,按账号隔离。',
|
||||
'quota.ratePopSharedBadge': '共享活跃',
|
||||
'quota.ratePopSharedBadgeTip': '最近 15 分钟内检测到同池外部消耗,新增预占将在二次验证后展示',
|
||||
'quota.ratePopExternalDetail': '检测到家庭组 / 其他设备消耗(已排除约 {detail}),不计入预占',
|
||||
@@ -2366,9 +2362,6 @@ const I18N_MESSAGES_EN_US = Object.freeze({
|
||||
'quota.ratePopTitle': 'Estimated Burn Rates',
|
||||
'quota.ratePopAccountScope': '{account}',
|
||||
'quota.ratePopAccountCurrent': 'Current account',
|
||||
'quota.ratePopWkCapTitle': 'Est. Weekly Quota',
|
||||
'quota.ratePopWkCapPrelim': '· est.',
|
||||
'quota.ratePopWkCapPartial': '· {ready}/{total} pools',
|
||||
'quota.ratePopPoolFallback': 'Pool average',
|
||||
'quota.ratePopEq5hLabel': '5h full',
|
||||
'quota.ratePopEqWkLabel': 'Weekly full',
|
||||
@@ -2377,7 +2370,6 @@ const I18N_MESSAGES_EN_US = Object.freeze({
|
||||
'quota.ratePopPrelimSlope': 'slope est.',
|
||||
'quota.ratePopPrelimCycle': 'cycle est.',
|
||||
'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.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)',
|
||||
@@ -14244,8 +14236,6 @@ function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
||||
let hoveredCellEl = null;
|
||||
let lastPointer = null;
|
||||
let lastRenderSig = '';
|
||||
let lastTickLabelsSig = '';
|
||||
let hasRenderedOnce = false;
|
||||
let hasRenderedLineOnce = false;
|
||||
let peakReadyArmed = false;
|
||||
let peakReadyRaf = 0;
|
||||
@@ -14253,40 +14243,13 @@ function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
||||
let morphRafId = 0;
|
||||
let committedSegs = [];
|
||||
let liveMorphSegs = null;
|
||||
const transientClassTimers = new Map();
|
||||
const vGridLinePool = [];
|
||||
const xAxisTickPool = [];
|
||||
const hmMonthPool = [];
|
||||
const hmCellPool = [];
|
||||
|
||||
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() {
|
||||
if (
|
||||
morphRafId &&
|
||||
@@ -14912,7 +14875,6 @@ function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
||||
cancelTipTrackRaf();
|
||||
cancelCurveMorph();
|
||||
cancelPeakReadyRaf();
|
||||
clearAllTransientTimers();
|
||||
plotStage.removeEventListener('mousemove', handlePointerMove);
|
||||
plotStage.removeEventListener('click', handleLineClick);
|
||||
plotStage.removeEventListener('mouseleave', clearHover);
|
||||
@@ -14961,14 +14923,6 @@ function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
||||
patchAttr(plotStage, 'hidden', useHeatmap);
|
||||
patchAttr(xAxisEl, '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) {
|
||||
syncViewWidth();
|
||||
@@ -15042,51 +14996,97 @@ function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
||||
patchStyleVar(hmBodyEl, '--hm-weeks', String(totalWeeks));
|
||||
patchStyleVar(hmBodyEl, '--hm-gap', `${gapPx}px`);
|
||||
|
||||
// 重建顶部对齐月份标签
|
||||
while (hmMonthsEl.firstChild) hmMonthsEl.removeChild(hmMonthsEl.firstChild);
|
||||
// 就地增量补丁顶部对齐月份标签,避免文字节点销毁重建
|
||||
const monthTicks = buildHeatmapMonthTicks(slots, firstDow, totalWeeks);
|
||||
for (const mt of monthTicks) {
|
||||
const mEl = h('span', { className: 'trend-hm-month text-mono', text: mt.text });
|
||||
for (let i = 0; i < monthTicks.length; i++) {
|
||||
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));
|
||||
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 一次性批量挂载减少重排
|
||||
while (hmGridEl.firstChild) hmGridEl.removeChild(hmGridEl.firstChild);
|
||||
hoveredCellEl = null;
|
||||
// 就地增量复用 7 行 × N 周列的每日小格子,首次批量新增节点使用 DocumentFragment 挂载
|
||||
currentCellEls = new Array(slots.length);
|
||||
const gridFrag =
|
||||
typeof document !== 'undefined' && typeof document.createDocumentFragment === 'function'
|
||||
const prevMountedCount = hmGridEl.children.length;
|
||||
const newCellsFrag =
|
||||
totalCells > prevMountedCount &&
|
||||
typeof document !== 'undefined' &&
|
||||
typeof document.createDocumentFragment === 'function'
|
||||
? document.createDocumentFragment()
|
||||
: null;
|
||||
const gridTarget = gridFrag || hmGridEl;
|
||||
|
||||
for (let pad = 0; pad < firstDow; pad++) {
|
||||
gridTarget.appendChild(
|
||||
h('span', { className: 'trend-hm-cell is-pad', 'aria-hidden': 'true' })
|
||||
);
|
||||
for (let nodeIdx = 0; nodeIdx < totalCells; nodeIdx++) {
|
||||
let cellEl = hmCellPool[nodeIdx];
|
||||
if (!cellEl) {
|
||||
cellEl = h('span', { className: 'trend-hm-cell' });
|
||||
hmCellPool.push(cellEl);
|
||||
}
|
||||
if (nodeIdx < firstDow) {
|
||||
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 tok = safeSlotTokens(slot?.tokens);
|
||||
const lv = resolveHeatmapLevel(tok, thresholds);
|
||||
const col = Math.floor(nodeIdx / 7);
|
||||
const row = nodeIdx % 7;
|
||||
patchClasses(cellEl, {
|
||||
'is-pad': false,
|
||||
'is-hovered': hoveredIdx === i,
|
||||
'lv-0': lv === 0,
|
||||
'lv-1': lv === 1,
|
||||
'lv-2': lv === 2,
|
||||
'lv-3': lv === 3,
|
||||
'lv-4': lv === 4,
|
||||
});
|
||||
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;
|
||||
}
|
||||
if (nodeIdx < prevMountedCount) {
|
||||
if (hmGridEl.children[nodeIdx] !== cellEl) {
|
||||
hmGridEl.insertBefore(cellEl, hmGridEl.children[nodeIdx] || null);
|
||||
}
|
||||
} else if (newCellsFrag) {
|
||||
newCellsFrag.appendChild(cellEl);
|
||||
} else {
|
||||
hmGridEl.appendChild(cellEl);
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < slots.length; i++) {
|
||||
const slot = slots[i];
|
||||
const tok = safeSlotTokens(slot?.tokens);
|
||||
const lv = resolveHeatmapLevel(tok, thresholds);
|
||||
const gridPos = firstDow + i;
|
||||
const col = Math.floor(gridPos / 7);
|
||||
const row = gridPos % 7;
|
||||
const cellEl = h('span', {
|
||||
className: `trend-hm-cell lv-${lv}`,
|
||||
'data-slot-idx': String(i),
|
||||
'data-hm-col': String(col),
|
||||
'data-hm-row': String(row),
|
||||
role: 'gridcell',
|
||||
});
|
||||
gridTarget.appendChild(cellEl);
|
||||
currentCellEls[i] = cellEl;
|
||||
if (newCellsFrag) {
|
||||
hmGridEl.appendChild(newCellsFrag);
|
||||
}
|
||||
if (gridFrag) {
|
||||
hmGridEl.appendChild(gridFrag);
|
||||
while (hmGridEl.children.length > totalCells) {
|
||||
hmGridEl.removeChild(hmGridEl.lastChild);
|
||||
}
|
||||
hoveredCellEl =
|
||||
hoveredIdx >= 0 && hoveredIdx < slots.length ? currentCellEls[hoveredIdx] || null : null;
|
||||
|
||||
if (typeof requestAnimationFrame === 'function') {
|
||||
requestAnimationFrame(() => {
|
||||
@@ -15114,7 +15114,6 @@ function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
||||
} else if (hoveredIdx >= 0) {
|
||||
showHeatmapHoverAtIndex(hoveredIdx, currentCellEls[hoveredIdx], lastPointer);
|
||||
}
|
||||
hasRenderedOnce = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15175,21 +15174,11 @@ function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
||||
}
|
||||
hasRenderedLineOnce = true;
|
||||
|
||||
// 渲染对齐底部刻度的垂直参考网格线及 X 轴标签(起止标签严格左右贴边)
|
||||
// 就地增量补丁垂直参考网格线及底部 X 轴标签,保持文字常驻不重排不闪烁
|
||||
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();
|
||||
let vLineCount = 0;
|
||||
let tickCount = 0;
|
||||
|
||||
for (let i = 0; i < tickIndices.length; i++) {
|
||||
const tIdx = tickIndices[i];
|
||||
@@ -15198,34 +15187,57 @@ function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
||||
if (!pt || !slot) continue;
|
||||
|
||||
if (i > 0 && i < tickIndices.length - 1) {
|
||||
const vLine = document.createElementNS(SVG_NS, 'line');
|
||||
vLine.setAttribute('x1', pt.x.toFixed(1));
|
||||
vLine.setAttribute('y1', '16');
|
||||
vLine.setAttribute('x2', pt.x.toFixed(1));
|
||||
vLine.setAttribute('y2', String(BOTTOM_Y));
|
||||
vGridGroup.appendChild(vLine);
|
||||
let vLine = vGridLinePool[vLineCount];
|
||||
if (!vLine) {
|
||||
vLine = document.createElementNS(SVG_NS, 'line');
|
||||
vLine.setAttribute('y1', '16');
|
||||
vLine.setAttribute('y2', String(BOTTOM_Y));
|
||||
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 isLast = !isSingle && i === tickIndices.length - 1;
|
||||
const pct = isFirst ? 0 : isLast ? 100 : (pt.x / viewW) * 100;
|
||||
const tickEl = h('span', {
|
||||
className: `trend-x-tick text-mono${isFirst ? ' is-start' : isLast ? ' is-end' : ''}`,
|
||||
text: slot.label || '',
|
||||
title: formatTrendSlotFullLabel(slot) || slot.label || '',
|
||||
let tickRec = xAxisTickPool[tickCount];
|
||||
if (!tickRec) {
|
||||
const el = h('span', { className: 'trend-x-tick text-mono' });
|
||||
const rec = { el, slotIdx: tIdx };
|
||||
el.onclick = () => {
|
||||
lastPointer = null;
|
||||
showLineHoverAtIndex(rec.slotIdx);
|
||||
};
|
||||
tickRec = rec;
|
||||
xAxisTickPool.push(tickRec);
|
||||
}
|
||||
tickRec.slotIdx = tIdx;
|
||||
patchClasses(tickRec.el, {
|
||||
'is-start': isFirst,
|
||||
'is-end': isLast,
|
||||
'is-hovered': hoveredIdx === tIdx,
|
||||
});
|
||||
patchStyleVar(tickEl, '--tick-x', `${pct.toFixed(2)}%`);
|
||||
tickEl.onclick = () => {
|
||||
lastPointer = null;
|
||||
showLineHoverAtIndex(tIdx);
|
||||
};
|
||||
xAxisEl.appendChild(tickEl);
|
||||
tickElsByIdx.set(tIdx, tickEl);
|
||||
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()) {
|
||||
triggerTransientClass(xAxisEl, 'is-switching');
|
||||
triggerTransientClass(vGridGroup, 'is-switching');
|
||||
while (vGridGroup.children.length > vLineCount) {
|
||||
vGridGroup.removeChild(vGridGroup.lastChild);
|
||||
}
|
||||
while (xAxisEl.children.length > tickCount) {
|
||||
xAxisEl.removeChild(xAxisEl.lastChild);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15259,7 +15271,6 @@ function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
||||
} else if (hoveredIdx >= 0) {
|
||||
showLineHoverAtIndex(hoveredIdx, lastPointer);
|
||||
}
|
||||
hasRenderedOnce = true;
|
||||
}
|
||||
|
||||
return { el: chartWrap, update, destroy };
|
||||
@@ -19598,88 +19609,6 @@ function formatPoolFullCapRef(eqUsd, eqTok) {
|
||||
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) {
|
||||
const num = Number(rate);
|
||||
if (!Number.isFinite(num) || num <= 0) return '--';
|
||||
@@ -19804,13 +19733,11 @@ function createRateModelCard({
|
||||
function buildRatePopoverSig(data) {
|
||||
const locale = getEffectiveLocale();
|
||||
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 poolSig = pools
|
||||
.map((p) => `${p.poolKey || ''}:${p.poolLabel || ''}:${JSON.stringify(p.rateEstimate || null)}`)
|
||||
.join('|');
|
||||
return `${locale}|${acct}|${isOfficial}|${wkCapSig}|${poolSig}`;
|
||||
return `${locale}|${acct}|${poolSig}`;
|
||||
}
|
||||
|
||||
const QuotaPoolsWidget = defineComponent({
|
||||
@@ -19828,32 +19755,7 @@ const QuotaPoolsWidget = defineComponent({
|
||||
className: 'quota-rate-pop-account',
|
||||
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 ratePopNoteEl = h('div', {
|
||||
className: 'quota-rate-pop-note',
|
||||
text: t('quota.ratePopNote'),
|
||||
});
|
||||
const ratePopoverEl = h(
|
||||
'div',
|
||||
{
|
||||
@@ -19863,9 +19765,7 @@ const QuotaPoolsWidget = defineComponent({
|
||||
},
|
||||
[
|
||||
h('div', { className: 'quota-rate-pop-head' }, [ratePopTitleEl, ratePopAccountEl]),
|
||||
ratePopWkSummaryEl,
|
||||
ratePopBodyEl,
|
||||
ratePopNoteEl,
|
||||
]
|
||||
);
|
||||
ratePopoverEl.hidden = true;
|
||||
@@ -19943,7 +19843,6 @@ const QuotaPoolsWidget = defineComponent({
|
||||
lastRatePopSig = sig;
|
||||
|
||||
patchText(ratePopTitleEl, t('quota.ratePopTitle'));
|
||||
patchText(ratePopNoteEl, t('quota.ratePopNote'));
|
||||
patchAttr(rateHelpBtn, 'aria-label', t('quota.rateHelpAria'));
|
||||
|
||||
const acctMasked = maskAccountLabel(data?.account?.email || data?.account?.name || '');
|
||||
@@ -19955,38 +19854,6 @@ const QuotaPoolsWidget = defineComponent({
|
||||
);
|
||||
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) {
|
||||
ratePopBodyEl.removeChild(ratePopBodyEl.firstChild);
|
||||
}
|
||||
@@ -30473,11 +30340,7 @@ const ConsumptionView = defineComponent({
|
||||
let lastAnimatedRankingKey = '';
|
||||
let lastAnimatedSortSig = '';
|
||||
const consAnimTimers = new Map();
|
||||
const TRANSIENT_CONS_CLASSES = [
|
||||
'is-range-switching',
|
||||
'is-tab-entering',
|
||||
'is-bars-revealing',
|
||||
];
|
||||
const TRANSIENT_CONS_CLASSES = ['is-bars-revealing'];
|
||||
|
||||
function cleanupConsAnim(el) {
|
||||
const rec = consAnimTimers.get(el);
|
||||
@@ -32295,13 +32158,7 @@ const ConsumptionView = defineComponent({
|
||||
!tabSwitched &&
|
||||
nextSortSig !== lastAnimatedSortSig;
|
||||
|
||||
if (rangeSwitched) {
|
||||
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) {
|
||||
if (tabSwitched || sortSwitched) {
|
||||
triggerConsAnim(activeRankingEl, 'is-bars-revealing');
|
||||
}
|
||||
if (!hasCompletedInitialDraw) {
|
||||
|
||||
Reference in New Issue
Block a user