mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
feat(panel): restore IDE mount compatibility, add composer dock mode, and refine chart tooltips
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,18 @@
|
||||
/**
|
||||
* @fileoverview 交互式 SVG 三次贝塞尔平滑曲线趋势图组件 (TrendAreaChart).
|
||||
* 支持:
|
||||
* 1. 自适应整点小时(<=72h)与自然日(>72h)高精度分桶序列渲染;
|
||||
* 2. 鼠标悬停/滑动十字准星探针、高亮圆点与自适应防溢出的悬浮详情卡片(精确日期/小时区间、Token 拆分、费用与调用次数);
|
||||
* 3. 与 SVG 垂直网格线像素级对齐的多刻度底部时间轴(彻底告别首/中/末简单对半切分)。
|
||||
* @fileoverview 交互式历史用量趋势图组件 (TrendAreaChart).
|
||||
* 支持双模式自适应切换:
|
||||
* 1. <= 90 天(或整点小时分桶):渲染三次贝塞尔平滑曲线面积图、峰值气泡与对齐多刻度时间轴;
|
||||
* 2. > 90 天(自然日分桶):自动切换为类 GitHub 贡献日历的小格子热力排列(一格一天,7 行星期 × 周列、月份刻度、分位数 5 档热力色阶与底部图例);
|
||||
* 3. 两种模式共享自适应防溢出的悬浮详情卡片(精确日期/小时区间、Token 拆分、费用与调用次数)。
|
||||
*/
|
||||
|
||||
import { h, patchAttr, patchClasses, patchStyleVar, patchText } from '../../core/domPatch.js';
|
||||
import { formatTokensPrecise, formatUsd } from '../../core/formatters.js';
|
||||
import { SVG_NS } from '../../icons/SvgIcon.js';
|
||||
|
||||
/** 超过该自然日天数(> 90 天)时,趋势图切换为类 GitHub 每日小格子热力图 */
|
||||
export const HEATMAP_DAYS_THRESHOLD = 90;
|
||||
|
||||
let chartUidCounter = 0;
|
||||
|
||||
function safeSlotTokens(v) {
|
||||
@@ -60,7 +63,128 @@ function computeTickIndices(slots) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建交互式 SVG 历史趋势平滑面积图组件。
|
||||
* 基于非零活跃日的分位数阈值计算热力图 5 档色阶(0 ~ 4),避免单日极端峰值压缩其余活跃日的层次对比。
|
||||
*
|
||||
* @param {number[]} nonZeroValues 已升序排列的正数 Token 列表
|
||||
* @param {number} maxTokens
|
||||
* @returns {{ q1: number, q2: number, q3: number, maxTokens: number, count: number }}
|
||||
*/
|
||||
function computeHeatmapThresholds(nonZeroValues, maxTokens) {
|
||||
const n = nonZeroValues.length;
|
||||
if (n === 0 || maxTokens <= 0) {
|
||||
return { q1: 0, q2: 0, q3: 0, maxTokens: 0, count: 0 };
|
||||
}
|
||||
if (n < 4) {
|
||||
return {
|
||||
q1: maxTokens * 0.25,
|
||||
q2: maxTokens * 0.5,
|
||||
q3: maxTokens * 0.75,
|
||||
maxTokens,
|
||||
count: n,
|
||||
};
|
||||
}
|
||||
return {
|
||||
q1: nonZeroValues[Math.floor((n - 1) * 0.25)],
|
||||
q2: nonZeroValues[Math.floor((n - 1) * 0.5)],
|
||||
q3: nonZeroValues[Math.floor((n - 1) * 0.75)],
|
||||
maxTokens,
|
||||
count: n,
|
||||
};
|
||||
}
|
||||
|
||||
function resolveHeatmapLevel(tokens, thresholds) {
|
||||
if (tokens <= 0 || thresholds.maxTokens <= 0) return 0;
|
||||
if (tokens >= thresholds.maxTokens || tokens > thresholds.q3) return 4;
|
||||
if (tokens > thresholds.q2) return 3;
|
||||
if (tokens > thresholds.q1) return 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析日期槽位的年份与月份信息(兼容真实时间戳 `startMs` 与测试简写 `label`)。
|
||||
*
|
||||
* @param {object} slot
|
||||
* @returns {{ year: number, month: number, day: number }}
|
||||
*/
|
||||
function parseSlotCalendarParts(slot) {
|
||||
const sMs = Number(slot?.startMs);
|
||||
if (Number.isFinite(sMs) && sMs > 0) {
|
||||
const d = new Date(sMs);
|
||||
return { year: d.getFullYear(), month: d.getMonth() + 1, day: d.getDate() };
|
||||
}
|
||||
const m = String(slot?.label || '').match(/^(\d{1,2})\/(\d{1,2})$/);
|
||||
if (m) {
|
||||
return { year: new Date().getFullYear(), month: Number(m[1]), day: Number(m[2]) };
|
||||
}
|
||||
return { year: new Date().getFullYear(), month: 0, day: 0 };
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建热力图顶部与周列对齐的月份刻度标签(自动跳过首尾过窄残月,防止相邻月份文字重叠)。
|
||||
*
|
||||
* @param {Array<object>} slots
|
||||
* @param {number} firstDow 首日对应的星期行索引(0 = 周一 .. 6 = 周日)
|
||||
* @param {number} totalWeeks 总周列数
|
||||
* @returns {Array<{ col: number, text: string }>}
|
||||
*/
|
||||
function buildHeatmapMonthTicks(slots, firstDow, totalWeeks) {
|
||||
if (!slots.length || totalWeeks <= 0) return [];
|
||||
const firstParts = parseSlotCalendarParts(slots[0]);
|
||||
const lastParts = parseSlotCalendarParts(slots[slots.length - 1]);
|
||||
const crossYear = firstParts.year !== lastParts.year;
|
||||
|
||||
const candidates = [];
|
||||
let prevMonthKey = '';
|
||||
|
||||
for (let col = 0; col < totalWeeks; col++) {
|
||||
let chosenParts = null;
|
||||
for (let row = 0; row < 7; row++) {
|
||||
const idx = col * 7 + row - firstDow;
|
||||
if (idx < 0 || idx >= slots.length) continue;
|
||||
const parts = parseSlotCalendarParts(slots[idx]);
|
||||
if (!parts.month) continue;
|
||||
const mKey = `${parts.year}-${parts.month}`;
|
||||
if (col === 0 && !chosenParts) {
|
||||
chosenParts = parts;
|
||||
prevMonthKey = mKey;
|
||||
break;
|
||||
}
|
||||
if (mKey !== prevMonthKey) {
|
||||
chosenParts = parts;
|
||||
prevMonthKey = mKey;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (chosenParts && chosenParts.month > 0) {
|
||||
candidates.push({ col, year: chosenParts.year, month: chosenParts.month });
|
||||
}
|
||||
}
|
||||
|
||||
const baseMinGap = totalWeeks > 40 ? 4 : 3;
|
||||
if (
|
||||
candidates.length >= 2 &&
|
||||
candidates[0].col === 0 &&
|
||||
candidates[1].col - candidates[0].col < baseMinGap
|
||||
) {
|
||||
candidates.shift();
|
||||
}
|
||||
|
||||
const ticks = [];
|
||||
let nextAllowedCol = 0;
|
||||
for (let i = 0; i < candidates.length; i++) {
|
||||
const c = candidates[i];
|
||||
if (totalWeeks > 16 && c.col >= totalWeeks - 1) continue;
|
||||
if (ticks.length > 0 && c.col < nextAllowedCol) continue;
|
||||
const showYear = crossYear && (c.month === 1 || ticks.length === 0);
|
||||
const text = showYear ? `${String(c.year).slice(-2)}年${c.month}月` : `${c.month}月`;
|
||||
ticks.push({ col: c.col, text });
|
||||
nextAllowedCol = c.col + (showYear ? baseMinGap + 1 : baseMinGap);
|
||||
}
|
||||
return ticks;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建交互式历史趋势组件(<=90 天为 SVG 平滑曲线图,>90 天自动切换为类 GitHub 每日小格子热力图)。
|
||||
*
|
||||
* @returns {{
|
||||
* el: HTMLElement,
|
||||
@@ -68,17 +192,22 @@ function computeTickIndices(slots) {
|
||||
* }}
|
||||
*/
|
||||
export function createTrendAreaChart() {
|
||||
const VIEW_W = 460;
|
||||
const DEFAULT_VIEW_W = 460;
|
||||
const VIEW_H = 120;
|
||||
const LEFT_X = 14;
|
||||
const RIGHT_X = 446;
|
||||
const TOP_Y = 24;
|
||||
const BOTTOM_Y = 102;
|
||||
const SPAN_X = RIGHT_X - LEFT_X;
|
||||
const SPAN_Y = BOTTOM_Y - TOP_Y;
|
||||
|
||||
let viewW = DEFAULT_VIEW_W;
|
||||
|
||||
function resolvePlotBounds(w) {
|
||||
const leftX = 1;
|
||||
const rightX = Math.max(leftX + 20, w - 1);
|
||||
return { leftX, rightX, spanX: rightX - leftX };
|
||||
}
|
||||
|
||||
const svg = document.createElementNS(SVG_NS, 'svg');
|
||||
svg.setAttribute('viewBox', `0 0 ${VIEW_W} ${VIEW_H}`);
|
||||
svg.setAttribute('viewBox', `0 0 ${viewW} ${VIEW_H}`);
|
||||
svg.setAttribute('class', 'trend-svg');
|
||||
svg.setAttribute('aria-hidden', 'true');
|
||||
|
||||
@@ -107,16 +236,18 @@ export function createTrendAreaChart() {
|
||||
defs.appendChild(grad);
|
||||
svg.appendChild(defs);
|
||||
|
||||
// 背景水平与垂直参考网格线
|
||||
// 背景水平与垂直参考网格线(水平网格全宽贴边铺满 0..viewW)
|
||||
const hGridGroup = document.createElementNS(SVG_NS, 'g');
|
||||
hGridGroup.setAttribute('class', 'trend-grid');
|
||||
const hGridLines = [];
|
||||
for (const y of [TOP_Y, Math.round((TOP_Y + BOTTOM_Y) / 2), BOTTOM_Y]) {
|
||||
const line = document.createElementNS(SVG_NS, 'line');
|
||||
line.setAttribute('x1', String(LEFT_X));
|
||||
line.setAttribute('x1', '0');
|
||||
line.setAttribute('y1', String(y));
|
||||
line.setAttribute('x2', String(RIGHT_X));
|
||||
line.setAttribute('x2', String(viewW));
|
||||
line.setAttribute('y2', String(y));
|
||||
hGridGroup.appendChild(line);
|
||||
hGridLines.push(line);
|
||||
}
|
||||
svg.appendChild(hGridGroup);
|
||||
|
||||
@@ -158,7 +289,7 @@ export function createTrendAreaChart() {
|
||||
|
||||
const peakPill = h('span', { className: 'trend-peak-pill text-mono', text: '0' });
|
||||
|
||||
// 悬停详情浮层卡片
|
||||
// 共享悬停详情浮层卡片(曲线图与热力格子图共用)
|
||||
const tipTimeEl = h('span', { className: 'trend-tip-time text-mono' });
|
||||
const tipCallsEl = h('span', { className: 'trend-tip-calls text-mono' });
|
||||
const tipTokensEl = h('strong', { className: 'trend-tip-tokens text-mono' });
|
||||
@@ -175,38 +306,56 @@ export function createTrendAreaChart() {
|
||||
]
|
||||
);
|
||||
|
||||
// 底部对齐刻度轴
|
||||
// 底部对齐刻度轴(曲线模式)
|
||||
const xAxisEl = h('div', { className: 'trend-x-axis' });
|
||||
const plotStage = h('div', { className: 'trend-plot-stage' }, [peakPill, svg]);
|
||||
|
||||
const plotStage = h('div', { className: 'trend-plot-stage' }, [peakPill, tooltipEl, svg]);
|
||||
const chartWrap = h('div', { className: 'trend-chart-wrap' }, [plotStage, xAxisEl]);
|
||||
// 类 GitHub 每日小格子热力图容器(> 90 天模式)
|
||||
const weekdayLabels = ['一', '', '三', '', '五', '', '日'];
|
||||
const hmWeekdaysEl = h('div', { className: 'trend-hm-weekdays', 'aria-hidden': 'true' }, [
|
||||
h('span', { className: 'trend-hm-month-spacer' }),
|
||||
...weekdayLabels.map((txt) => h('span', { className: 'trend-hm-wday', text: txt })),
|
||||
]);
|
||||
const hmMonthsEl = h('div', { className: 'trend-hm-months' });
|
||||
const hmGridEl = h('div', { className: 'trend-hm-grid', role: 'grid', 'aria-label': '每日用量热力格子图' });
|
||||
const hmTrackEl = h('div', { className: 'trend-hm-track' }, [hmMonthsEl, hmGridEl]);
|
||||
const hmScrollEl = h('div', { className: 'trend-hm-scroll' }, [hmTrackEl]);
|
||||
const hmBodyEl = h('div', { className: 'trend-heatmap-body' }, [hmWeekdaysEl, hmScrollEl]);
|
||||
|
||||
const hmSummaryEl = h('span', { className: 'trend-hm-summary text-mono', text: '' });
|
||||
const hmLegendEl = h('span', { className: 'trend-hm-legend', 'aria-hidden': 'true' }, [
|
||||
h('span', { text: '少' }),
|
||||
h('span', { className: 'trend-hm-swatch lv-0' }),
|
||||
h('span', { className: 'trend-hm-swatch lv-1' }),
|
||||
h('span', { className: 'trend-hm-swatch lv-2' }),
|
||||
h('span', { className: 'trend-hm-swatch lv-3' }),
|
||||
h('span', { className: 'trend-hm-swatch lv-4' }),
|
||||
h('span', { text: '多' }),
|
||||
]);
|
||||
const hmFooterEl = h('div', { className: 'trend-hm-footer' }, [hmSummaryEl, hmLegendEl]);
|
||||
const heatmapStage = h('div', { className: 'trend-heatmap-stage', hidden: true }, [
|
||||
hmBodyEl,
|
||||
hmFooterEl,
|
||||
]);
|
||||
|
||||
const chartWrap = h('div', { className: 'trend-chart-wrap' }, [
|
||||
plotStage,
|
||||
xAxisEl,
|
||||
heatmapStage,
|
||||
tooltipEl,
|
||||
]);
|
||||
|
||||
let currentSlots = [];
|
||||
let currentPts = [];
|
||||
let currentIsHeatmap = false;
|
||||
let currentHeatmapWeeks = 0;
|
||||
let currentCellEls = [];
|
||||
let tickElsByIdx = new Map();
|
||||
let hoveredIdx = -1;
|
||||
let hoveredCellEl = null;
|
||||
let lastRenderSig = '';
|
||||
|
||||
function showHoverAtIndex(idx) {
|
||||
if (idx < 0 || idx >= currentSlots.length || !currentPts[idx]) {
|
||||
clearHover();
|
||||
return;
|
||||
}
|
||||
hoveredIdx = idx;
|
||||
const slot = currentSlots[idx];
|
||||
const pt = currentPts[idx];
|
||||
|
||||
patchAttr(hoverLine, 'hidden', false);
|
||||
patchAttr(hoverLine, 'x1', pt.x.toFixed(1));
|
||||
patchAttr(hoverLine, 'x2', pt.x.toFixed(1));
|
||||
|
||||
patchAttr(hoverDot, 'hidden', false);
|
||||
patchAttr(hoverDot, 'cx', pt.x.toFixed(1));
|
||||
patchAttr(hoverDot, 'cy', pt.y.toFixed(1));
|
||||
|
||||
patchAttr(peakPill, 'hidden', true);
|
||||
patchAttr(tooltipEl, 'hidden', false);
|
||||
|
||||
function populateTooltipContent(slot) {
|
||||
patchText(tipTimeEl, slot.fullLabel || slot.label || '--');
|
||||
patchText(tipCallsEl, `${Math.max(0, Math.floor(Number(slot.calls) || 0))} 次`);
|
||||
const slotTok = safeSlotTokens(slot.tokens);
|
||||
@@ -231,47 +380,219 @@ export function createTrendAreaChart() {
|
||||
`入 ${formatTokensPrecise(safeSlotTokens(slot.inputTokens))} · 缓 ${formatTokensPrecise(safeSlotTokens(slot.cacheReadTokens))} · 出 ${formatTokensPrecise(safeSlotTokens(slot.outputTokens))}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const rawPct = (pt.x / VIEW_W) * 100;
|
||||
const clampedPct = Math.max(2, Math.min(98, rawPct));
|
||||
const shiftX = rawPct < 28 ? '0%' : rawPct > 72 ? '-100%' : '-50%';
|
||||
function showLineHoverAtIndex(idx) {
|
||||
if (currentIsHeatmap || idx < 0 || idx >= currentSlots.length || !currentPts[idx]) {
|
||||
clearHover();
|
||||
return;
|
||||
}
|
||||
hoveredIdx = idx;
|
||||
const slot = currentSlots[idx];
|
||||
const pt = currentPts[idx];
|
||||
|
||||
patchAttr(hoverLine, 'hidden', false);
|
||||
patchAttr(hoverLine, 'x1', pt.x.toFixed(1));
|
||||
patchAttr(hoverLine, 'x2', pt.x.toFixed(1));
|
||||
|
||||
patchAttr(hoverDot, 'hidden', false);
|
||||
patchAttr(hoverDot, 'cx', pt.x.toFixed(1));
|
||||
patchAttr(hoverDot, 'cy', pt.y.toFixed(1));
|
||||
|
||||
patchAttr(peakPill, 'hidden', true);
|
||||
patchClasses(tooltipEl, { 'is-hm-bottom': false, 'is-hm-top': false });
|
||||
patchAttr(tooltipEl, 'hidden', false);
|
||||
populateTooltipContent(slot);
|
||||
|
||||
const rawPct = (pt.x / viewW) * 100;
|
||||
const clampedPct = Math.max(1, Math.min(99, rawPct));
|
||||
patchStyleVar(tooltipEl, '--tip-x', `${clampedPct.toFixed(1)}%`);
|
||||
patchStyleVar(tooltipEl, '--tip-shift', shiftX);
|
||||
patchStyleVar(tooltipEl, '--tip-shift', `-${clampedPct.toFixed(1)}%`);
|
||||
|
||||
for (const [tIdx, el] of tickElsByIdx.entries()) {
|
||||
patchClasses(el, { 'is-hovered': tIdx === idx });
|
||||
}
|
||||
}
|
||||
|
||||
function showHeatmapHoverAtIndex(idx, cellEl) {
|
||||
if (!currentIsHeatmap || idx < 0 || idx >= currentSlots.length) {
|
||||
clearHover();
|
||||
return;
|
||||
}
|
||||
const targetCell = cellEl || currentCellEls[idx] || null;
|
||||
if (!targetCell) {
|
||||
clearHover();
|
||||
return;
|
||||
}
|
||||
hoveredIdx = idx;
|
||||
if (hoveredCellEl && hoveredCellEl !== targetCell) {
|
||||
patchClasses(hoveredCellEl, { 'is-hovered': false });
|
||||
}
|
||||
hoveredCellEl = targetCell;
|
||||
patchClasses(targetCell, { 'is-hovered': true });
|
||||
|
||||
const slot = currentSlots[idx];
|
||||
const row = Number(targetCell.getAttribute('data-hm-row') || 0);
|
||||
const col = Number(targetCell.getAttribute('data-hm-col') || 0);
|
||||
|
||||
// 上半区(周一~周四)浮层停靠底部,下半区(周五~周日)停靠顶部,互不遮挡被悬停格子且永不越界裁剪
|
||||
patchClasses(tooltipEl, {
|
||||
'is-hm-bottom': row <= 3,
|
||||
'is-hm-top': row > 3,
|
||||
});
|
||||
patchAttr(tooltipEl, 'hidden', false);
|
||||
populateTooltipContent(slot);
|
||||
|
||||
const wrapRect = chartWrap.getBoundingClientRect();
|
||||
const cellRect = targetCell.getBoundingClientRect();
|
||||
let rawPct = 50;
|
||||
if (
|
||||
wrapRect &&
|
||||
wrapRect.width > 0 &&
|
||||
cellRect &&
|
||||
cellRect.width > 0 &&
|
||||
cellRect.width < wrapRect.width
|
||||
) {
|
||||
rawPct = ((cellRect.left + cellRect.width / 2 - wrapRect.left) / wrapRect.width) * 100;
|
||||
} else if (currentHeatmapWeeks > 0) {
|
||||
rawPct = ((col + 0.5) / currentHeatmapWeeks) * 100;
|
||||
}
|
||||
const clampedPct = Math.max(1, Math.min(99, rawPct));
|
||||
patchStyleVar(tooltipEl, '--tip-x', `${clampedPct.toFixed(1)}%`);
|
||||
patchStyleVar(tooltipEl, '--tip-shift', `-${clampedPct.toFixed(1)}%`);
|
||||
}
|
||||
|
||||
function clearHover() {
|
||||
hoveredIdx = -1;
|
||||
patchAttr(hoverLine, 'hidden', true);
|
||||
patchAttr(hoverDot, 'hidden', true);
|
||||
patchAttr(tooltipEl, 'hidden', true);
|
||||
patchAttr(peakPill, 'hidden', false);
|
||||
patchClasses(tooltipEl, { 'is-hm-bottom': false, 'is-hm-top': false });
|
||||
if (!currentIsHeatmap) {
|
||||
patchAttr(peakPill, 'hidden', false);
|
||||
}
|
||||
if (hoveredCellEl) {
|
||||
patchClasses(hoveredCellEl, { 'is-hovered': false });
|
||||
hoveredCellEl = null;
|
||||
}
|
||||
for (const el of tickElsByIdx.values()) {
|
||||
patchClasses(el, { 'is-hovered': false });
|
||||
}
|
||||
}
|
||||
|
||||
function syncViewWidth() {
|
||||
const measured = Math.round(
|
||||
plotStage.clientWidth ||
|
||||
svg.clientWidth ||
|
||||
plotStage.getBoundingClientRect?.()?.width ||
|
||||
0
|
||||
);
|
||||
if (measured >= 160 && measured !== viewW) {
|
||||
viewW = measured;
|
||||
svg.setAttribute('viewBox', `0 0 ${viewW} ${VIEW_H}`);
|
||||
for (const line of hGridLines) {
|
||||
line.setAttribute('x1', '0');
|
||||
line.setAttribute('x2', String(viewW));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function handlePointerMove(e) {
|
||||
if (!currentSlots.length) return;
|
||||
if (currentIsHeatmap || !currentSlots.length) return;
|
||||
const rect = svg.getBoundingClientRect();
|
||||
if (!rect || rect.width <= 0) return;
|
||||
const relX = ((e.clientX - rect.left) / rect.width) * VIEW_W;
|
||||
const ratio = (relX - LEFT_X) / Math.max(1, SPAN_X);
|
||||
const relX = ((e.clientX - rect.left) / rect.width) * viewW;
|
||||
const { leftX, spanX } = resolvePlotBounds(viewW);
|
||||
const ratio = (relX - leftX) / Math.max(1, spanX);
|
||||
const idx = Math.max(
|
||||
0,
|
||||
Math.min(currentSlots.length - 1, Math.round(ratio * (currentSlots.length - 1)))
|
||||
);
|
||||
showHoverAtIndex(idx);
|
||||
showLineHoverAtIndex(idx);
|
||||
}
|
||||
|
||||
function findHeatmapCellFromEvent(e) {
|
||||
let cur = e?.target || null;
|
||||
while (cur && cur !== hmGridEl) {
|
||||
const idxAttr = cur.getAttribute?.('data-slot-idx');
|
||||
if (idxAttr !== null && idxAttr !== undefined && idxAttr !== '') {
|
||||
return { idx: Number(idxAttr), cellEl: cur };
|
||||
}
|
||||
cur = cur.parentNode || null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function handleHeatmapPointer(e) {
|
||||
if (!currentIsHeatmap || !currentSlots.length) return;
|
||||
const hit = findHeatmapCellFromEvent(e);
|
||||
if (!hit || !Number.isFinite(hit.idx)) {
|
||||
clearHover();
|
||||
return;
|
||||
}
|
||||
if (hit.idx !== hoveredIdx || hit.cellEl !== hoveredCellEl) {
|
||||
showHeatmapHoverAtIndex(hit.idx, hit.cellEl);
|
||||
}
|
||||
}
|
||||
|
||||
function handleHeatmapWheel(e) {
|
||||
if (!currentIsHeatmap) return;
|
||||
const maxScrollLeft = (hmScrollEl.scrollWidth || 0) - (hmScrollEl.clientWidth || 0);
|
||||
if (maxScrollLeft <= 2) return;
|
||||
const dy = Number(e.deltaY || 0);
|
||||
const dx = Number(e.deltaX || 0);
|
||||
if (Math.abs(dy) > Math.abs(dx) && dy !== 0) {
|
||||
const prev = hmScrollEl.scrollLeft || 0;
|
||||
const next = Math.max(0, Math.min(maxScrollLeft, prev + dy));
|
||||
if (next !== prev) {
|
||||
hmScrollEl.scrollLeft = next;
|
||||
e.preventDefault?.();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plotStage.addEventListener('mousemove', handlePointerMove);
|
||||
plotStage.addEventListener('mouseleave', clearHover);
|
||||
|
||||
hmGridEl.addEventListener('mouseover', handleHeatmapPointer);
|
||||
hmGridEl.addEventListener('mousemove', handleHeatmapPointer);
|
||||
hmGridEl.addEventListener('click', handleHeatmapPointer);
|
||||
hmGridEl.addEventListener('mouseleave', clearHover);
|
||||
hmScrollEl.addEventListener('wheel', handleHeatmapWheel);
|
||||
|
||||
let resizeObs = null;
|
||||
let onWinResize = null;
|
||||
if (typeof ResizeObserver === 'function') {
|
||||
resizeObs = new ResizeObserver(() => {
|
||||
if (!currentIsHeatmap && syncViewWidth() && currentSlots.length > 0) {
|
||||
lastRenderSig = '';
|
||||
update(currentSlots);
|
||||
}
|
||||
});
|
||||
resizeObs.observe(plotStage);
|
||||
} else if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') {
|
||||
onWinResize = () => {
|
||||
if (!currentIsHeatmap && syncViewWidth() && currentSlots.length > 0) {
|
||||
lastRenderSig = '';
|
||||
update(currentSlots);
|
||||
}
|
||||
};
|
||||
window.addEventListener('resize', onWinResize);
|
||||
}
|
||||
|
||||
function destroy() {
|
||||
resizeObs?.disconnect();
|
||||
resizeObs = null;
|
||||
if (onWinResize && typeof window !== 'undefined' && typeof window.removeEventListener === 'function') {
|
||||
window.removeEventListener('resize', onWinResize);
|
||||
onWinResize = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据最新时间分桶序列重绘平滑曲线、渐变区域、峰值气泡与底部对齐刻度。
|
||||
* 根据最新时间分桶序列重绘平滑曲线(<=90天/小时级)或类 GitHub 每日小格子热力图(>90天)。
|
||||
*/
|
||||
function update(series = []) {
|
||||
const slots =
|
||||
@@ -285,39 +606,155 @@ export function createTrendAreaChart() {
|
||||
];
|
||||
currentSlots = slots;
|
||||
|
||||
const isHourly =
|
||||
slots[0]?.granularity === 'hour' || String(slots[0]?.label || '').includes(':');
|
||||
const useHeatmap = !isHourly && slots.length > HEATMAP_DAYS_THRESHOLD;
|
||||
const modeChanged = useHeatmap !== currentIsHeatmap;
|
||||
currentIsHeatmap = useHeatmap;
|
||||
|
||||
if (modeChanged) {
|
||||
clearHover();
|
||||
}
|
||||
patchClasses(chartWrap, { 'is-heatmap': useHeatmap });
|
||||
patchAttr(plotStage, 'hidden', useHeatmap);
|
||||
patchAttr(xAxisEl, 'hidden', useHeatmap);
|
||||
patchAttr(heatmapStage, 'hidden', !useHeatmap);
|
||||
|
||||
if (!useHeatmap) {
|
||||
syncViewWidth();
|
||||
}
|
||||
|
||||
let maxTokens = 0;
|
||||
let peakIdx = 0;
|
||||
let activeDays = 0;
|
||||
const nonZeroVals = [];
|
||||
|
||||
for (let i = 0; i < slots.length; i++) {
|
||||
const t = safeSlotTokens(slots[i]?.tokens);
|
||||
if (t > 0) {
|
||||
activeDays++;
|
||||
nonZeroVals.push(t);
|
||||
}
|
||||
if (t >= maxTokens) {
|
||||
maxTokens = t;
|
||||
peakIdx = i;
|
||||
}
|
||||
}
|
||||
|
||||
const sig =
|
||||
`${useHeatmap ? 'hm' : `line:${viewW}`}|` +
|
||||
slots
|
||||
.map(
|
||||
(s) =>
|
||||
`${s?.startMs || ''}:${s?.label || ''}:${s?.fullLabel || ''}:${safeSlotTokens(s?.tokens)}:${Number(s?.costUsd || 0)}:${Number(s?.calls || 0)}`
|
||||
)
|
||||
.join('|');
|
||||
|
||||
if (useHeatmap) {
|
||||
currentPts = [];
|
||||
if (sig !== lastRenderSig) {
|
||||
lastRenderSig = sig;
|
||||
nonZeroVals.sort((a, b) => a - b);
|
||||
const thresholds = computeHeatmapThresholds(nonZeroVals, maxTokens);
|
||||
|
||||
const firstStartMs = Number(slots[0]?.startMs);
|
||||
const firstDow =
|
||||
Number.isFinite(firstStartMs) && firstStartMs > 0
|
||||
? (new Date(firstStartMs).getDay() + 6) % 7
|
||||
: 0;
|
||||
const totalCells = firstDow + slots.length;
|
||||
const totalWeeks = Math.max(1, Math.ceil(totalCells / 7));
|
||||
currentHeatmapWeeks = totalWeeks;
|
||||
|
||||
patchStyleVar(hmBodyEl, '--hm-weeks', String(totalWeeks));
|
||||
patchStyleVar(hmBodyEl, '--hm-gap', totalWeeks > 42 ? '1.5px' : '2px');
|
||||
|
||||
// 重建顶部对齐月份标签
|
||||
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 });
|
||||
patchStyleVar(mEl, '--hm-col', String(mt.col));
|
||||
hmMonthsEl.appendChild(mEl);
|
||||
}
|
||||
|
||||
// 重建 7 行 × N 周列的每日小格子(一格一天)
|
||||
while (hmGridEl.firstChild) hmGridEl.removeChild(hmGridEl.firstChild);
|
||||
hoveredCellEl = null;
|
||||
currentCellEls = new Array(slots.length);
|
||||
|
||||
for (let pad = 0; pad < firstDow; pad++) {
|
||||
hmGridEl.appendChild(
|
||||
h('span', { className: 'trend-hm-cell is-pad', 'aria-hidden': 'true' })
|
||||
);
|
||||
}
|
||||
|
||||
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',
|
||||
});
|
||||
hmGridEl.appendChild(cellEl);
|
||||
currentCellEls[i] = cellEl;
|
||||
}
|
||||
|
||||
if (typeof requestAnimationFrame === 'function') {
|
||||
requestAnimationFrame(() => {
|
||||
if (hmScrollEl.scrollWidth > hmScrollEl.clientWidth) {
|
||||
hmScrollEl.scrollLeft = hmScrollEl.scrollWidth;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const peakSlot = slots[peakIdx];
|
||||
const summaryText =
|
||||
maxTokens > 0 && peakSlot?.label
|
||||
? `活跃 ${activeDays}/${slots.length} 天 · 峰值 ${peakSlot.label} · ${formatTokensPrecise(maxTokens)}`
|
||||
: `活跃 0/${slots.length} 天`;
|
||||
patchText(hmSummaryEl, summaryText);
|
||||
|
||||
if (hoveredIdx >= slots.length) {
|
||||
clearHover();
|
||||
} else if (hoveredIdx >= 0) {
|
||||
showHeatmapHoverAtIndex(hoveredIdx, currentCellEls[hoveredIdx]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// --- <= 90 天(或整点小时级):渲染平滑面积曲线图(1:1 贴边对齐) ---
|
||||
currentCellEls = [];
|
||||
const { leftX, rightX, spanX } = resolvePlotBounds(viewW);
|
||||
const denom = Math.max(1, maxTokens);
|
||||
const isSingle = slots.length === 1;
|
||||
const pts = slots.map((s, idx) => {
|
||||
const tok = safeSlotTokens(s?.tokens);
|
||||
const x = isSingle ? (LEFT_X + RIGHT_X) / 2 : LEFT_X + (idx / Math.max(1, slots.length - 1)) * SPAN_X;
|
||||
const x = isSingle
|
||||
? (leftX + rightX) / 2
|
||||
: leftX + (idx / Math.max(1, slots.length - 1)) * spanX;
|
||||
const ratio = maxTokens > 0 ? tok / denom : 0;
|
||||
const y = BOTTOM_Y - ratio * SPAN_Y;
|
||||
return { x, y, tokens: tok };
|
||||
});
|
||||
currentPts = pts;
|
||||
|
||||
const sig = slots
|
||||
.map((s) => `${s?.label || ''}:${s?.fullLabel || ''}:${safeSlotTokens(s?.tokens)}:${Number(s?.costUsd || 0)}:${Number(s?.calls || 0)}`)
|
||||
.join('|');
|
||||
|
||||
if (sig !== lastRenderSig) {
|
||||
lastRenderSig = sig;
|
||||
let lineD;
|
||||
let areaD;
|
||||
if (isSingle) {
|
||||
const yStr = pts[0].y.toFixed(1);
|
||||
lineD = `M ${LEFT_X.toFixed(1)} ${yStr} L ${RIGHT_X.toFixed(1)} ${yStr}`;
|
||||
areaD = `${lineD} L ${RIGHT_X.toFixed(1)} ${BOTTOM_Y} L ${LEFT_X.toFixed(1)} ${BOTTOM_Y} Z`;
|
||||
lineD = `M ${leftX.toFixed(1)} ${yStr} L ${rightX.toFixed(1)} ${yStr}`;
|
||||
areaD = `${lineD} L ${rightX.toFixed(1)} ${BOTTOM_Y} L ${leftX.toFixed(1)} ${BOTTOM_Y} Z`;
|
||||
} else {
|
||||
lineD = buildSmoothSplinePath(pts);
|
||||
areaD = `${lineD} L ${pts[pts.length - 1].x.toFixed(1)} ${BOTTOM_Y} L ${pts[0].x.toFixed(1)} ${BOTTOM_Y} Z`;
|
||||
@@ -325,7 +762,7 @@ export function createTrendAreaChart() {
|
||||
patchAttr(linePath, 'd', lineD);
|
||||
patchAttr(areaPath, 'd', areaD);
|
||||
|
||||
// 渲染与底部刻度对齐的垂直参考网格线及底部 X 轴标签
|
||||
// 渲染与底部刻度对齐的垂直参考网格线及底部 X 轴标签(起止标签严格左右贴边)
|
||||
const tickIndices = computeTickIndices(slots);
|
||||
while (vGridGroup.firstChild) vGridGroup.removeChild(vGridGroup.firstChild);
|
||||
while (xAxisEl.firstChild) xAxisEl.removeChild(xAxisEl.firstChild);
|
||||
@@ -348,14 +785,14 @@ export function createTrendAreaChart() {
|
||||
|
||||
const isFirst = !isSingle && i === 0;
|
||||
const isLast = !isSingle && i === tickIndices.length - 1;
|
||||
const pct = (pt.x / VIEW_W) * 100;
|
||||
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: slot.fullLabel || slot.label || '',
|
||||
});
|
||||
patchStyleVar(tickEl, '--tick-x', `${pct.toFixed(2)}%`);
|
||||
tickEl.onclick = () => showHoverAtIndex(tIdx);
|
||||
tickEl.onclick = () => showLineHoverAtIndex(tIdx);
|
||||
xAxisEl.appendChild(tickEl);
|
||||
tickElsByIdx.set(tIdx, tickEl);
|
||||
}
|
||||
@@ -375,7 +812,7 @@ export function createTrendAreaChart() {
|
||||
}
|
||||
}
|
||||
|
||||
const peakPt = pts[peakIdx] || { x: 230, y: BOTTOM_Y };
|
||||
const peakPt = pts[peakIdx] || { x: viewW / 2, y: BOTTOM_Y };
|
||||
patchAttr(peakDot, 'cx', peakPt.x.toFixed(1));
|
||||
patchAttr(peakDot, 'cy', peakPt.y.toFixed(1));
|
||||
|
||||
@@ -385,15 +822,15 @@ export function createTrendAreaChart() {
|
||||
? `峰值 ${peakSlot.label} · ${formatTokensPrecise(maxTokens)}`
|
||||
: formatTokensPrecise(maxTokens);
|
||||
patchText(peakPill, peakText);
|
||||
const pctLeft = Math.max(12, Math.min(88, (peakPt.x / VIEW_W) * 100));
|
||||
const pctLeft = Math.max(12, Math.min(88, (peakPt.x / viewW) * 100));
|
||||
patchStyleVar(peakPill, '--peak-x', `${pctLeft.toFixed(1)}%`);
|
||||
|
||||
if (hoveredIdx >= slots.length) {
|
||||
clearHover();
|
||||
} else if (hoveredIdx >= 0) {
|
||||
showHoverAtIndex(hoveredIdx);
|
||||
showLineHoverAtIndex(hoveredIdx);
|
||||
}
|
||||
}
|
||||
|
||||
return { el: chartWrap, update };
|
||||
return { el: chartWrap, update, destroy };
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
/**
|
||||
* @fileoverview Bespoke CustomSelect dropdown component replacing native <select> / <option>.
|
||||
* Supports incremental option patching while open without losing focus or closing the menu.
|
||||
* Supports both single-select and multi-select (`multiple: true`) modes, with incremental
|
||||
* option patching while open without losing focus or closing the menu.
|
||||
*/
|
||||
|
||||
import { defineComponent } from '../../core/component.js';
|
||||
@@ -14,6 +15,40 @@ import {
|
||||
} from '../../core/domPatch.js';
|
||||
import { createSvgIcon, patchSvgIcon } from '../../icons/SvgIcon.js';
|
||||
|
||||
function normalizeMultiSelection(rawValue, options = [], allValue = '') {
|
||||
const arr = Array.isArray(rawValue)
|
||||
? rawValue
|
||||
: rawValue !== undefined && rawValue !== null && rawValue !== ''
|
||||
? [rawValue]
|
||||
: [];
|
||||
const clean = [];
|
||||
const seen = new Set();
|
||||
for (const item of arr) {
|
||||
const str = String(item ?? '');
|
||||
if (!str || seen.has(str)) continue;
|
||||
seen.add(str);
|
||||
clean.push(str);
|
||||
}
|
||||
if (allValue && (clean.length === 0 || clean.includes(allValue))) {
|
||||
return [allValue];
|
||||
}
|
||||
if (options.length > 0) {
|
||||
const validSet = new Set(options.map((o) => String(o.value)));
|
||||
const filtered = clean.filter((v) => validSet.has(v));
|
||||
if (filtered.length > 0) return filtered;
|
||||
return allValue ? [allValue] : [];
|
||||
}
|
||||
return clean;
|
||||
}
|
||||
|
||||
function sameStringArray(a, b) {
|
||||
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
if (a[i] !== b[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export const CustomSelect = defineComponent({
|
||||
name: 'CustomSelect',
|
||||
setup({ getProps, setProps, emit, onCleanup }) {
|
||||
@@ -49,9 +84,23 @@ export const CustomSelect = defineComponent({
|
||||
hidden: true,
|
||||
});
|
||||
|
||||
const initialClass = ['custom-select', getProps().className].filter(Boolean).join(' ');
|
||||
const initialClass = [
|
||||
'custom-select',
|
||||
getProps().multiple ? 'is-multi' : '',
|
||||
getProps().className,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ');
|
||||
const rootEl = h('div', { className: initialClass }, [triggerBtn, menuEl]);
|
||||
|
||||
function getSelectedSet() {
|
||||
const { multiple, modelValue, options = [], allValue = '' } = getProps();
|
||||
if (!multiple) {
|
||||
return new Set(modelValue !== undefined && modelValue !== null ? [modelValue] : []);
|
||||
}
|
||||
return new Set(normalizeMultiSelection(modelValue, options, allValue));
|
||||
}
|
||||
|
||||
function toggleOpen(nextOpen) {
|
||||
isOpen = Boolean(nextOpen);
|
||||
patchClasses(rootEl, { 'is-open': isOpen });
|
||||
@@ -60,10 +109,10 @@ export const CustomSelect = defineComponent({
|
||||
patchSvgIcon(chevronIcon, isOpen ? 'chevron-up' : 'chevron-down');
|
||||
if (isOpen) {
|
||||
const opts = getProps().options || [];
|
||||
const currentVal = getProps().modelValue;
|
||||
const selSet = getSelectedSet();
|
||||
focusedIndex = Math.max(
|
||||
0,
|
||||
opts.findIndex((o) => o.value === currentVal)
|
||||
opts.findIndex((o) => selSet.has(o.value))
|
||||
);
|
||||
renderMenuOptions();
|
||||
}
|
||||
@@ -71,11 +120,47 @@ export const CustomSelect = defineComponent({
|
||||
|
||||
function chooseOption(option) {
|
||||
if (!option) return;
|
||||
const prevVal = getProps().modelValue;
|
||||
toggleOpen(false);
|
||||
if (option.value !== prevVal) {
|
||||
setProps({ modelValue: option.value });
|
||||
emit('update:modelValue', option.value);
|
||||
const { multiple, options = [], allValue = '', collapseAll = false } = getProps();
|
||||
if (!multiple) {
|
||||
const prevVal = getProps().modelValue;
|
||||
toggleOpen(false);
|
||||
if (option.value !== prevVal) {
|
||||
setProps({ modelValue: option.value });
|
||||
emit('update:modelValue', option.value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const prevList = normalizeMultiSelection(getProps().modelValue, options, allValue);
|
||||
const val = String(option.value);
|
||||
let nextList;
|
||||
if (allValue && val === allValue) {
|
||||
nextList = [allValue];
|
||||
} else {
|
||||
const base = prevList.filter((v) => v !== allValue);
|
||||
if (base.includes(val)) {
|
||||
const rest = base.filter((v) => v !== val);
|
||||
nextList = rest.length > 0 ? rest : allValue ? [allValue] : [val];
|
||||
} else {
|
||||
const addedSet = new Set([...base, val]);
|
||||
const ordered = options
|
||||
.filter((o) => String(o.value) !== allValue && addedSet.has(String(o.value)))
|
||||
.map((o) => String(o.value));
|
||||
nextList = ordered.length > 0 ? ordered : [...base, val];
|
||||
if (collapseAll && allValue) {
|
||||
const nonAllTotal = options.filter((o) => String(o.value) !== allValue).length;
|
||||
if (nonAllTotal > 0 && nextList.length >= nonAllTotal) {
|
||||
nextList = [allValue];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!sameStringArray(prevList, nextList)) {
|
||||
setProps({ modelValue: nextList });
|
||||
emit('update:modelValue', nextList);
|
||||
} else {
|
||||
renderMenuOptions();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +186,7 @@ export const CustomSelect = defineComponent({
|
||||
renderMenuOptions();
|
||||
menuEl.children[focusedIndex]?.scrollIntoView?.({ block: 'nearest' });
|
||||
}
|
||||
} else if (e.key === 'Enter' && isOpen) {
|
||||
} else if ((e.key === 'Enter' || (e.key === ' ' && isOpen && getProps().multiple)) && isOpen) {
|
||||
e.preventDefault();
|
||||
const target = opts[focusedIndex];
|
||||
if (target) chooseOption(target);
|
||||
@@ -112,14 +197,20 @@ export const CustomSelect = defineComponent({
|
||||
}
|
||||
|
||||
function renderMenuOptions() {
|
||||
const { options = [], modelValue } = getProps();
|
||||
const { options = [], multiple = false } = getProps();
|
||||
const selSet = getSelectedSet();
|
||||
patchAttr(menuEl, 'aria-multiselectable', multiple ? 'true' : null);
|
||||
patchKeyedList(menuEl, options, {
|
||||
keyFn: (opt) => opt.value,
|
||||
sigFn: (opt, idx) =>
|
||||
`${opt.value}::${opt.label}::${opt.meta || ''}::${opt.value === modelValue}::${idx === focusedIndex}`,
|
||||
`${multiple}::${opt.value}::${opt.label}::${opt.meta || ''}::${selSet.has(opt.value)}::${idx === focusedIndex}`,
|
||||
createRow: (opt) => {
|
||||
const checkboxIcon = createSvgIcon('check', { size: 10 });
|
||||
const checkboxBox = h('span', { className: 'select-checkbox', hidden: true }, [
|
||||
checkboxIcon,
|
||||
]);
|
||||
const textSpan = h('span', { className: 'select-option-text' });
|
||||
const metaSpan = h('span', { className: 'text-muted' });
|
||||
const metaSpan = h('span', { className: 'text-muted select-option-meta' });
|
||||
const checkIcon = createSvgIcon('check', { size: 12 });
|
||||
const btn = h(
|
||||
'button',
|
||||
@@ -129,21 +220,26 @@ export const CustomSelect = defineComponent({
|
||||
className: 'select-option',
|
||||
onClick: (e) => {
|
||||
e.stopPropagation();
|
||||
const latestOpt = (getProps().options || []).find((o) => o.value === opt.value) || opt;
|
||||
const latestOpt =
|
||||
(getProps().options || []).find((o) => o.value === opt.value) || opt;
|
||||
chooseOption(latestOpt);
|
||||
},
|
||||
},
|
||||
[textSpan, metaSpan, checkIcon]
|
||||
[checkboxBox, textSpan, metaSpan, checkIcon]
|
||||
);
|
||||
return { el: btn, refs: { textSpan, metaSpan, checkIcon } };
|
||||
return { el: btn, refs: { checkboxBox, checkboxIcon, textSpan, metaSpan, checkIcon } };
|
||||
},
|
||||
updateRow: (refs, opt, idx, el) => {
|
||||
const selected = opt.value === modelValue;
|
||||
const isMulti = Boolean(getProps().multiple);
|
||||
const selected = selSet.has(opt.value);
|
||||
const focused = idx === focusedIndex;
|
||||
patchAttr(refs.checkboxBox, 'hidden', !isMulti);
|
||||
patchClasses(refs.checkboxBox, { 'is-checked': selected });
|
||||
patchAttr(refs.checkboxIcon, 'hidden', !selected);
|
||||
patchText(refs.textSpan, opt.label);
|
||||
patchText(refs.metaSpan, opt.meta || '');
|
||||
patchAttr(refs.metaSpan, 'hidden', !opt.meta);
|
||||
patchAttr(refs.checkIcon, 'hidden', !selected);
|
||||
patchAttr(refs.checkIcon, 'hidden', isMulti || !selected);
|
||||
patchClasses(el, {
|
||||
'is-selected': selected,
|
||||
'is-focused': focused,
|
||||
@@ -155,17 +251,51 @@ export const CustomSelect = defineComponent({
|
||||
}
|
||||
|
||||
function syncTriggerAndMenu() {
|
||||
const { options = [], modelValue, placeholder = '请选择', icon } = getProps();
|
||||
const {
|
||||
options = [],
|
||||
modelValue,
|
||||
placeholder = '请选择',
|
||||
icon,
|
||||
multiple = false,
|
||||
allValue = '',
|
||||
multiUnit = '项',
|
||||
} = getProps();
|
||||
patchClasses(rootEl, { 'is-multi': Boolean(multiple) });
|
||||
patchAttr(leadIcon, 'hidden', !icon);
|
||||
if (icon) {
|
||||
patchSvgIcon(leadIcon, icon);
|
||||
}
|
||||
const matchedOpt = options.find((o) => o.value === modelValue);
|
||||
const selectedOpt = matchedOpt || (!modelValue ? options[0] : undefined);
|
||||
const fallbackText = modelValue ? `${placeholder} (${String(modelValue).slice(0, 8)})` : placeholder;
|
||||
const labelText = selectedOpt ? selectedOpt.label : fallbackText;
|
||||
|
||||
let labelText = placeholder;
|
||||
let titleText = placeholder;
|
||||
|
||||
if (multiple) {
|
||||
const vals = normalizeMultiSelection(modelValue, options, allValue);
|
||||
if ((allValue && vals.includes(allValue)) || vals.length === 0) {
|
||||
const allOpt = options.find((o) => String(o.value) === allValue);
|
||||
labelText = allOpt ? allOpt.label : placeholder;
|
||||
titleText = labelText;
|
||||
} else if (vals.length === 1) {
|
||||
const singleOpt = options.find((o) => String(o.value) === vals[0]);
|
||||
labelText = singleOpt ? singleOpt.label : vals[0];
|
||||
titleText = labelText;
|
||||
} else {
|
||||
const names = vals.map((v) => options.find((o) => String(o.value) === v)?.label || v);
|
||||
labelText = `已选 ${vals.length} ${multiUnit}`;
|
||||
titleText = `已选 (${vals.length}):${names.join('、')}`;
|
||||
}
|
||||
} else {
|
||||
const matchedOpt = options.find((o) => o.value === modelValue);
|
||||
const selectedOpt = matchedOpt || (!modelValue ? options[0] : undefined);
|
||||
const fallbackText = modelValue
|
||||
? `${placeholder} (${String(modelValue).slice(0, 8)})`
|
||||
: placeholder;
|
||||
labelText = selectedOpt ? selectedOpt.label : fallbackText;
|
||||
titleText = labelText;
|
||||
}
|
||||
|
||||
patchText(triggerLabel, labelText);
|
||||
patchAttr(triggerBtn, 'title', labelText);
|
||||
patchAttr(triggerBtn, 'title', titleText);
|
||||
if (isOpen) {
|
||||
renderMenuOptions();
|
||||
}
|
||||
|
||||
@@ -34,6 +34,9 @@ export function formatCnyApprox(usdAmount, rate = 7.2) {
|
||||
export function formatDateSpanBadge(startMs, endMs) {
|
||||
const s = startMs && Number.isFinite(startMs) ? new Date(startMs) : new Date();
|
||||
const e = endMs && Number.isFinite(endMs) ? new Date(endMs) : new Date();
|
||||
if (s.getFullYear() !== e.getFullYear()) {
|
||||
return `${s.getFullYear()}年${s.getMonth() + 1}月${s.getDate()}日 ~ ${e.getFullYear()}年${e.getMonth() + 1}月${e.getDate()}日`;
|
||||
}
|
||||
return `${s.getMonth() + 1}月${s.getDate()}日 ~ ${e.getMonth() + 1}月${e.getDate()}日`;
|
||||
}
|
||||
|
||||
@@ -100,3 +103,267 @@ export function formatElapsedSec(seconds) {
|
||||
const remM = m % 60;
|
||||
return `${h}h ${remM}m`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 归一化 Orchestrator 系列 ID 显示格式枚举(`'compact'` 精简代号 vs `'full'` 原始完整 ID,默认 `'compact'`)。
|
||||
*
|
||||
* @param {unknown} mode
|
||||
* @returns {'compact'|'full'}
|
||||
*/
|
||||
export function normalizeOrchestratorIdDisplayMode(mode) {
|
||||
return String(mode ?? '').trim().toLowerCase() === 'full' ? 'full' : 'compact';
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一解析步骤、会话摘要或模型汇总行面向用户的模型显示文本与悬停提示。
|
||||
*
|
||||
* 规则:
|
||||
* - Orchestrator 系列(`Orchestrator (Carbon)`、`Orchestrator (Argon)`、`gemini-flash-worker-agy` / `M669`)
|
||||
* 独立遵循 `orchestratorIdMode`(`'compact'` 显示 `orchestrator-carbon` / `orchestrator-argon` / `worker-agy-hydrogen`;
|
||||
* `'full'` 显示带括号标注的完整上游 ID),不受普通模型“精简代号 / 原始模型 ID”切换影响;
|
||||
* - 其余普通模型继续按 `showUpstreamModel` 与视图选项切换。
|
||||
*
|
||||
* @param {object|null|undefined} target
|
||||
* @param {{ showUpstreamModel?: boolean, orchestratorIdMode?: string }|boolean} [settings]
|
||||
* @param {{ preferLabelInShort?: boolean, fallback?: string }} [options]
|
||||
* @returns {{ text: string, title: string, isOrchestratorSeries: boolean }}
|
||||
*/
|
||||
export function resolveModelDisplayInfo(target, settings = {}, options = {}) {
|
||||
const showUpstream =
|
||||
typeof settings === 'boolean' ? settings : Boolean(settings?.showUpstreamModel);
|
||||
const orchestratorMode = normalizeOrchestratorIdDisplayMode(
|
||||
typeof settings === 'object' && settings ? settings.orchestratorIdMode : 'compact'
|
||||
);
|
||||
const preferLabelInShort = Boolean(options?.preferLabelInShort);
|
||||
const fallback = options?.fallback ?? '模型未知';
|
||||
|
||||
if (!target || typeof target !== 'object') {
|
||||
return { text: fallback, title: fallback, isOrchestratorSeries: false };
|
||||
}
|
||||
|
||||
const shortText = String(
|
||||
target.activeModelShort ?? target.modelShort ?? target.shortName ?? ''
|
||||
).trim();
|
||||
const labelText = String(
|
||||
target.activeModelLabel ?? target.modelLabel ?? target.label ?? ''
|
||||
).trim();
|
||||
const upstreamText = String(
|
||||
target.activeModelUpstream ?? target.modelUpstream ?? target.upstreamName ?? ''
|
||||
).trim();
|
||||
const responseText = String(target.responseModel ?? '').trim();
|
||||
const modelKeyText = String(target.modelKey ?? '').trim();
|
||||
|
||||
const isCompaction =
|
||||
Boolean(target.isCompactionStep) ||
|
||||
/·压缩\s*$/.test(shortText) ||
|
||||
/·压缩\s*$/.test(upstreamText) ||
|
||||
/·压缩\s*$/.test(labelText);
|
||||
|
||||
const combined = `${modelKeyText} ${shortText} ${labelText} ${upstreamText} ${responseText}`;
|
||||
const isOrchWorker =
|
||||
/\bMODEL_PLACEHOLDER_M669\b|\b[a-z0-9.-]*worker-agy\b|\bworker-agy-hydrogen\b|\bOrchestrator\s+Worker\b/i.test(
|
||||
combined
|
||||
);
|
||||
const isOrchSeries =
|
||||
isOrchWorker ||
|
||||
/\bgemini-pro-orchestrator(?:-argon)?\b|\borchestrator-(?:carbon|argon)\b|\borch-(?:carbon|argon)(?:·压缩)?(?=\s|$)|Orchestrator\s*\((?:Carbon|Argon)\)|\bMODEL_PLACEHOLDER_M(?:667|681)\b/i.test(
|
||||
combined
|
||||
);
|
||||
|
||||
if (isOrchSeries) {
|
||||
let compactId = 'orchestrator-carbon';
|
||||
let fullId = 'gemini-pro-orchestrator (carbon-4)';
|
||||
if (isOrchWorker) {
|
||||
compactId = 'worker-agy-hydrogen';
|
||||
fullId = 'gemini-flash-worker-agy (hydrogen-4)';
|
||||
} else if (/\bargon\b|\bMODEL_PLACEHOLDER_M681\b|\borch-argon\b/i.test(combined)) {
|
||||
compactId = 'orchestrator-argon';
|
||||
fullId = 'gemini-pro-orchestrator-argon (argon-4)';
|
||||
}
|
||||
const suffix = isCompaction ? '·压缩' : '';
|
||||
const text = `${orchestratorMode === 'full' ? fullId : compactId}${suffix}`;
|
||||
const multiUpstream =
|
||||
Array.isArray(target.upstreamModels) && target.upstreamModels.length > 1
|
||||
? target.upstreamModels.join(' / ')
|
||||
: '';
|
||||
const title = multiUpstream || `${fullId}${suffix}`;
|
||||
return { text, title, isOrchestratorSeries: true };
|
||||
}
|
||||
|
||||
const standardText =
|
||||
(showUpstream
|
||||
? upstreamText || responseText || shortText || labelText
|
||||
: preferLabelInShort
|
||||
? labelText || shortText
|
||||
: shortText || labelText) || fallback;
|
||||
const standardTitle =
|
||||
showUpstream && Array.isArray(target.upstreamModels) && target.upstreamModels.length > 1
|
||||
? target.upstreamModels.join(' / ')
|
||||
: standardText;
|
||||
return { text: standardText, title: standardTitle, isOrchestratorSeries: false };
|
||||
}
|
||||
|
||||
/**
|
||||
* 按当前显示策略 (`resolveModelDisplayInfo`) 解析出的最终展示名称对模型统计列表执行二次去重归并,
|
||||
* 确保当多个外层模型槽位映射到同一展示名(例如切换至“原始模型 ID”后共享同一 `upstreamName`)时,
|
||||
* 不会在排行榜或总览中出现重复同名行,同时完整累加 Token、调用次数、未定价计数与速度/首字加权均值。
|
||||
*
|
||||
* @param {object[]} [models=[]]
|
||||
* @param {object|boolean} [settings={}]
|
||||
* @param {{ preferLabelInShort?: boolean, fallback?: string }} [options={}]
|
||||
* @returns {object[]}
|
||||
*/
|
||||
export function mergeModelsByDisplayName(models = [], settings = {}, options = {}) {
|
||||
if (!Array.isArray(models) || models.length === 0) return [];
|
||||
const showUpstream =
|
||||
typeof settings === 'boolean' ? settings : Boolean(settings?.showUpstreamModel);
|
||||
const byDisplay = new Map();
|
||||
|
||||
for (const m of models) {
|
||||
if (!m || typeof m !== 'object') continue;
|
||||
const disp = resolveModelDisplayInfo(m, settings, options);
|
||||
const key = String(disp.text || options?.fallback || '—').trim() || '—';
|
||||
|
||||
const calls = Math.max(0, Number(m.calls || 0));
|
||||
const inTok = Math.max(0, Number(m.inputTokens || 0));
|
||||
const cacheTok = Math.max(0, Number(m.cacheReadTokens || 0));
|
||||
const outTok = Math.max(0, Number(m.outputTokens || 0));
|
||||
const thinkTok = Math.max(0, Number(m.thinkingTokens || 0));
|
||||
const respTok =
|
||||
m.responseTokens != null
|
||||
? Math.max(0, Number(m.responseTokens))
|
||||
: Math.max(0, outTok - thinkTok);
|
||||
const totTok = Math.max(0, Number(m.totalTokens ?? inTok + cacheTok + outTok));
|
||||
const costUsd = Number.isFinite(Number(m.costUsd)) ? Math.max(0, Number(m.costUsd)) : 0;
|
||||
const unpricedCalls = Math.max(0, Number(m.unpricedCalls || 0));
|
||||
|
||||
const speedSampleCount = Math.max(0, Number(m.speedSummary?.sampleCount || 0));
|
||||
const speedExcludedCount = Math.max(0, Number(m.speedSummary?.excludedCount || 0));
|
||||
const speedWeight = speedSampleCount > 0 ? speedSampleCount : Math.max(1, outTok || calls || 1);
|
||||
const hasSpeed = m.avgTokPerSec != null && Number.isFinite(Number(m.avgTokPerSec)) && Number(m.avgTokPerSec) > 0;
|
||||
|
||||
const ttftSampleCount = Math.max(0, Number(m.ttftSampleCount || 0));
|
||||
const ttftWeight = ttftSampleCount > 0 ? ttftSampleCount : Math.max(1, calls || 1);
|
||||
const hasTtft = m.avgTtftSec != null && Number.isFinite(Number(m.avgTtftSec)) && Number(m.avgTtftSec) >= 0;
|
||||
|
||||
let acc = byDisplay.get(key);
|
||||
if (!acc) {
|
||||
acc = {
|
||||
baseItem: m,
|
||||
mergedCount: 1,
|
||||
displayText: key,
|
||||
firstTitle: disp.title || key,
|
||||
titleSet: new Set(disp.title ? [disp.title] : []),
|
||||
upstreamSet: new Set(
|
||||
Array.isArray(m.upstreamModels) ? m.upstreamModels.filter(Boolean) : []
|
||||
),
|
||||
sourceLabels: m.label ? [m.label] : [],
|
||||
calls,
|
||||
inputTokens: inTok,
|
||||
cacheReadTokens: cacheTok,
|
||||
outputTokens: outTok,
|
||||
thinkingTokens: thinkTok,
|
||||
responseTokens: respTok,
|
||||
totalTokens: totTok,
|
||||
costUsd,
|
||||
unpricedCalls,
|
||||
speedWeightedSum: hasSpeed ? Number(m.avgTokPerSec) * speedWeight : 0,
|
||||
speedWeight: hasSpeed ? speedWeight : 0,
|
||||
speedSampleCount,
|
||||
speedExcludedCount,
|
||||
ttftWeightedSum: hasTtft ? Number(m.avgTtftSec) * ttftWeight : 0,
|
||||
ttftWeight: hasTtft ? ttftWeight : 0,
|
||||
ttftSampleCount,
|
||||
};
|
||||
if (m.upstreamName) acc.upstreamSet.add(m.upstreamName);
|
||||
byDisplay.set(key, acc);
|
||||
continue;
|
||||
}
|
||||
|
||||
acc.mergedCount += 1;
|
||||
if (disp.title) acc.titleSet.add(disp.title);
|
||||
if (Array.isArray(m.upstreamModels)) {
|
||||
for (const u of m.upstreamModels) {
|
||||
if (u) acc.upstreamSet.add(u);
|
||||
}
|
||||
}
|
||||
if (m.upstreamName) acc.upstreamSet.add(m.upstreamName);
|
||||
if (m.label && !acc.sourceLabels.includes(m.label)) {
|
||||
acc.sourceLabels.push(m.label);
|
||||
}
|
||||
|
||||
acc.calls += calls;
|
||||
acc.inputTokens += inTok;
|
||||
acc.cacheReadTokens += cacheTok;
|
||||
acc.outputTokens += outTok;
|
||||
acc.thinkingTokens += thinkTok;
|
||||
acc.responseTokens += respTok;
|
||||
acc.totalTokens += totTok;
|
||||
acc.costUsd += costUsd;
|
||||
acc.unpricedCalls += unpricedCalls;
|
||||
|
||||
if (hasSpeed) {
|
||||
acc.speedWeightedSum += Number(m.avgTokPerSec) * speedWeight;
|
||||
acc.speedWeight += speedWeight;
|
||||
}
|
||||
acc.speedSampleCount += speedSampleCount;
|
||||
acc.speedExcludedCount += speedExcludedCount;
|
||||
|
||||
if (hasTtft) {
|
||||
acc.ttftWeightedSum += Number(m.avgTtftSec) * ttftWeight;
|
||||
acc.ttftWeight += ttftWeight;
|
||||
}
|
||||
acc.ttftSampleCount += ttftSampleCount;
|
||||
}
|
||||
|
||||
return Array.from(byDisplay.values()).map((acc) => {
|
||||
if (acc.mergedCount === 1) {
|
||||
return {
|
||||
...acc.baseItem,
|
||||
displayText: acc.displayText,
|
||||
displayTitle: acc.firstTitle,
|
||||
sourceLabels: acc.sourceLabels,
|
||||
};
|
||||
}
|
||||
const promptTok = acc.inputTokens + acc.cacheReadTokens;
|
||||
const cacheHitPct = promptTok > 0 ? +((acc.cacheReadTokens / promptTok) * 100).toFixed(1) : 0;
|
||||
const avgTokPerSec =
|
||||
acc.speedWeight > 0 ? +(acc.speedWeightedSum / acc.speedWeight).toFixed(1) : null;
|
||||
const avgTtftSec =
|
||||
acc.ttftWeight > 0 ? +(acc.ttftWeightedSum / acc.ttftWeight).toFixed(1) : null;
|
||||
const upstreamModels = Array.from(acc.upstreamSet);
|
||||
const displayTitle =
|
||||
showUpstream && upstreamModels.length > 1
|
||||
? upstreamModels.join(' / ')
|
||||
: Array.from(acc.titleSet).join(' / ') || acc.displayText;
|
||||
|
||||
return {
|
||||
...acc.baseItem,
|
||||
calls: acc.calls,
|
||||
inputTokens: acc.inputTokens,
|
||||
cacheReadTokens: acc.cacheReadTokens,
|
||||
outputTokens: acc.outputTokens,
|
||||
thinkingTokens: acc.thinkingTokens,
|
||||
responseTokens: acc.responseTokens,
|
||||
totalTokens: acc.totalTokens,
|
||||
costUsd: +acc.costUsd.toFixed(6),
|
||||
unpricedCalls: acc.unpricedCalls,
|
||||
cacheHitPct,
|
||||
avgTokPerSec,
|
||||
avgTtftSec,
|
||||
ttftSampleCount: acc.ttftSampleCount,
|
||||
speedSummary: acc.baseItem.speedSummary
|
||||
? {
|
||||
...acc.baseItem.speedSummary,
|
||||
sampleCount: acc.speedSampleCount,
|
||||
excludedCount: acc.speedExcludedCount,
|
||||
avgTokPerSec,
|
||||
}
|
||||
: undefined,
|
||||
upstreamModels,
|
||||
displayText: acc.displayText,
|
||||
displayTitle,
|
||||
sourceLabels: acc.sourceLabels,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6,8 +6,13 @@
|
||||
import { createReactiveStore } from '../core/reactive.js';
|
||||
import { callSidecarApi, isWindowOverlayMode } from '../core/httpClient.js';
|
||||
|
||||
const CASCADE_UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
|
||||
/**
|
||||
* 在主窗口双栖模式下,从宿主页面路径 `/c/<uuid>` 提取当前正在浏览的会话 ID。
|
||||
* 在主窗口双栖模式下,提取当前正在浏览的会话 ID:
|
||||
* 1. 优先解析 Antigravity 2.0 路由路径 `/c/<uuid>`;
|
||||
* 2. 在 Antigravity IDE (`workbench.html`) 无路径路由时,回退读取活跃对话视图
|
||||
* `[data-testid="conversation-view"][data-cascade-id]` 或侧栏选中项。
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
@@ -15,7 +20,63 @@ export function extractHostRouteCascadeId() {
|
||||
if (typeof window === 'undefined' || !isWindowOverlayMode()) return '';
|
||||
const pathname = String(window.location?.pathname || '');
|
||||
const m = pathname.match(/^\/c\/([a-f0-9-]{36})(?:\/|$)/i);
|
||||
return m ? m[1] : '';
|
||||
if (m && CASCADE_UUID_RE.test(m[1])) {
|
||||
return m[1];
|
||||
}
|
||||
const extBridgeRouteId = String(window.__AGUsageMonitorBridge?.hostRouteCascadeId || '').trim();
|
||||
if (extBridgeRouteId && CASCADE_UUID_RE.test(extBridgeRouteId)) {
|
||||
return extBridgeRouteId;
|
||||
}
|
||||
try {
|
||||
if (typeof document === 'undefined' || typeof document.querySelector !== 'function') {
|
||||
return '';
|
||||
}
|
||||
const selectedRow = document.querySelector(
|
||||
'[data-testid^="conversation-row-"][data-selected="true"][data-cascade-id]'
|
||||
);
|
||||
const selectedRowId = String(selectedRow?.getAttribute?.('data-cascade-id') || '').trim();
|
||||
|
||||
if (typeof document.querySelectorAll === 'function') {
|
||||
const views = document.querySelectorAll('[data-testid="conversation-view"][data-cascade-id]');
|
||||
const visibleIds = [];
|
||||
let focusedId = '';
|
||||
const activeEl = document.activeElement || null;
|
||||
for (const viewEl of views) {
|
||||
const cid = String(viewEl?.getAttribute?.('data-cascade-id') || '').trim();
|
||||
if (!CASCADE_UUID_RE.test(cid)) continue;
|
||||
if (viewEl.hasAttribute?.('hidden')) continue;
|
||||
if (viewEl.getBoundingClientRect) {
|
||||
const r = viewEl.getBoundingClientRect();
|
||||
if (r.width <= 0 && r.height <= 0) continue;
|
||||
}
|
||||
visibleIds.push(cid);
|
||||
if (activeEl && viewEl.contains?.(activeEl)) {
|
||||
focusedId = cid;
|
||||
}
|
||||
}
|
||||
if (focusedId) return focusedId;
|
||||
if (
|
||||
selectedRowId &&
|
||||
CASCADE_UUID_RE.test(selectedRowId) &&
|
||||
visibleIds.some((id) => id.toLowerCase() === selectedRowId.toLowerCase())
|
||||
) {
|
||||
return selectedRowId;
|
||||
}
|
||||
if (visibleIds.length > 0) return visibleIds[0];
|
||||
}
|
||||
|
||||
const singleView = document.querySelector('[data-testid="conversation-view"][data-cascade-id]');
|
||||
const singleViewId = String(singleView?.getAttribute?.('data-cascade-id') || '').trim();
|
||||
if (CASCADE_UUID_RE.test(singleViewId)) {
|
||||
return singleViewId;
|
||||
}
|
||||
if (CASCADE_UUID_RE.test(selectedRowId)) {
|
||||
return selectedRowId;
|
||||
}
|
||||
} catch {
|
||||
// 忽略宿主 DOM 查询异常
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
const initialConversationId =
|
||||
@@ -88,19 +149,67 @@ export function normalizeClientUpdateMode(mode, legacyAutoUpdate) {
|
||||
return 'manual';
|
||||
}
|
||||
|
||||
export function normalizeClientOrchestratorIdMode(mode) {
|
||||
return String(mode ?? '').trim().toLowerCase() === 'full' ? 'full' : 'compact';
|
||||
}
|
||||
|
||||
/**
|
||||
* 归一化前端面板挂载方式(`'dual'` | `'composer'` | `'sidebar'`),兼容旧版 `enableWindowOverlay` 布尔字段。
|
||||
*
|
||||
* @param {unknown} mode
|
||||
* @param {unknown} [legacyEnableOverlay]
|
||||
* @returns {'dual'|'composer'|'sidebar'}
|
||||
*/
|
||||
export function normalizeClientWindowMountMode(mode, legacyEnableOverlay) {
|
||||
const m = String(mode ?? '').trim().toLowerCase();
|
||||
if (m === 'composer' || m === 'input') return 'composer';
|
||||
if (m === 'sidebar' || m === 'off') return 'sidebar';
|
||||
if (m === 'dual' || m === 'topbar') return 'dual';
|
||||
if (legacyEnableOverlay === false) return 'sidebar';
|
||||
return 'dual';
|
||||
}
|
||||
|
||||
function isEquivalentTelemetry(prev, next) {
|
||||
if (!prev || !next) return false;
|
||||
if (prev === next) return true;
|
||||
|
||||
// 1. 比对系统设置项(模型显示策略、周预算模式与额度、插件更新策略、双栖与顶栏槽位配置)
|
||||
// 1. 比对系统设置项(模型显示策略、Orchestrator ID 显示风格、周预算模式与额度、插件更新策略、双栖与顶栏槽位配置)
|
||||
const pAct = prev.activeConversation;
|
||||
const nAct = next.activeConversation;
|
||||
if (prev.settings?.showUpstreamModel !== next.settings?.showUpstreamModel) return false;
|
||||
const prevOrchIdMode = String(prev.settings?.orchestratorIdMode ?? 'compact').trim().toLowerCase() === 'full' ? 'full' : 'compact';
|
||||
const nextOrchIdMode = String(next.settings?.orchestratorIdMode ?? 'compact').trim().toLowerCase() === 'full' ? 'full' : 'compact';
|
||||
if (prevOrchIdMode !== nextOrchIdMode) {
|
||||
return false;
|
||||
}
|
||||
if (prev.settings?.weeklyLimitMode !== next.settings?.weeklyLimitMode) return false;
|
||||
if (prev.settings?.weeklyTokenBudget !== next.settings?.weeklyTokenBudget) return false;
|
||||
if (prev.settings?.weeklyCostBudget !== next.settings?.weeklyCostBudget) return false;
|
||||
if ((prev.settings?.pluginUpdateMode ?? '') !== (next.settings?.pluginUpdateMode ?? '')) return false;
|
||||
if (prev.settings?.autoUpdatePlugin !== next.settings?.autoUpdatePlugin) return false;
|
||||
const rawPrevMount = String(prev.settings?.windowMountMode ?? '').trim().toLowerCase();
|
||||
const prevMountMode =
|
||||
rawPrevMount === 'composer' || rawPrevMount === 'input'
|
||||
? 'composer'
|
||||
: rawPrevMount === 'sidebar' || rawPrevMount === 'off'
|
||||
? 'sidebar'
|
||||
: rawPrevMount === 'dual' || rawPrevMount === 'topbar'
|
||||
? 'dual'
|
||||
: prev.settings?.enableWindowOverlay === false
|
||||
? 'sidebar'
|
||||
: 'dual';
|
||||
const rawNextMount = String(next.settings?.windowMountMode ?? '').trim().toLowerCase();
|
||||
const nextMountMode =
|
||||
rawNextMount === 'composer' || rawNextMount === 'input'
|
||||
? 'composer'
|
||||
: rawNextMount === 'sidebar' || rawNextMount === 'off'
|
||||
? 'sidebar'
|
||||
: rawNextMount === 'dual' || rawNextMount === 'topbar'
|
||||
? 'dual'
|
||||
: next.settings?.enableWindowOverlay === false
|
||||
? 'sidebar'
|
||||
: 'dual';
|
||||
if (prevMountMode !== nextMountMode) return false;
|
||||
if (prev.settings?.enableWindowOverlay !== next.settings?.enableWindowOverlay) return false;
|
||||
if ((prev.settings?.showTopbarMultiSession !== false) !== (next.settings?.showTopbarMultiSession !== false)) {
|
||||
return false;
|
||||
@@ -250,8 +359,12 @@ function isEquivalentTelemetry(prev, next) {
|
||||
bs?.tokPerSec !== as?.tokPerSec ||
|
||||
bs?.ttftSec !== as?.ttftSec ||
|
||||
bs?.outputTokens !== as?.outputTokens ||
|
||||
bs?.thinkingTokens !== as?.thinkingTokens ||
|
||||
bs?.responseTokens !== as?.responseTokens ||
|
||||
bs?.inputTokens !== as?.inputTokens ||
|
||||
bs?.cacheReadTokens !== as?.cacheReadTokens ||
|
||||
bs?.contextTokens !== as?.contextTokens ||
|
||||
bs?.cacheHitPct !== as?.cacheHitPct ||
|
||||
bs?.selectedSpeedReason !== as?.selectedSpeedReason
|
||||
) {
|
||||
return false;
|
||||
@@ -290,8 +403,12 @@ function isEquivalentTelemetry(prev, next) {
|
||||
before.tokPerSec !== after.tokPerSec ||
|
||||
before.ttftSec !== after.ttftSec ||
|
||||
before.outputTokens !== after.outputTokens ||
|
||||
before.thinkingTokens !== after.thinkingTokens ||
|
||||
before.responseTokens !== after.responseTokens ||
|
||||
before.inputTokens !== after.inputTokens ||
|
||||
before.cacheReadTokens !== after.cacheReadTokens ||
|
||||
before.contextTokens !== after.contextTokens ||
|
||||
before.cacheHitPct !== after.cacheHitPct ||
|
||||
before.selectedSpeedReason !== after.selectedSpeedReason
|
||||
) {
|
||||
return false;
|
||||
@@ -428,7 +545,13 @@ function isEquivalentTelemetry(prev, next) {
|
||||
pPools[i]?.resetTime !== nPools[i]?.resetTime ||
|
||||
pPools[i]?.weeklyUsedPct !== nPools[i]?.weeklyUsedPct ||
|
||||
pPools[i]?.weeklyRemainingPct !== nPools[i]?.weeklyRemainingPct ||
|
||||
pPools[i]?.weeklyResetTime !== nPools[i]?.weeklyResetTime
|
||||
pPools[i]?.weeklyResetTime !== nPools[i]?.weeklyResetTime ||
|
||||
pPools[i]?.cycle5h?.tokens !== nPools[i]?.cycle5h?.tokens ||
|
||||
pPools[i]?.cycle5h?.costUsd !== nPools[i]?.cycle5h?.costUsd ||
|
||||
pPools[i]?.cycle5h?.calls !== nPools[i]?.cycle5h?.calls ||
|
||||
pPools[i]?.cycleWeekly?.tokens !== nPools[i]?.cycleWeekly?.tokens ||
|
||||
pPools[i]?.cycleWeekly?.costUsd !== nPools[i]?.cycleWeekly?.costUsd ||
|
||||
pPools[i]?.cycleWeekly?.calls !== nPools[i]?.cycleWeekly?.calls
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
@@ -613,6 +736,20 @@ export async function saveSettingsPatch(patch) {
|
||||
if (Object.prototype.hasOwnProperty.call(safePatch, 'topbarCapsuleSlots')) {
|
||||
safePatch.topbarCapsuleSlots = normalizeClientTopbarSlots(safePatch.topbarCapsuleSlots);
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(safePatch, 'orchestratorIdMode')) {
|
||||
safePatch.orchestratorIdMode = normalizeClientOrchestratorIdMode(safePatch.orchestratorIdMode);
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(safePatch, 'windowMountMode')) {
|
||||
const normMount = normalizeClientWindowMountMode(
|
||||
safePatch.windowMountMode,
|
||||
safePatch.enableWindowOverlay
|
||||
);
|
||||
safePatch.windowMountMode = normMount;
|
||||
safePatch.enableWindowOverlay = normMount !== 'sidebar';
|
||||
} else if (Object.prototype.hasOwnProperty.call(safePatch, 'enableWindowOverlay')) {
|
||||
safePatch.enableWindowOverlay = Boolean(safePatch.enableWindowOverlay);
|
||||
safePatch.windowMountMode = safePatch.enableWindowOverlay ? 'dual' : 'sidebar';
|
||||
}
|
||||
const prevTelemetry = telemetryStore.getState().telemetry;
|
||||
if (prevTelemetry?.settings) {
|
||||
telemetryStore.setState({
|
||||
|
||||
@@ -52,10 +52,10 @@ input {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
max-width: 560px;
|
||||
max-width: none;
|
||||
height: 100dvh;
|
||||
max-height: 100dvh;
|
||||
margin: 0 auto;
|
||||
margin: 0;
|
||||
padding: var(--space-3) var(--space-4);
|
||||
gap: var(--space-3);
|
||||
overflow: hidden;
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.steps-inline-scope-select .select-menu {
|
||||
.steps-inline-scope-select .select-menu,
|
||||
.steps-inline-model-select .select-menu {
|
||||
left: auto;
|
||||
right: 0;
|
||||
min-width: 220px;
|
||||
@@ -212,6 +213,10 @@
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.custom-select[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.select-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -296,6 +301,41 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.select-option-meta {
|
||||
font-size: 11px;
|
||||
flex-shrink: 0;
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
.select-checkbox {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
border-radius: 3px;
|
||||
border: 1px solid var(--border-strong);
|
||||
background: transparent;
|
||||
color: var(--text-inverse);
|
||||
flex-shrink: 0;
|
||||
transition:
|
||||
background-color var(--dur-instant) var(--ease-fast),
|
||||
border-color var(--dur-instant) var(--ease-fast);
|
||||
}
|
||||
|
||||
.select-checkbox[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.select-checkbox.is-checked {
|
||||
background: var(--accent-primary);
|
||||
border-color: var(--accent-primary);
|
||||
}
|
||||
|
||||
.select-checkbox .svg-icon {
|
||||
stroke-width: 2.4;
|
||||
}
|
||||
|
||||
/* --- 4. 定制步进数字框 (Bespoke Custom Number Input,零原生 <input type="number">) --- */
|
||||
.number-input {
|
||||
display: inline-flex;
|
||||
|
||||
@@ -32,6 +32,44 @@
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
:host(.wm-capsule-host[data-dock="composer"]) {
|
||||
position: relative;
|
||||
height: 26px;
|
||||
gap: 4px;
|
||||
margin-right: 4px;
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
:host(.wm-capsule-host[data-dock="composer"][data-composer-push="1"]) {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
:host(.wm-capsule-host[data-dock="composer"]) .wm-multi-btn,
|
||||
:host(.wm-capsule-host[data-dock="composer"]) .wm-capsule-btn {
|
||||
height: 26px;
|
||||
border-radius: var(--radius-pill);
|
||||
}
|
||||
|
||||
:host(.wm-capsule-host[data-dock="composer"]) .wm-multi-btn {
|
||||
padding: 0 7px;
|
||||
}
|
||||
|
||||
:host(.wm-capsule-host[data-dock="composer"]) .wm-capsule-btn {
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
:host(.wm-capsule-host[data-dock="ide-titlebar"]) {
|
||||
position: relative;
|
||||
margin-left: auto;
|
||||
margin-right: 8px;
|
||||
z-index: 2501;
|
||||
--text-primary: var(
|
||||
--vscode-titleBar-activeForeground,
|
||||
var(--foreground, var(--vscode-foreground, hsl(215 22% 15%)))
|
||||
);
|
||||
--text-secondary: color-mix(in srgb, var(--text-primary) 78%, transparent);
|
||||
}
|
||||
|
||||
:host(.wm-capsule-host[data-dock="fixed"]) {
|
||||
position: fixed;
|
||||
top: 6px;
|
||||
@@ -449,11 +487,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes wm-popover-in-up {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(3px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.wm-popover-panel {
|
||||
position: fixed;
|
||||
top: 42px;
|
||||
left: 12px;
|
||||
width: min(492px, calc(100vw - 24px));
|
||||
width: min(522px, calc(100vw - 24px));
|
||||
height: min(588px, calc(100vh - 54px));
|
||||
max-height: calc(100vh - 54px);
|
||||
display: flex;
|
||||
@@ -481,7 +530,7 @@
|
||||
position: fixed;
|
||||
top: 42px;
|
||||
left: 12px;
|
||||
width: min(492px, calc(100vw - 24px));
|
||||
width: min(522px, calc(100vw - 24px));
|
||||
max-height: calc(100vh - 54px);
|
||||
padding: var(--space-3) var(--space-4);
|
||||
display: flex;
|
||||
@@ -505,7 +554,7 @@
|
||||
position: fixed;
|
||||
top: 42px;
|
||||
left: 12px;
|
||||
width: min(484px, calc(100vw - 24px));
|
||||
width: min(464px, calc(100vw - 24px));
|
||||
max-height: calc(100vh - 54px);
|
||||
padding: 14px 16px;
|
||||
display: flex;
|
||||
@@ -526,6 +575,21 @@
|
||||
animation: wm-popover-in var(--dur-instant) var(--ease-fast);
|
||||
}
|
||||
|
||||
.wm-popover-panel.is-above {
|
||||
transform-origin: bottom right;
|
||||
animation-name: wm-popover-in-up;
|
||||
}
|
||||
|
||||
.wm-hover-tip.is-above {
|
||||
transform-origin: bottom right;
|
||||
animation-name: wm-popover-in-up;
|
||||
}
|
||||
|
||||
.wm-multi-panel.is-above {
|
||||
transform-origin: bottom left;
|
||||
animation-name: wm-popover-in-up;
|
||||
}
|
||||
|
||||
.wm-popover-panel.is-instant,
|
||||
.wm-hover-tip.is-instant,
|
||||
.wm-multi-panel.is-instant {
|
||||
|
||||
@@ -11,26 +11,48 @@
|
||||
--radius-sm: 4px;
|
||||
--radius-xs: 2px;
|
||||
|
||||
/* Host-Bridged Surfaces (Clean, zero-muddy-gray light mode & safe dark fallback) */
|
||||
--surface-bg: var(--background, hsl(0 0% 100%));
|
||||
--surface-panel: var(--card, var(--background, hsl(0 0% 100%)));
|
||||
/* Host-Bridged Surfaces (Antigravity 2.0 + Antigravity IDE --vscode-* + safe fallback) */
|
||||
--surface-bg: var(--background, var(--vscode-sideBar-background, var(--vscode-editor-background, hsl(0 0% 100%))));
|
||||
--surface-panel: var(
|
||||
--card,
|
||||
var(
|
||||
--background,
|
||||
var(--vscode-editorWidget-background, var(--vscode-sideBar-background, var(--vscode-editor-background, hsl(0 0% 100%))))
|
||||
)
|
||||
);
|
||||
--surface-subtle: color-mix(in srgb, var(--surface-panel) 97%, var(--text-primary) 3%);
|
||||
--surface-track: color-mix(in srgb, var(--border-hairline) 42%, var(--surface-panel));
|
||||
--surface-hover: color-mix(in srgb, var(--accent-primary) 6%, var(--surface-panel));
|
||||
--surface-active: color-mix(in srgb, var(--accent-primary) 12%, var(--surface-panel));
|
||||
|
||||
/* Crisp 1px Hairline Borders */
|
||||
--border-hairline: color-mix(in srgb, var(--border, hsl(214 18% 88%)) 82%, var(--surface-panel));
|
||||
--border-hairline: color-mix(
|
||||
in srgb,
|
||||
var(
|
||||
--border,
|
||||
var(
|
||||
--vscode-widget-border,
|
||||
var(
|
||||
--vscode-panel-border,
|
||||
var(--vscode-contrastBorder, color-mix(in srgb, var(--text-primary) 18%, var(--surface-panel)))
|
||||
)
|
||||
)
|
||||
) 82%,
|
||||
var(--surface-panel)
|
||||
);
|
||||
--border-strong: color-mix(in srgb, var(--border-hairline) 72%, var(--text-primary) 28%);
|
||||
|
||||
/* Typography Hierarchy */
|
||||
--text-primary: var(--foreground, hsl(215 22% 15%));
|
||||
--text-secondary: var(--muted-foreground, hsl(215 12% 44%));
|
||||
--text-primary: var(--foreground, var(--vscode-foreground, var(--vscode-editor-foreground, hsl(215 22% 15%))));
|
||||
--text-secondary: var(--muted-foreground, var(--vscode-descriptionForeground, hsl(215 12% 44%)));
|
||||
--text-muted: color-mix(in srgb, var(--text-secondary) 74%, var(--surface-panel) 26%);
|
||||
--text-inverse: var(--surface-panel);
|
||||
|
||||
/* Semantic Telemetry Accents */
|
||||
--accent-primary: var(--primary, hsl(217 82% 51%));
|
||||
--accent-primary: var(
|
||||
--primary,
|
||||
var(--vscode-textLink-foreground, var(--vscode-button-background, hsl(217 82% 51%)))
|
||||
);
|
||||
--accent-primary-soft: color-mix(in srgb, var(--accent-primary) 13%, transparent);
|
||||
--accent-primary-border: color-mix(in srgb, var(--accent-primary) 38%, var(--border-hairline));
|
||||
|
||||
@@ -43,7 +65,7 @@
|
||||
--metric-warn: hsl(34 86% 44%);
|
||||
--metric-warn-soft: color-mix(in srgb, var(--metric-warn) 15%, transparent);
|
||||
|
||||
--metric-danger: var(--destructive, hsl(0 74% 50%));
|
||||
--metric-danger: var(--destructive, var(--vscode-errorForeground, hsl(0 74% 50%)));
|
||||
|
||||
/* Context Window 10-Channel Palette */
|
||||
--ctx-assistant: hsl(217 82% 54%);
|
||||
|
||||
@@ -238,7 +238,7 @@
|
||||
|
||||
.trend-svg {
|
||||
width: 100%;
|
||||
height: 118px;
|
||||
height: 120px;
|
||||
display: block;
|
||||
overflow: visible;
|
||||
}
|
||||
@@ -304,9 +304,10 @@
|
||||
top: 0;
|
||||
left: var(--tip-x, 50%);
|
||||
transform: translateX(var(--tip-shift, -50%));
|
||||
min-width: 148px;
|
||||
max-width: 240px;
|
||||
padding: 5px 8px;
|
||||
width: max-content;
|
||||
min-width: 152px;
|
||||
max-width: min(300px, calc(100% - 8px));
|
||||
padding: 5px 9px;
|
||||
background: var(--surface-panel);
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: var(--radius-sm);
|
||||
@@ -322,7 +323,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
gap: 10px;
|
||||
font-size: 10.5px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
@@ -331,42 +332,62 @@
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.trend-tip-calls {
|
||||
font-size: 10px;
|
||||
color: var(--text-muted);
|
||||
white-space: nowrap;
|
||||
max-width: 190px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.trend-tip-main {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.trend-tip-tokens {
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: var(--accent-primary);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.trend-tip-cost {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.trend-tip-sub {
|
||||
font-size: 10px;
|
||||
color: var(--text-secondary);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
border-top: 1px solid var(--border-hairline);
|
||||
padding-top: 2px;
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
.trend-tooltip.is-hm-top {
|
||||
top: 0;
|
||||
bottom: auto;
|
||||
}
|
||||
|
||||
.trend-tooltip.is-hm-bottom {
|
||||
top: auto;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.trend-x-axis {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
@@ -401,6 +422,177 @@
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* --- 4b. 类 GitHub 每日小格子热力图 (> 90 天自动启用,一格一天) --- */
|
||||
.trend-heatmap-stage {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
padding-top: 2px;
|
||||
width: 100%;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.trend-heatmap-body {
|
||||
--hm-weeks: 26;
|
||||
--hm-gap: 2px;
|
||||
--hm-cell: 9px;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 4px;
|
||||
width: 100%;
|
||||
container-type: inline-size;
|
||||
}
|
||||
|
||||
@supports (width: 1cqi) {
|
||||
.trend-heatmap-body {
|
||||
--hm-cell: clamp(
|
||||
6.5px,
|
||||
calc((100cqi - 18px - (var(--hm-weeks) - 1) * var(--hm-gap)) / var(--hm-weeks)),
|
||||
18px
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
.trend-hm-weekdays {
|
||||
display: grid;
|
||||
grid-template-rows: 15px repeat(7, var(--hm-cell));
|
||||
row-gap: var(--hm-gap);
|
||||
width: 14px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.trend-hm-month-spacer {
|
||||
height: 15px;
|
||||
}
|
||||
|
||||
.trend-hm-wday {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
font-size: 9px;
|
||||
line-height: 1;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.trend-hm-scroll {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
.trend-hm-track {
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
gap: var(--hm-gap);
|
||||
min-width: max-content;
|
||||
}
|
||||
|
||||
.trend-hm-months {
|
||||
position: relative;
|
||||
height: 15px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.trend-hm-month {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: calc(var(--hm-col, 0) * (var(--hm-cell) + var(--hm-gap)));
|
||||
font-size: 9.5px;
|
||||
line-height: 14px;
|
||||
color: var(--text-muted);
|
||||
white-space: nowrap;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.trend-hm-grid {
|
||||
display: grid;
|
||||
grid-template-rows: repeat(7, var(--hm-cell));
|
||||
grid-auto-flow: column;
|
||||
grid-auto-columns: var(--hm-cell);
|
||||
gap: var(--hm-gap);
|
||||
}
|
||||
|
||||
.trend-hm-cell {
|
||||
width: var(--hm-cell);
|
||||
height: var(--hm-cell);
|
||||
border-radius: 2px;
|
||||
box-sizing: border-box;
|
||||
cursor: pointer;
|
||||
transition: transform var(--dur-instant) var(--ease-fast);
|
||||
}
|
||||
|
||||
.trend-hm-cell.is-pad {
|
||||
visibility: hidden;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.trend-hm-cell.lv-0,
|
||||
.trend-hm-swatch.lv-0 {
|
||||
background: color-mix(in srgb, var(--text-primary) 6.5%, var(--surface-panel));
|
||||
border: 1px solid color-mix(in srgb, var(--border-hairline) 55%, transparent);
|
||||
}
|
||||
|
||||
.trend-hm-cell.lv-1,
|
||||
.trend-hm-swatch.lv-1 {
|
||||
background: color-mix(in srgb, var(--ctx-cached) 24%, var(--surface-panel));
|
||||
}
|
||||
|
||||
.trend-hm-cell.lv-2,
|
||||
.trend-hm-swatch.lv-2 {
|
||||
background: color-mix(in srgb, var(--ctx-cached) 46%, var(--surface-panel));
|
||||
}
|
||||
|
||||
.trend-hm-cell.lv-3,
|
||||
.trend-hm-swatch.lv-3 {
|
||||
background: color-mix(in srgb, var(--ctx-cached) 70%, var(--surface-panel));
|
||||
}
|
||||
|
||||
.trend-hm-cell.lv-4,
|
||||
.trend-hm-swatch.lv-4 {
|
||||
background: color-mix(in srgb, var(--ctx-cached) 94%, var(--surface-panel));
|
||||
}
|
||||
|
||||
.trend-hm-cell.is-hovered {
|
||||
outline: 1.5px solid var(--text-primary);
|
||||
outline-offset: 0.5px;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.trend-hm-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
font-size: 10px;
|
||||
color: var(--text-muted);
|
||||
min-height: 16px;
|
||||
}
|
||||
|
||||
.trend-hm-summary {
|
||||
color: var(--text-secondary);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.trend-hm-legend {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
flex-shrink: 0;
|
||||
font-size: 9.5px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.trend-hm-swatch {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 2px;
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* --- 5. 模型与数据来源明细行容器 (Popular Models & Sources Item Rows) --- */
|
||||
.cons-item-list {
|
||||
display: flex;
|
||||
@@ -423,6 +615,10 @@
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.cons-item-foot > .legend-left:last-child {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.cons-item-foot strong {
|
||||
color: var(--text-primary);
|
||||
font-weight: 600;
|
||||
|
||||
@@ -53,6 +53,46 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* 配额池窗口行头:标题 + 周期用量内联(窄栏自适应截断,零额外纵向行高) */
|
||||
.quota-win-head {
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.quota-win-left {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 5px;
|
||||
min-width: 0;
|
||||
flex: 1 1 auto;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.quota-win-title {
|
||||
font-size: 11.5px;
|
||||
font-weight: 500;
|
||||
color: var(--text-primary);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.quota-win-usage {
|
||||
font-family: var(--font-mono);
|
||||
font-variant-numeric: tabular-nums;
|
||||
font-size: 10.5px;
|
||||
font-weight: 400;
|
||||
color: var(--text-muted);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.quota-win-meta {
|
||||
font-size: 11px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* --- 2. 多任务实时运行卡片列表与 4 格测速指标矩阵 (Live Running Tasks List & 4-Cell Telemetry Matrix) --- */
|
||||
.live-activity-list {
|
||||
display: flex;
|
||||
|
||||
@@ -44,13 +44,13 @@
|
||||
|
||||
.data-table th:first-child,
|
||||
.data-table td:first-child {
|
||||
padding-left: 7px;
|
||||
padding-left: 2px;
|
||||
}
|
||||
|
||||
.data-table th:last-child,
|
||||
.data-table td:last-child {
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.data-table th {
|
||||
@@ -88,13 +88,15 @@
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.steps-inline-scope-select {
|
||||
flex: 0 1 180px;
|
||||
.steps-inline-scope-select,
|
||||
.steps-inline-model-select {
|
||||
flex: 0 1 165px;
|
||||
min-width: 72px;
|
||||
max-width: 190px;
|
||||
max-width: 175px;
|
||||
}
|
||||
|
||||
.steps-inline-scope-select .select-trigger {
|
||||
.steps-inline-scope-select .select-trigger,
|
||||
.steps-inline-model-select .select-trigger {
|
||||
height: 22px;
|
||||
padding: 0 6px;
|
||||
gap: 4px;
|
||||
@@ -104,3 +106,473 @@
|
||||
border: 1px solid var(--border-hairline);
|
||||
background: var(--surface-subtle);
|
||||
}
|
||||
|
||||
/* --- 3. 按模型汇总分析视图:双趋势图与极简模型总览 (Models Analytics Pane) --- */
|
||||
.models-analytics-pane {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
padding: var(--space-3) 0 2px;
|
||||
}
|
||||
|
||||
.sstep-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
padding: var(--space-3) var(--space-4);
|
||||
background: var(--surface-panel);
|
||||
border: 1px solid var(--border-hairline);
|
||||
border-radius: var(--radius-xs);
|
||||
}
|
||||
|
||||
.sstep-card-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.sstep-card-title-group {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.sstep-card-title {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.sstep-card .seg-btn {
|
||||
padding: 2px 6px;
|
||||
font-size: 10.5px;
|
||||
}
|
||||
|
||||
.sstep-fit-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.sstep-fit-model-select {
|
||||
min-width: 96px;
|
||||
max-width: 176px;
|
||||
}
|
||||
|
||||
.sstep-fit-model-select .select-trigger {
|
||||
height: 22px;
|
||||
padding: 0 6px;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
font-size: 10.5px;
|
||||
border: 1px solid var(--border-hairline);
|
||||
background: var(--surface-subtle);
|
||||
}
|
||||
|
||||
.sstep-chart-wrap {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.sstep-plot-stage {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
padding-top: 4px;
|
||||
cursor: crosshair;
|
||||
}
|
||||
|
||||
.sstep-svg {
|
||||
width: 100%;
|
||||
height: 106px;
|
||||
display: block;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.sstep-fit-svg {
|
||||
height: 136px;
|
||||
}
|
||||
|
||||
.sstep-sci-grid line {
|
||||
stroke: var(--border-hairline);
|
||||
stroke-width: 0.9;
|
||||
stroke-dasharray: 2 3;
|
||||
}
|
||||
|
||||
.sstep-axis-spine {
|
||||
stroke: var(--border-strong);
|
||||
stroke-width: 1;
|
||||
shape-rendering: crispEdges;
|
||||
}
|
||||
|
||||
.sstep-axis-tick {
|
||||
stroke: var(--border-strong);
|
||||
stroke-width: 1;
|
||||
shape-rendering: crispEdges;
|
||||
}
|
||||
|
||||
.sstep-axis-label {
|
||||
fill: var(--text-muted);
|
||||
font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
|
||||
font-size: 9.5px;
|
||||
user-select: none;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.sstep-axis-label.is-y-inline {
|
||||
paint-order: stroke;
|
||||
stroke: var(--surface-panel);
|
||||
stroke-width: 2.5px;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
|
||||
.sstep-line-card .trend-line {
|
||||
stroke: var(--sstep-accent, var(--ctx-cached));
|
||||
stroke-width: 1.9;
|
||||
}
|
||||
|
||||
.sstep-multi-area {
|
||||
fill: var(--sstep-series-color, var(--ctx-cached));
|
||||
fill-opacity: 0.08;
|
||||
stroke: none;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.sstep-series-single-dot {
|
||||
fill: var(--sstep-series-color, var(--ctx-cached));
|
||||
stroke: var(--surface-panel);
|
||||
stroke-width: 1.3;
|
||||
}
|
||||
|
||||
.sstep-svg .trend-hover-dot {
|
||||
stroke: var(--hover-dot-color, var(--sstep-accent, var(--accent-primary)));
|
||||
}
|
||||
|
||||
.sstep-line-card .trend-peak-pill {
|
||||
background: color-mix(in srgb, var(--sstep-accent, var(--ctx-cached)) 14%, var(--surface-panel));
|
||||
border-color: color-mix(in srgb, var(--sstep-accent, var(--ctx-cached)) 30%, var(--border-hairline));
|
||||
}
|
||||
|
||||
.sstep-node-dot {
|
||||
fill: var(--surface-panel);
|
||||
stroke: var(--dot-stroke, var(--sstep-accent, var(--ctx-cached)));
|
||||
stroke-width: 1.45;
|
||||
}
|
||||
|
||||
.sstep-node-dot.is-skipped {
|
||||
fill: transparent;
|
||||
stroke: var(--border-strong);
|
||||
stroke-width: 1;
|
||||
stroke-dasharray: 1.5 1.5;
|
||||
opacity: 0.65;
|
||||
}
|
||||
|
||||
.sstep-ci-band {
|
||||
fill: var(--sstep-fit-accent, var(--ctx-cached));
|
||||
fill-opacity: 0.14;
|
||||
stroke: var(--sstep-fit-accent, var(--ctx-cached));
|
||||
stroke-opacity: 0.24;
|
||||
stroke-width: 0.75;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.sstep-ci-band.is-multi {
|
||||
fill-opacity: 0.1;
|
||||
stroke-opacity: 0.18;
|
||||
}
|
||||
|
||||
.sstep-fit-line {
|
||||
stroke: var(--sstep-fit-accent, var(--ctx-cached));
|
||||
stroke-width: 2;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
|
||||
.sstep-ols-line {
|
||||
stroke: color-mix(in srgb, var(--text-secondary) 72%, var(--surface-panel));
|
||||
stroke-width: 1.1;
|
||||
stroke-dasharray: 3.5 3;
|
||||
}
|
||||
|
||||
.sstep-scatter-dot {
|
||||
fill: color-mix(in srgb, var(--sstep-fit-accent, var(--ctx-cached)) 48%, var(--text-secondary) 52%);
|
||||
fill-opacity: 0.42;
|
||||
stroke: none;
|
||||
}
|
||||
|
||||
.sstep-scatter-dot.is-multi {
|
||||
fill: var(--sstep-fit-accent, var(--ctx-cached));
|
||||
fill-opacity: 0.48;
|
||||
}
|
||||
|
||||
.sstep-fit-svg .trend-hover-dot {
|
||||
stroke: var(--hover-dot-color, var(--accent-primary));
|
||||
}
|
||||
|
||||
.sstep-hover-raw-dot {
|
||||
fill: var(--surface-panel);
|
||||
stroke: var(--text-primary);
|
||||
stroke-width: 1.6;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.sstep-empty-hint {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 11px;
|
||||
pointer-events: none;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.sstep-model-legend {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 10px;
|
||||
padding-top: 2px;
|
||||
font-size: 10px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.sstep-legend-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.sstep-legend-dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: var(--radius-pill);
|
||||
background: var(--swatch-bg, var(--ctx-cached));
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.sstep-legend-line {
|
||||
width: 11px;
|
||||
height: 2px;
|
||||
border-radius: 1px;
|
||||
background: var(--swatch-bg, var(--ctx-cached));
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.sstep-fit-legend[hidden],
|
||||
.sstep-model-legend[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.sstep-fit-foot {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 8px;
|
||||
padding-top: 2px;
|
||||
font-size: 10px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.sstep-fit-legend {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 5px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.sstep-fit-legend-ols {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.sstep-fit-legend-ols[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sstep-fit-swatch {
|
||||
display: inline-block;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.sstep-fit-swatch.is-scatter {
|
||||
width: 5.5px;
|
||||
height: 5.5px;
|
||||
border-radius: var(--radius-pill);
|
||||
background: color-mix(in srgb, var(--sstep-fit-accent, var(--ctx-cached)) 48%, var(--text-secondary) 52%);
|
||||
opacity: 0.68;
|
||||
}
|
||||
|
||||
.sstep-fit-swatch.is-curve {
|
||||
width: 11px;
|
||||
height: 2px;
|
||||
border-radius: 1px;
|
||||
background: var(--sstep-fit-accent, var(--ctx-cached));
|
||||
margin-left: 3px;
|
||||
}
|
||||
|
||||
.sstep-fit-swatch.is-ci {
|
||||
width: 10px;
|
||||
height: 6.5px;
|
||||
border-radius: 1px;
|
||||
background: color-mix(in srgb, var(--sstep-fit-accent, var(--ctx-cached)) 22%, var(--surface-panel));
|
||||
border: 0.75px solid color-mix(in srgb, var(--sstep-fit-accent, var(--ctx-cached)) 42%, transparent);
|
||||
margin-left: 3px;
|
||||
}
|
||||
|
||||
.sstep-fit-swatch.is-ols {
|
||||
width: 10px;
|
||||
height: 0;
|
||||
border-top: 1.2px dashed color-mix(in srgb, var(--text-secondary) 75%, var(--surface-panel));
|
||||
margin-left: 3px;
|
||||
}
|
||||
|
||||
.sstep-fit-delta {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
/* --- 4. 极简高密度模型总览列表 (Minimalist Session Model Summary Cards) --- */
|
||||
.smodel-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.smodel-section-head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
padding: 2px 1px 0;
|
||||
}
|
||||
|
||||
.smodel-empty {
|
||||
padding: var(--space-5) var(--space-3);
|
||||
text-align: center;
|
||||
font-size: 11px;
|
||||
border: 1px dashed var(--border-hairline);
|
||||
border-radius: var(--radius-xs);
|
||||
}
|
||||
|
||||
.smodel-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.smodel-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
padding: 7px 10px;
|
||||
background: var(--surface-panel);
|
||||
border: 1px solid var(--border-hairline);
|
||||
border-radius: var(--radius-xs);
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background var(--dur-instant) var(--ease-fast),
|
||||
border-color var(--dur-instant) var(--ease-fast);
|
||||
}
|
||||
|
||||
.smodel-card:hover {
|
||||
background: var(--surface-hover);
|
||||
}
|
||||
|
||||
.smodel-card.is-fit-active {
|
||||
border-color: var(--accent-primary-border);
|
||||
background: color-mix(in srgb, var(--accent-primary) 4.5%, var(--surface-panel));
|
||||
}
|
||||
|
||||
.smodel-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.smodel-ident {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.smodel-name {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.smodel-calls-pill {
|
||||
flex-shrink: 0;
|
||||
font-size: 10px;
|
||||
font-weight: 500;
|
||||
padding: 1px 5px;
|
||||
color: var(--text-secondary);
|
||||
background: var(--surface-track);
|
||||
border-radius: var(--radius-xs);
|
||||
}
|
||||
|
||||
.smodel-totals {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.smodel-tok {
|
||||
font-size: 11.5px;
|
||||
font-weight: 500;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.smodel-cost {
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.smodel-seg-bar {
|
||||
height: 3.5px;
|
||||
}
|
||||
|
||||
.smodel-foot {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 2px 10px;
|
||||
font-size: 10.5px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.smodel-perf {
|
||||
color: var(--text-secondary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.smodel-split {
|
||||
color: var(--text-muted);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@@ -23,11 +23,16 @@ import {
|
||||
formatDateSpanBadge,
|
||||
formatTokensPrecise,
|
||||
formatUsd,
|
||||
mergeModelsByDisplayName,
|
||||
normalizeOrchestratorIdDisplayMode,
|
||||
} from '../core/formatters.js';
|
||||
import { createSvgIcon } from '../icons/SvgIcon.js';
|
||||
import { fetchTelemetry, telemetryStore } from '../store/telemetryStore.js';
|
||||
import { uiStore } from '../store/uiStore.js';
|
||||
import { createTrendAreaChart } from '../components/charts/TrendAreaChart.js';
|
||||
import {
|
||||
createTrendAreaChart,
|
||||
HEATMAP_DAYS_THRESHOLD,
|
||||
} from '../components/charts/TrendAreaChart.js';
|
||||
import { CustomDateTimePicker } from '../components/ui/CustomDateTimePicker.js';
|
||||
import { CustomScrollbar } from '../components/ui/CustomScrollbar.js';
|
||||
import { createFourSegmentBar } from '../components/ui/FourSegmentBar.js';
|
||||
@@ -411,13 +416,24 @@ export const ConsumptionView = defineComponent({
|
||||
* 增量更新热门模型或数据来源单行的指标文本与 4 段比例条宽度。
|
||||
*/
|
||||
function updateBreakdownItemRow(refs, item, grandTotalTokens, showTokensInHeader = true) {
|
||||
patchText(refs.nameEl, item.label || item.name || item.shortName || '—');
|
||||
const displayLabel = item.label || item.name || item.shortName || '—';
|
||||
patchText(refs.nameEl, displayLabel);
|
||||
patchAttr(refs.nameEl, 'title', item.title || displayLabel);
|
||||
const total = Number(item.totalTokens || 0);
|
||||
const share = grandTotalTokens > 0 ? +((total / grandTotalTokens) * 100).toFixed(1) : 0;
|
||||
patchText(refs.pctBadge, `${share.toFixed(1)}%`);
|
||||
patchText(refs.totalTokEl, showTokensInHeader ? formatTokensPrecise(total) : '');
|
||||
patchAttr(refs.totalTokEl, 'hidden', !showTokensInHeader);
|
||||
patchText(refs.costEl, formatUsd(item.costUsd || 0));
|
||||
const costVal = Number(item.costUsd || 0);
|
||||
const callsCount = Number(item.calls || 0);
|
||||
const isAllUnpriced =
|
||||
callsCount > 0 && Number(item.unpricedCalls || 0) >= callsCount && !(costVal > 0);
|
||||
patchText(
|
||||
refs.costEl,
|
||||
formatUsd(isAllUnpriced ? null : costVal, {
|
||||
precise: costVal > 0 && costVal < 0.1,
|
||||
})
|
||||
);
|
||||
|
||||
const responseTok =
|
||||
item.responseTokens != null
|
||||
@@ -530,36 +546,40 @@ export const ConsumptionView = defineComponent({
|
||||
thinkingTokens,
|
||||
});
|
||||
|
||||
// 2. 同步历史趋势交互式 SVG 面积图与粒度提示
|
||||
// 2. 同步历史趋势交互式 SVG 面积图 / 类 GitHub 每日热力图(>90天)与粒度提示
|
||||
patchText(trendRangeBadge, preset?.label || rangeInfo.label || '全部时间');
|
||||
const trendSeries = cons.trendSeries || [];
|
||||
const isHourlyTrend =
|
||||
trendSeries[0]?.granularity === 'hour' ||
|
||||
(trendSeries[0]?.label || '').includes(':');
|
||||
const isHeatmapTrend = !isHourlyTrend && trendSeries.length > HEATMAP_DAYS_THRESHOLD;
|
||||
patchText(
|
||||
trendGranularityHint,
|
||||
`${isHourlyTrend ? '按小时' : '按日'} (${trendSeries.length || 0}点) · 悬停查看`
|
||||
isHeatmapTrend
|
||||
? `按日 (${trendSeries.length}天) · 悬停查看`
|
||||
: `${isHourlyTrend ? '按小时' : '按日'} (${trendSeries.length || 0}点) · 悬停查看`
|
||||
);
|
||||
trendChart.update(trendSeries);
|
||||
|
||||
// 3. 同步热门模型列表(按总 Token 数降序排列并执行键值增量对账,遵循模型名称显示格式设置)
|
||||
const showUpstream = Boolean(slice.showUpstreamModel);
|
||||
const models = (slice.modelBreakdown || [])
|
||||
.slice()
|
||||
.sort((a, b) => (b.totalTokens || 0) - (a.totalTokens || 0));
|
||||
// 3. 同步热门模型列表(按最终展示名称去重归并后按总 Token 数降序排列并执行键值增量对账)
|
||||
const displaySettings = {
|
||||
showUpstreamModel: Boolean(slice.showUpstreamModel),
|
||||
orchestratorIdMode: slice.orchestratorIdMode,
|
||||
};
|
||||
const models = mergeModelsByDisplayName(slice.modelBreakdown || [], displaySettings, {
|
||||
preferLabelInShort: true,
|
||||
}).sort((a, b) => (b.totalTokens || 0) - (a.totalTokens || 0));
|
||||
const modelsTotalTok = models.reduce((s, m) => s + Number(m.totalTokens || 0), 0);
|
||||
|
||||
patchKeyedList(modelsListEl, models, {
|
||||
keyFn: (m) => m.label || m.shortName,
|
||||
keyFn: (m) => m.displayText || m.label || m.shortName,
|
||||
sigFn: (m) =>
|
||||
`${showUpstream}:${m.label}:${m.upstreamName || ''}:${m.totalTokens}:${m.costUsd}:${m.unpricedCalls}:${m.calls}:${modelsTotalTok}`,
|
||||
`${m.displayText}:${m.displayTitle}:${m.totalTokens}:${m.costUsd}:${m.unpricedCalls}:${m.calls}:${modelsTotalTok}`,
|
||||
createRow: createBreakdownItemRow,
|
||||
updateRow: (refs, m) =>
|
||||
updateBreakdownItemRow(
|
||||
refs,
|
||||
showUpstream
|
||||
? { ...m, label: m.upstreamName || m.label || m.shortName }
|
||||
: m,
|
||||
{ ...m, label: m.displayText, title: m.displayTitle },
|
||||
modelsTotalTok,
|
||||
true
|
||||
),
|
||||
@@ -632,6 +652,9 @@ export const ConsumptionView = defineComponent({
|
||||
consumption: st.telemetry?.consumption,
|
||||
modelBreakdown: st.telemetry?.modelBreakdown,
|
||||
showUpstreamModel: Boolean(st.telemetry?.settings?.showUpstreamModel),
|
||||
orchestratorIdMode: normalizeOrchestratorIdDisplayMode(
|
||||
st.telemetry?.settings?.orchestratorIdMode
|
||||
),
|
||||
}),
|
||||
(slice) => {
|
||||
latestSlice = slice;
|
||||
@@ -659,6 +682,7 @@ export const ConsumptionView = defineComponent({
|
||||
onCleanup(() => {
|
||||
unsub();
|
||||
unsubView();
|
||||
trendChart.destroy?.();
|
||||
timeFilterSwitch.destroy();
|
||||
startPicker.destroy();
|
||||
endPicker.destroy();
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
formatMetric,
|
||||
formatTokens,
|
||||
formatUsd,
|
||||
resolveModelDisplayInfo,
|
||||
sampleSummary,
|
||||
speedReasonText,
|
||||
} from '../core/formatters.js';
|
||||
@@ -176,22 +177,27 @@ export function buildQuotaPoolItems(quotas, minuteTick = 0, { isPending = false
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建单个配额池的 DOM 行结构,内含 5h 限额与每周限额两个可独立显隐的子窗口进度条。
|
||||
* 创建单个配额池的 DOM 行结构,内含 5h 限额与每周限额两个可独立显隐的子窗口进度条,
|
||||
* 并在窗口标题右侧内联展示该配额池自身的周期消耗统计(零额外纵向行高)。
|
||||
*/
|
||||
export function createPoolQuotaRow() {
|
||||
const title5h = h('span', { text: '5h 限额' });
|
||||
const meta5h = h('span', { className: 'panel-meta text-mono', text: '--' });
|
||||
const title5h = h('span', { className: 'quota-win-title', text: '5h' });
|
||||
const usage5h = h('span', { className: 'quota-win-usage', hidden: true, text: '' });
|
||||
const left5h = h('span', { className: 'quota-win-left' }, [title5h, usage5h]);
|
||||
const meta5h = h('span', { className: 'panel-meta quota-win-meta text-mono', text: '--' });
|
||||
const fill5h = h('div', { className: 'progress-fill' });
|
||||
const row5h = h('div', { style: 'display: flex; flex-direction: column; gap: 4px;' }, [
|
||||
h('div', { className: 'panel-header' }, [title5h, meta5h]),
|
||||
h('div', { className: 'panel-header quota-win-head' }, [left5h, meta5h]),
|
||||
h('div', { className: 'progress-track' }, [fill5h]),
|
||||
]);
|
||||
|
||||
const titleWk = h('span', { text: '每周限额' });
|
||||
const metaWk = h('span', { className: 'panel-meta text-mono', text: '--' });
|
||||
const titleWk = h('span', { className: 'quota-win-title', text: '周限' });
|
||||
const usageWk = h('span', { className: 'quota-win-usage', hidden: true, text: '' });
|
||||
const leftWk = h('span', { className: 'quota-win-left' }, [titleWk, usageWk]);
|
||||
const metaWk = h('span', { className: 'panel-meta quota-win-meta text-mono', text: '--' });
|
||||
const fillWk = h('div', { className: 'progress-fill' });
|
||||
const rowWk = h('div', { style: 'display: flex; flex-direction: column; gap: 4px;' }, [
|
||||
h('div', { className: 'panel-header' }, [titleWk, metaWk]),
|
||||
h('div', { className: 'panel-header quota-win-head' }, [leftWk, metaWk]),
|
||||
h('div', { className: 'progress-track' }, [fillWk]),
|
||||
]);
|
||||
|
||||
@@ -202,10 +208,41 @@ export function createPoolQuotaRow() {
|
||||
|
||||
return {
|
||||
el,
|
||||
refs: { row5h, title5h, meta5h, fill5h, rowWk, titleWk, metaWk, fillWk },
|
||||
refs: {
|
||||
row5h,
|
||||
left5h,
|
||||
title5h,
|
||||
usage5h,
|
||||
meta5h,
|
||||
fill5h,
|
||||
rowWk,
|
||||
leftWk,
|
||||
titleWk,
|
||||
usageWk,
|
||||
metaWk,
|
||||
fillWk,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化可用额度面板底部的汇总行文案(官方配额模式下展示各池周期合计,自定义预算模式下展示自然周累计)。
|
||||
*/
|
||||
export function formatQuotaSummaryFooter(quotas, account) {
|
||||
const weekly = quotas?.weekly || {};
|
||||
const isCustomLocal = weekly.isOfficial === false;
|
||||
const prefix = isCustomLocal ? '本周' : '周期';
|
||||
const leftText = `${prefix}累计: ${formatTokens(weekly.tokens || 0)} (${formatUsd(weekly.costUsd || 0)})`;
|
||||
const rightText =
|
||||
Number(account?.aiCredits) > 0
|
||||
? `AI 积分: ${account.aiCredits}`
|
||||
: `${prefix}调用: ${weekly.calls || 0} 次`;
|
||||
const tooltip = isCustomLocal
|
||||
? '按本机自然周(周一 00:00 起)统计'
|
||||
: '按各配额池独立周限重置周期分别统计并汇总';
|
||||
return { leftText, rightText, tooltip };
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步单个配额池行的 5h 与每周窗口状态:
|
||||
* - 对于仅有周限额的独立配额池(例如 Google AI Pro 账号下的 Argon 池或 Plus 档位)自动隐藏 5h 行;
|
||||
@@ -250,7 +287,24 @@ export function syncPoolQuotaRow(refs, item, idx, rowEl) {
|
||||
|
||||
const fallbackMetaText = isPending ? '读取中...' : '获取失败 (--%)';
|
||||
|
||||
patchText(refs.title5h, `5h 限额 (${poolLabel})`);
|
||||
patchText(refs.title5h, `5h (${poolLabel})`);
|
||||
const c5h = poolData?.cycle5h;
|
||||
if (!isPending && has5h && c5h && (c5h.tokens != null || c5h.costUsd != null)) {
|
||||
const tok5h = formatTokens(c5h.tokens || 0);
|
||||
const cost5h = formatUsd(c5h.costUsd || 0);
|
||||
const calls5h = Number(c5h.calls || 0);
|
||||
refs.usage5h.hidden = false;
|
||||
patchText(refs.usage5h, `· ${tok5h} (${cost5h})`);
|
||||
patchAttr(
|
||||
refs.left5h,
|
||||
'title',
|
||||
`当前 5h 周期累计 (${poolLabel}):${tok5h} Tokens · ${cost5h} · ${calls5h} 次调用`
|
||||
);
|
||||
} else {
|
||||
refs.usage5h.hidden = true;
|
||||
patchText(refs.usage5h, '');
|
||||
patchAttr(refs.left5h, 'title', null);
|
||||
}
|
||||
patchText(
|
||||
refs.meta5h,
|
||||
has5h
|
||||
@@ -264,10 +318,27 @@ export function syncPoolQuotaRow(refs, item, idx, rowEl) {
|
||||
});
|
||||
|
||||
const customTitle =
|
||||
isActivePool && fallbackWeekly?.isOfficial === false && fallbackWeekly?.title
|
||||
? fallbackWeekly.title
|
||||
: `每周限额 (${poolLabel})`;
|
||||
useCustomWeekly && fallbackWeekly?.title ? fallbackWeekly.title : `周限 (${poolLabel})`;
|
||||
patchText(refs.titleWk, customTitle);
|
||||
const cWk = useCustomWeekly
|
||||
? fallbackWeekly
|
||||
: poolData?.cycleWeekly || (isActivePool ? fallbackWeekly : null);
|
||||
if (!isPending && hasWk && cWk && (cWk.tokens != null || cWk.costUsd != null)) {
|
||||
const tokWk = formatTokens(cWk.tokens || 0);
|
||||
const costWk = formatUsd(cWk.costUsd || 0);
|
||||
const callsWk = Number(cWk.calls || 0);
|
||||
refs.usageWk.hidden = false;
|
||||
patchText(refs.usageWk, `· ${tokWk} (${costWk})`);
|
||||
patchAttr(
|
||||
refs.leftWk,
|
||||
'title',
|
||||
`${useCustomWeekly ? '本周自然周累计' : `当前周限周期累计 (${poolLabel})`}:${tokWk} Tokens · ${costWk} · ${callsWk} 次调用`
|
||||
);
|
||||
} else {
|
||||
refs.usageWk.hidden = true;
|
||||
patchText(refs.usageWk, '');
|
||||
patchAttr(refs.leftWk, 'title', null);
|
||||
}
|
||||
patchText(
|
||||
refs.metaWk,
|
||||
hasWk
|
||||
@@ -282,7 +353,10 @@ export function syncPoolQuotaRow(refs, item, idx, rowEl) {
|
||||
}
|
||||
|
||||
export function quotaPoolRowSig(item, idx) {
|
||||
return `${idx}:${item.poolLabel}:${item.isActivePool}:${Boolean(item.isPending)}:${item.minuteTick}:${item.poolData?.usedPct}:${item.poolData?.remainingPct}:${item.poolData?.resetTime}:${item.poolData?.weeklyUsedPct}:${item.poolData?.weeklyRemainingPct}:${item.poolData?.weeklyResetTime}:${item.fallbackWeekly?.isOfficial}:${item.fallbackWeekly?.usedPct}:${item.fallbackWeekly?.remainingPct}:${item.fallbackWeekly?.resetTime}:${item.fallbackWeekly?.title}`;
|
||||
const c5h = item.poolData?.cycle5h;
|
||||
const cWk = item.poolData?.cycleWeekly;
|
||||
const fw = item.fallbackWeekly;
|
||||
return `${idx}:${item.poolLabel}:${item.isActivePool}:${Boolean(item.isPending)}:${item.minuteTick}:${item.poolData?.usedPct}:${item.poolData?.remainingPct}:${item.poolData?.resetTime}:${item.poolData?.weeklyUsedPct}:${item.poolData?.weeklyRemainingPct}:${item.poolData?.weeklyResetTime}:${c5h?.tokens}:${c5h?.costUsd}:${c5h?.calls}:${cWk?.tokens}:${cWk?.costUsd}:${cWk?.calls}:${fw?.isOfficial}:${fw?.usedPct}:${fw?.remainingPct}:${fw?.resetTime}:${fw?.title}:${fw?.tokens}:${fw?.costUsd}:${fw?.calls}`;
|
||||
}
|
||||
|
||||
export const LiveOverviewView = defineComponent({
|
||||
@@ -561,7 +635,7 @@ export const LiveOverviewView = defineComponent({
|
||||
const tierBadge = h('span', { className: 'panel-meta', text: 'Google AI · Pro' });
|
||||
const poolsListEl = h('div', { style: 'display: flex; flex-direction: column; gap: 0;' });
|
||||
|
||||
const wkFootLeft = h('span', { className: 'text-muted', text: '本周累计: 0 ($0.00)' });
|
||||
const wkFootLeft = h('span', { className: 'text-muted', text: '周期累计: 0 ($0.00)' });
|
||||
const wkFootRight = h('span', { className: 'text-muted', text: '' });
|
||||
|
||||
const quotaPanel = h('section', { className: 'panel' }, [
|
||||
@@ -860,12 +934,10 @@ export const LiveOverviewView = defineComponent({
|
||||
ensureLiveTicker();
|
||||
}
|
||||
|
||||
// 1. 更新 4 格实时测速矩阵(展示当前会话全局汇总指标,遵循模型名称格式设置)
|
||||
const showUpstream = Boolean(data.settings?.showUpstreamModel);
|
||||
const activeModelDisplay =
|
||||
(showUpstream
|
||||
? active.activeModelUpstream || active.activeModelShort
|
||||
: active.activeModelShort) || '模型未知';
|
||||
// 1. 更新 4 格实时测速矩阵(展示当前会话全局汇总指标,遵循模型名称格式与 Orchestrator ID 格式设置)
|
||||
const activeModelDisplay = resolveModelDisplayInfo(active, data.settings, {
|
||||
fallback: '模型未知',
|
||||
}).text;
|
||||
patchClasses(pulseDot, { 'is-pulsing': Boolean(active.isRunning) });
|
||||
patchText(tpsVal, formatMetric(active.latestTokPerSec, ' tok/s'));
|
||||
const reason = speedReasonText(active.latestSpeedReason);
|
||||
@@ -914,9 +986,9 @@ export const LiveOverviewView = defineComponent({
|
||||
|
||||
const allAgentPills = agents.map((ag) => {
|
||||
const agPct = ag.context?.usedPct ?? 0;
|
||||
const agModelDisplay =
|
||||
(showUpstream ? ag.activeModelUpstream || ag.activeModelShort : ag.activeModelShort) ||
|
||||
'模型未知';
|
||||
const agModelDisplay = resolveModelDisplayInfo(ag, data.settings, {
|
||||
fallback: '模型未知',
|
||||
}).text;
|
||||
return {
|
||||
key: ag.agentId,
|
||||
label: `${ag.badgeText || ag.shortLabel} ${agPct}%`,
|
||||
@@ -1038,7 +1110,6 @@ export const LiveOverviewView = defineComponent({
|
||||
tierBadge,
|
||||
`${data.account?.tierName || 'Google AI'} · ${data.account?.planName || 'Pro'}`
|
||||
);
|
||||
const weekly = quotas.weekly || {};
|
||||
const minuteTick = Math.floor(Date.now() / 30000);
|
||||
const poolItems = buildQuotaPoolItems(quotas, minuteTick);
|
||||
|
||||
@@ -1049,16 +1120,11 @@ export const LiveOverviewView = defineComponent({
|
||||
updateRow: syncPoolQuotaRow,
|
||||
});
|
||||
|
||||
patchText(
|
||||
wkFootLeft,
|
||||
`本周累计: ${formatTokens(weekly.tokens || 0)} (${formatUsd(weekly.costUsd || 0)})`
|
||||
);
|
||||
patchText(
|
||||
wkFootRight,
|
||||
data.account?.aiCredits > 0
|
||||
? `AI 积分: ${data.account.aiCredits}`
|
||||
: `本周调用: ${weekly.calls || 0} 次`
|
||||
);
|
||||
const footSummary = formatQuotaSummaryFooter(quotas, data.account);
|
||||
patchText(wkFootLeft, footSummary.leftText);
|
||||
patchText(wkFootRight, footSummary.rightText);
|
||||
patchAttr(wkFootLeft, 'title', footSummary.tooltip);
|
||||
patchAttr(wkFootRight, 'title', footSummary.tooltip);
|
||||
|
||||
ensureCountdownTicker();
|
||||
viewScrollbar.refresh();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @fileoverview View 4: SettingsView (系统设置视图).
|
||||
* 采用定制的 `CustomSelect` 与 `SegmentedControl` 替代所有原生表单控件,分为三个单层细线设置面板:
|
||||
* 1. 常规设置:配置面板挂载方式(双栖挂载 / 仅右侧辅助栏)与模型名称格式(精简代号 / 原始模型 ID);
|
||||
* 1. 常规设置:配置面板挂载方式(双栖挂载 / 仅右侧辅助栏)、模型名称格式(精简代号 / 原始模型 ID)与 Orchestrator 系列 ID 格式;
|
||||
* 2. 顶部栏定制:控制左侧「实时运行会话」入口开关,以及自由定义右侧精简胶囊三个数值槽位的显示内容与左右顺序;
|
||||
* 3. 版本更新:配置插件自动更新策略、手动同步云端模型价格表,以及检查并执行 Git/ZIP 双模式插件升级。
|
||||
*/
|
||||
@@ -11,8 +11,10 @@ import { h, patchAttr, patchClasses, patchText } from '../core/domPatch.js';
|
||||
import { createSvgIcon } from '../icons/SvgIcon.js';
|
||||
import {
|
||||
DEFAULT_CLIENT_TOPBAR_SLOTS,
|
||||
normalizeClientOrchestratorIdMode,
|
||||
normalizeClientTopbarSlots,
|
||||
normalizeClientUpdateMode,
|
||||
normalizeClientWindowMountMode,
|
||||
saveSettingsPatch,
|
||||
telemetryStore,
|
||||
triggerCloudSync,
|
||||
@@ -29,9 +31,16 @@ const STEP_MODEL_DISPLAY_OPTIONS = [
|
||||
{ value: 'upstream', label: '原始模型 ID (如 gemini-3.8-flash-n)' },
|
||||
];
|
||||
|
||||
/** 面板挂载模式可选项(顶部栏 + 侧边栏 vs 仅侧边栏) */
|
||||
/** Orchestrator 系列模型 ID 显示方式可选项(独立于普通模型名称格式) */
|
||||
const ORCHESTRATOR_ID_DISPLAY_OPTIONS = [
|
||||
{ value: 'compact', label: '精简代号 (如 orchestrator-argon)' },
|
||||
{ value: 'full', label: '原始完整 ID (如 gemini-pro-orchestrator)' },
|
||||
];
|
||||
|
||||
/** 面板挂载模式可选项(顶部栏 + 侧边栏 / 输入框 + 侧边栏 / 仅侧边栏) */
|
||||
const WINDOW_MOUNT_OPTIONS = [
|
||||
{ value: 'dual', label: '双栖挂载 (顶部栏 + 侧边栏)' },
|
||||
{ value: 'composer', label: '输入框挂载 (输入框 + 侧边栏)' },
|
||||
{ value: 'sidebar', label: '仅侧边栏' },
|
||||
];
|
||||
|
||||
@@ -81,7 +90,9 @@ export const SettingsView = defineComponent({
|
||||
name: 'SettingsView',
|
||||
setup({ onCleanup }) {
|
||||
let draftShowUpstreamModel = false;
|
||||
let draftOrchestratorIdMode = 'compact';
|
||||
let draftPluginUpdateMode = 'manual';
|
||||
let draftWindowMountMode = 'dual';
|
||||
let draftEnableWindowOverlay = true;
|
||||
let draftShowTopbarMulti = true;
|
||||
let draftTopbarSlots = [...DEFAULT_CLIENT_TOPBAR_SLOTS];
|
||||
@@ -144,12 +155,15 @@ export const SettingsView = defineComponent({
|
||||
icon: 'dock',
|
||||
options: WINDOW_MOUNT_OPTIONS,
|
||||
onUpdateModelValue: async (val) => {
|
||||
const nextEnable = val !== 'sidebar';
|
||||
const nextMode = normalizeClientWindowMountMode(val);
|
||||
const nextEnable = nextMode !== 'sidebar';
|
||||
draftWindowMountMode = nextMode;
|
||||
draftEnableWindowOverlay = nextEnable;
|
||||
windowMountSelect.setValue(nextEnable ? 'dual' : 'sidebar');
|
||||
windowMountSelect.setValue(nextMode);
|
||||
showSaveFeedback('保存中…');
|
||||
try {
|
||||
await saveSettingsPatch({
|
||||
windowMountMode: nextMode,
|
||||
enableWindowOverlay: nextEnable,
|
||||
});
|
||||
showSaveFeedback('已保存');
|
||||
@@ -185,6 +199,29 @@ export const SettingsView = defineComponent({
|
||||
},
|
||||
});
|
||||
|
||||
const orchestratorIdSelect = CustomSelect({
|
||||
modelValue: 'compact',
|
||||
icon: 'layers',
|
||||
options: ORCHESTRATOR_ID_DISPLAY_OPTIONS,
|
||||
onUpdateModelValue: async (val) => {
|
||||
const nextMode = normalizeClientOrchestratorIdMode(val);
|
||||
draftOrchestratorIdMode = nextMode;
|
||||
orchestratorIdSelect.setValue(nextMode);
|
||||
showSaveFeedback('保存中…');
|
||||
try {
|
||||
await saveSettingsPatch({
|
||||
orchestratorIdMode: nextMode,
|
||||
});
|
||||
showSaveFeedback('已保存');
|
||||
} catch {
|
||||
if (latestSettings) {
|
||||
renderSettings(latestSettings);
|
||||
}
|
||||
showSaveFeedback('保存失败');
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const generalPanel = h('section', { className: 'panel' }, [
|
||||
h('div', { className: 'panel-header' }, [
|
||||
h('span', { className: 'panel-title' }, [
|
||||
@@ -201,6 +238,10 @@ export const SettingsView = defineComponent({
|
||||
h('span', { className: 'form-label', text: '模型名称格式' }),
|
||||
stepModelSelect.el,
|
||||
]),
|
||||
h('div', { className: 'form-row' }, [
|
||||
h('span', { className: 'form-label', text: 'Orchestrator 系列 ID' }),
|
||||
orchestratorIdSelect.el,
|
||||
]),
|
||||
]);
|
||||
|
||||
// --- 面板 2:顶部栏定制(实时运行会话开关 + 右侧三槽位指标与顺序自定义) ---
|
||||
@@ -532,16 +573,22 @@ export const SettingsView = defineComponent({
|
||||
function renderSettings(settings) {
|
||||
if (!settings) return;
|
||||
draftShowUpstreamModel = Boolean(settings.showUpstreamModel);
|
||||
draftOrchestratorIdMode = normalizeClientOrchestratorIdMode(settings.orchestratorIdMode);
|
||||
draftPluginUpdateMode = normalizeClientUpdateMode(
|
||||
settings.pluginUpdateMode,
|
||||
settings.autoUpdatePlugin
|
||||
);
|
||||
draftEnableWindowOverlay = settings.enableWindowOverlay !== false;
|
||||
draftWindowMountMode = normalizeClientWindowMountMode(
|
||||
settings.windowMountMode,
|
||||
settings.enableWindowOverlay
|
||||
);
|
||||
draftEnableWindowOverlay = draftWindowMountMode !== 'sidebar';
|
||||
draftShowTopbarMulti = settings.showTopbarMultiSession !== false;
|
||||
draftTopbarSlots = normalizeClientTopbarSlots(settings.topbarCapsuleSlots);
|
||||
|
||||
windowMountSelect.setValue(draftEnableWindowOverlay ? 'dual' : 'sidebar');
|
||||
windowMountSelect.setValue(draftWindowMountMode);
|
||||
stepModelSelect.setValue(draftShowUpstreamModel ? 'upstream' : 'short');
|
||||
orchestratorIdSelect.setValue(draftOrchestratorIdMode);
|
||||
autoUpdateSelect.setValue(draftPluginUpdateMode);
|
||||
syncTopbarControls();
|
||||
viewScrollbar.refresh();
|
||||
@@ -623,6 +670,7 @@ export const SettingsView = defineComponent({
|
||||
unsubView();
|
||||
windowMountSelect.destroy();
|
||||
stepModelSelect.destroy();
|
||||
orchestratorIdSelect.destroy();
|
||||
multiSessionToggle.destroy();
|
||||
for (const sel of slotSelects) {
|
||||
sel.destroy();
|
||||
@@ -636,6 +684,7 @@ export const SettingsView = defineComponent({
|
||||
refs: {
|
||||
windowMountSelect,
|
||||
stepModelSelect,
|
||||
orchestratorIdSelect,
|
||||
multiSessionToggle,
|
||||
slotSelects,
|
||||
resetTopbarBtn,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user