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:
@@ -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