mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
feat(panel): 3-tier update modes, topbar update prompt, and Gemini Hydrogen & Helix support (v1.4.4)
This commit is contained in:
@@ -417,7 +417,7 @@ export const ConsumptionView = defineComponent({
|
||||
patchText(refs.pctBadge, `${share.toFixed(1)}%`);
|
||||
patchText(refs.totalTokEl, showTokensInHeader ? formatTokensPrecise(total) : '');
|
||||
patchAttr(refs.totalTokEl, 'hidden', !showTokensInHeader);
|
||||
patchText(refs.costEl, formatUsd(item.costUsd || 0, { unpricedCalls: item.unpricedCalls }));
|
||||
patchText(refs.costEl, formatUsd(item.costUsd || 0));
|
||||
|
||||
const responseTok =
|
||||
item.responseTokens != null
|
||||
@@ -477,8 +477,8 @@ export const ConsumptionView = defineComponent({
|
||||
|
||||
patchText(heroTotalTokens, formatTokensPrecise(totalTokens));
|
||||
patchText(heroTotalCalls, `${acct.calls || 0} 次`);
|
||||
patchText(heroCostUsd, formatUsd(costUsd, { unpricedCalls: acct.unpricedCalls }));
|
||||
patchText(heroCostCny, acct.unpricedCalls > 0 ? `${acct.unpricedCalls} 步费用待定` : formatCnyApprox(costUsd));
|
||||
patchText(heroCostUsd, formatUsd(costUsd));
|
||||
patchText(heroCostCny, formatCnyApprox(costUsd));
|
||||
|
||||
patchText(cacheHitPctEl, `${Number(acct.cacheHitPct ?? 0).toFixed(1)}%`);
|
||||
patchText(cacheTokensEl, `命中 ${formatTokensPrecise(cacheTokens)}`);
|
||||
@@ -602,11 +602,7 @@ export const ConsumptionView = defineComponent({
|
||||
const cVal = Number(m.costUsd || 0);
|
||||
patchText(
|
||||
col.costText,
|
||||
m.unpricedCalls > 0
|
||||
? formatUsd(cVal, { unpricedCalls: m.unpricedCalls, compactPending: true })
|
||||
: cVal >= 10
|
||||
? `$${Math.round(cVal)}`
|
||||
: `$${cVal.toFixed(2)}`
|
||||
cVal >= 10 ? `$${Math.round(cVal)}` : `$${cVal.toFixed(2)}`
|
||||
);
|
||||
patchText(col.tokText, formatTokensPrecise(mTot));
|
||||
|
||||
|
||||
@@ -889,7 +889,7 @@ export const LiveOverviewView = defineComponent({
|
||||
);
|
||||
patchText(
|
||||
cacheSub,
|
||||
`缓存 ${active.latestCacheHitPct ?? 0}% · 累计 ${formatUsd(active.sessionCostUsd || 0, { unpricedCalls: active.sessionUnpricedCalls })}`
|
||||
`缓存 ${active.latestCacheHitPct ?? 0}% · 累计 ${formatUsd(active.sessionCostUsd || 0)}`
|
||||
);
|
||||
|
||||
// 2. 更新 10 段上下文窗口构成与内嵌上下文窗口检视胶囊条
|
||||
@@ -1051,7 +1051,7 @@ export const LiveOverviewView = defineComponent({
|
||||
|
||||
patchText(
|
||||
wkFootLeft,
|
||||
`本周累计: ${formatTokens(weekly.tokens || 0)} (${formatUsd(weekly.costUsd || 0, { unpricedCalls: weekly.unpricedCalls })})`
|
||||
`本周累计: ${formatTokens(weekly.tokens || 0)} (${formatUsd(weekly.costUsd || 0)})`
|
||||
);
|
||||
patchText(
|
||||
wkFootRight,
|
||||
|
||||
@@ -12,6 +12,7 @@ import { createSvgIcon } from '../icons/SvgIcon.js';
|
||||
import {
|
||||
DEFAULT_CLIENT_TOPBAR_SLOTS,
|
||||
normalizeClientTopbarSlots,
|
||||
normalizeClientUpdateMode,
|
||||
saveSettingsPatch,
|
||||
telemetryStore,
|
||||
triggerCloudSync,
|
||||
@@ -54,10 +55,11 @@ const TOPBAR_SLOT_OPTIONS = [
|
||||
{ value: 'none', label: '不显示' },
|
||||
];
|
||||
|
||||
/** 插件版本更新策略可选项 */
|
||||
/** 插件版本更新策略可选项(默认仅提示新版本、手动更新) */
|
||||
const AUTO_UPDATE_OPTIONS = [
|
||||
{ value: 'manual', label: '仅提示新版本,手动更新 (推荐)' },
|
||||
{ value: 'auto', label: '后台自动安装新版本' },
|
||||
{ value: 'manual', label: '仅提示新版本,手动更新' },
|
||||
{ value: 'auto', label: '自动更新' },
|
||||
{ value: 'off', label: '关闭更新' },
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -79,7 +81,7 @@ export const SettingsView = defineComponent({
|
||||
name: 'SettingsView',
|
||||
setup({ onCleanup }) {
|
||||
let draftShowUpstreamModel = false;
|
||||
let draftAutoUpdatePlugin = false;
|
||||
let draftPluginUpdateMode = 'manual';
|
||||
let draftEnableWindowOverlay = true;
|
||||
let draftShowTopbarMulti = true;
|
||||
let draftTopbarSlots = [...DEFAULT_CLIENT_TOPBAR_SLOTS];
|
||||
@@ -375,19 +377,26 @@ export const SettingsView = defineComponent({
|
||||
icon: 'refresh',
|
||||
options: AUTO_UPDATE_OPTIONS,
|
||||
onUpdateModelValue: async (val) => {
|
||||
const nextAuto = val === 'auto';
|
||||
draftAutoUpdatePlugin = nextAuto;
|
||||
autoUpdateSelect.setValue(nextAuto ? 'auto' : 'manual');
|
||||
const nextMode = normalizeClientUpdateMode(val);
|
||||
draftPluginUpdateMode = nextMode;
|
||||
autoUpdateSelect.setValue(nextMode);
|
||||
if (latestCloudStatus) {
|
||||
renderCloudStatus(latestCloudStatus);
|
||||
}
|
||||
showCloudFeedback('保存中…', 0);
|
||||
try {
|
||||
await saveSettingsPatch({
|
||||
autoUpdatePlugin: nextAuto,
|
||||
pluginUpdateMode: nextMode,
|
||||
autoUpdatePlugin: nextMode === 'auto',
|
||||
});
|
||||
showCloudFeedback('已保存', 1800);
|
||||
} catch {
|
||||
if (latestSettings) {
|
||||
renderSettings(latestSettings);
|
||||
}
|
||||
if (latestCloudStatus) {
|
||||
renderCloudStatus(latestCloudStatus);
|
||||
}
|
||||
showCloudFeedback('保存失败', 2500);
|
||||
}
|
||||
},
|
||||
@@ -395,7 +404,7 @@ export const SettingsView = defineComponent({
|
||||
|
||||
const pricingCountVal = h('strong', { className: 'cell-value', text: '—' });
|
||||
const pricingSyncSub = h('span', { className: 'cell-sub', text: '读取中…' });
|
||||
const versionVal = h('strong', { className: 'cell-value', text: 'v1.4.3' });
|
||||
const versionVal = h('strong', { className: 'cell-value', text: 'v1.4.4' });
|
||||
const versionSub = h('span', { className: 'cell-sub', text: '检查中…' });
|
||||
|
||||
const syncPricingBtnText = h('span', { text: '更新价格表' });
|
||||
@@ -450,7 +459,7 @@ export const SettingsView = defineComponent({
|
||||
return;
|
||||
}
|
||||
if (!cs?.updateAvailable) {
|
||||
const curVer = cs?.currentPluginVersion || '1.4.3';
|
||||
const curVer = cs?.currentPluginVersion || '1.4.4';
|
||||
showCloudFeedback(`当前已是最新版本 (v${curVer})`, 4500);
|
||||
return;
|
||||
}
|
||||
@@ -486,7 +495,7 @@ export const SettingsView = defineComponent({
|
||||
cloudStatusMsg,
|
||||
]),
|
||||
h('div', { className: 'form-row' }, [
|
||||
h('span', { className: 'form-label', text: '自动更新' }),
|
||||
h('span', { className: 'form-label', text: '更新方式' }),
|
||||
autoUpdateSelect.el,
|
||||
]),
|
||||
h('div', { className: 'dual-grid' }, [
|
||||
@@ -523,14 +532,17 @@ export const SettingsView = defineComponent({
|
||||
function renderSettings(settings) {
|
||||
if (!settings) return;
|
||||
draftShowUpstreamModel = Boolean(settings.showUpstreamModel);
|
||||
draftAutoUpdatePlugin = Boolean(settings.autoUpdatePlugin);
|
||||
draftPluginUpdateMode = normalizeClientUpdateMode(
|
||||
settings.pluginUpdateMode,
|
||||
settings.autoUpdatePlugin
|
||||
);
|
||||
draftEnableWindowOverlay = settings.enableWindowOverlay !== false;
|
||||
draftShowTopbarMulti = settings.showTopbarMultiSession !== false;
|
||||
draftTopbarSlots = normalizeClientTopbarSlots(settings.topbarCapsuleSlots);
|
||||
|
||||
windowMountSelect.setValue(draftEnableWindowOverlay ? 'dual' : 'sidebar');
|
||||
stepModelSelect.setValue(draftShowUpstreamModel ? 'upstream' : 'short');
|
||||
autoUpdateSelect.setValue(draftAutoUpdatePlugin ? 'auto' : 'manual');
|
||||
autoUpdateSelect.setValue(draftPluginUpdateMode);
|
||||
syncTopbarControls();
|
||||
viewScrollbar.refresh();
|
||||
}
|
||||
@@ -550,15 +562,20 @@ export const SettingsView = defineComponent({
|
||||
`${srcLabel} · ${formatSyncTimeText(cs.lastSyncedAtMs, cs.catalogUpdatedAt)}`
|
||||
);
|
||||
|
||||
const curVer = cs.currentPluginVersion || '1.4.3';
|
||||
const curVer = cs.currentPluginVersion || '1.4.4';
|
||||
const latVer = cs.latestPluginVersion || curVer;
|
||||
const modeTag = cs.installMode === 'git' ? 'Git' : 'ZIP';
|
||||
patchText(versionVal, `v${curVer}`);
|
||||
if (cs.updateAvailable) {
|
||||
if (cs.updateAvailable && draftPluginUpdateMode !== 'off') {
|
||||
patchText(versionSub, `可升级至 v${latVer} (${modeTag})`);
|
||||
patchClasses(versionSub, { 'accent-ok': true });
|
||||
patchText(updatePluginBtnText, `升级至 v${latVer}`);
|
||||
patchClasses(updatePluginBtn, { 'btn-primary': true, 'btn-secondary': false });
|
||||
} else if (draftPluginUpdateMode === 'off') {
|
||||
patchText(versionSub, `已关闭更新提醒 (${modeTag})`);
|
||||
patchClasses(versionSub, { 'accent-ok': false });
|
||||
patchText(updatePluginBtnText, cs.updateAvailable ? `手动升级 v${latVer}` : '检查更新');
|
||||
patchClasses(updatePluginBtn, { 'btn-primary': false, 'btn-secondary': true });
|
||||
} else {
|
||||
patchText(versionSub, `已是最新 (${modeTag})`);
|
||||
patchClasses(versionSub, { 'accent-ok': false });
|
||||
|
||||
@@ -119,8 +119,8 @@ export const StepsDetailView = defineComponent({
|
||||
style: 'flex: 1; min-height: 0; display: flex; flex-direction: column;',
|
||||
},
|
||||
[
|
||||
h('div', { className: 'panel-header' }, [
|
||||
h('span', { className: 'panel-title' }, [
|
||||
h('div', { className: 'panel-header steps-panel-header' }, [
|
||||
h('span', { className: 'panel-title steps-panel-title' }, [
|
||||
createSvgIcon('table', { size: 13 }),
|
||||
h('span', { text: '调用记录' }),
|
||||
]),
|
||||
@@ -349,7 +349,7 @@ export const StepsDetailView = defineComponent({
|
||||
patchText(refs.speedMain, formatMetric(m.avgTokPerSec, ' tok/s'));
|
||||
patchText(refs.speedSub, `有效 ${sampleSummary(m.speedSummary)}`);
|
||||
patchText(refs.tdTokens, formatTokens(m.totalTokens || 0));
|
||||
patchText(refs.tdCost, formatUsd(m.costUsd, { unpricedCalls: m.unpricedCalls }));
|
||||
patchText(refs.tdCost, formatUsd(m.costUsd || 0));
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user