mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
refactor(panel): unify settings and bridge contracts, prune dead code, and rename trajectory metrics
- Share settings normalization and window-bridge protocol contracts across frontend and backend - Encapsulate trajectory cache accessors inside config.mjs and validate bundle imports/syntax before writing - Remove dead selectors, unused symbols, duplicate re-export imports, and unmounted account tab instantiation - Rename speed-metrics.mjs to trajectory-metrics.mjs and audit-fixes.test.mjs to cross-module-regressions.test.mjs
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
|
||||
import { h, patchAttr, patchClasses, patchStyleVar, patchText } from '../../core/domPatch.js';
|
||||
import {
|
||||
formatMetric,
|
||||
formatTokens,
|
||||
formatTokensPrecise,
|
||||
formatUsd,
|
||||
@@ -422,21 +421,6 @@ export function computePublicationFit(
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算样本点上的平滑回归拟合值序列(供单元测试与轻量调用直接读取)。
|
||||
*
|
||||
* @param {number[]} ys
|
||||
* @param {{ minVal?: number, maxVal?: number, xs?: number[] }} [bounds]
|
||||
* @returns {number[]}
|
||||
*/
|
||||
export function computeLoessFit(ys, { minVal = 0, maxVal = Infinity, xs = null } = {}) {
|
||||
const n = Array.isArray(ys) ? ys.length : 0;
|
||||
if (n === 0) return [];
|
||||
const xArr =
|
||||
Array.isArray(xs) && xs.length === n ? xs : Array.from({ length: n }, (_, idx) => idx);
|
||||
return computePublicationFit(xArr, ys, { minVal, maxVal }).sampleFits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Heckbert 科学坐标轴刻度取整算法,生成科研图表风格的均匀整洁刻度。
|
||||
*/
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
* 在宿主切换会话重建顶栏 DOM 时始终保持组件实例、滚动位置与动画状态不丢失。
|
||||
*/
|
||||
|
||||
import {
|
||||
WINDOW_BRIDGE_KEY,
|
||||
WINDOW_OVERLAY_KEY,
|
||||
WINDOW_OVERLAY_METHODS,
|
||||
readInjectedWindowBridge,
|
||||
} from '../../../shared/window-bridge-protocol.mjs';
|
||||
import { App } from '../../App.js';
|
||||
import { applyAppearanceToRoot } from '../../core/appearance.js';
|
||||
import {
|
||||
@@ -813,7 +819,7 @@ function isImmediatelyBeforeNode(node, refNode) {
|
||||
function isIdeExtensionChatFrame() {
|
||||
try {
|
||||
if (typeof window === 'undefined') return false;
|
||||
if (window.__AGUsageMonitorBridge?.isIdeChatFrame === true) return true;
|
||||
if (readInjectedWindowBridge()?.isIdeChatFrame === true) return true;
|
||||
return /[?&]extension(?:View|Variant)=/i.test(String(window.location?.search || ''));
|
||||
} catch {
|
||||
return false;
|
||||
@@ -824,7 +830,7 @@ function resolveActiveDockTarget(options = undefined) {
|
||||
const settings = telemetryStore.getState().telemetry?.settings;
|
||||
const rawMode =
|
||||
settings?.windowMountMode ??
|
||||
(typeof window !== 'undefined' ? window.__AGUsageMonitorBridge?.mountMode : undefined);
|
||||
readInjectedWindowBridge()?.mountMode;
|
||||
const mountMode =
|
||||
options?.mountMode ||
|
||||
normalizeClientWindowMountMode(rawMode, settings?.enableWindowOverlay);
|
||||
@@ -925,14 +931,14 @@ export function mountWindowOverlay() {
|
||||
let carryOverMultiPinnedOpen = false;
|
||||
let carryOverPointer = null;
|
||||
try {
|
||||
const prevOv = window.__AGUsageMonitorOverlay;
|
||||
const prevOv = window[WINDOW_OVERLAY_KEY];
|
||||
carryOverTelemetry = prevOv?.getTelemetrySnapshot?.() || null;
|
||||
carryOverTooltipOpen = Boolean(prevOv?.isHoverOpen?.());
|
||||
carryOverPopoverOpen = Boolean(prevOv?.isOpen?.());
|
||||
carryOverMultiHoverOpen = Boolean(prevOv?.isMultiHoverOpen?.());
|
||||
carryOverMultiPinnedOpen = Boolean(prevOv?.isMultiPinnedOpen?.());
|
||||
carryOverPointer = prevOv?.getLastPointer?.() || null;
|
||||
prevOv?.dispose?.();
|
||||
prevOv?.[WINDOW_OVERLAY_METHODS.dispose]?.();
|
||||
} catch {
|
||||
// 忽略旧实例卸载异常
|
||||
}
|
||||
@@ -3070,28 +3076,28 @@ export function mountWindowOverlay() {
|
||||
|
||||
const handle = {
|
||||
bundleVersion,
|
||||
ensureAlive() {
|
||||
[WINDOW_OVERLAY_METHODS.ensureAlive]() {
|
||||
if (disposed) return false;
|
||||
return ensureCapsuleDocked();
|
||||
},
|
||||
syncHostRoute() {
|
||||
[WINDOW_OVERLAY_METHODS.syncHostRoute]() {
|
||||
if (disposed) return false;
|
||||
syncHostRouteIfChanged();
|
||||
return true;
|
||||
},
|
||||
updateBridge(nextBridge) {
|
||||
[WINDOW_OVERLAY_METHODS.updateBridge](nextBridge) {
|
||||
if (disposed || !nextBridge || typeof nextBridge !== 'object') return false;
|
||||
const port = Number(nextBridge.port || 0);
|
||||
const token = String(nextBridge.token || '');
|
||||
if (!Number.isInteger(port) || port <= 0 || !token) return false;
|
||||
const cur = window.__AGUsageMonitorBridge || {};
|
||||
const cur = readInjectedWindowBridge() || {};
|
||||
const portChanged = Number(cur.port || 0) !== port || String(cur.token || '') !== token;
|
||||
cur.port = port;
|
||||
cur.token = token;
|
||||
if (portChanged) {
|
||||
cur.transportMode = 'http';
|
||||
}
|
||||
window.__AGUsageMonitorBridge = cur;
|
||||
window[WINDOW_BRIDGE_KEY] = cur;
|
||||
void fetchTelemetry({ force: false });
|
||||
return true;
|
||||
},
|
||||
@@ -3101,7 +3107,7 @@ export function mountWindowOverlay() {
|
||||
getLastPointer() {
|
||||
return hasPointerCoords ? { x: lastPointerX, y: lastPointerY } : null;
|
||||
},
|
||||
deliverRpc(responses) {
|
||||
[WINDOW_OVERLAY_METHODS.deliverRpc](responses) {
|
||||
if (disposed) return 0;
|
||||
return deliverCdpBridgeResponses(responses);
|
||||
},
|
||||
@@ -3126,14 +3132,13 @@ export function mountWindowOverlay() {
|
||||
isMultiHoverOpen: () => Boolean(multiOpen && !multiPinned),
|
||||
isMultiPinnedOpen: () => Boolean(multiOpen && multiPinned),
|
||||
getLayoutMode: () => layoutMode,
|
||||
getDockKind: () => String(capsuleHost.getAttribute('data-dock') || ''),
|
||||
getMountMode: () => lastAppliedMountMode,
|
||||
applyMountMode(nextMode) {
|
||||
[WINDOW_OVERLAY_METHODS.getDockKind]: () => String(capsuleHost.getAttribute('data-dock') || ''),
|
||||
[WINDOW_OVERLAY_METHODS.getMountMode]: () => lastAppliedMountMode,
|
||||
[WINDOW_OVERLAY_METHODS.applyMountMode](nextMode) {
|
||||
if (disposed) return false;
|
||||
const normalized = normalizeClientWindowMountMode(nextMode, nextMode !== 'sidebar');
|
||||
if (typeof window !== 'undefined' && window.__AGUsageMonitorBridge) {
|
||||
window.__AGUsageMonitorBridge.mountMode = normalized;
|
||||
}
|
||||
const bridgeConfig = readInjectedWindowBridge();
|
||||
if (bridgeConfig) bridgeConfig.mountMode = normalized;
|
||||
const curTel = telemetryStore.getState().telemetry;
|
||||
if (curTel?.settings) {
|
||||
telemetryStore.setState({
|
||||
@@ -3150,7 +3155,7 @@ export function mountWindowOverlay() {
|
||||
lastAppliedMountMode = normalized;
|
||||
return ensureCapsuleDocked();
|
||||
},
|
||||
dispose() {
|
||||
[WINDOW_OVERLAY_METHODS.dispose]() {
|
||||
if (disposed) return;
|
||||
disposed = true;
|
||||
clearInterval(watchdogTimer);
|
||||
@@ -3203,12 +3208,12 @@ export function mountWindowOverlay() {
|
||||
try {
|
||||
portalHost.remove();
|
||||
} catch {}
|
||||
if (window.__AGUsageMonitorOverlay === handle) {
|
||||
delete window.__AGUsageMonitorOverlay;
|
||||
if (window[WINDOW_OVERLAY_KEY] === handle) {
|
||||
delete window[WINDOW_OVERLAY_KEY];
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
window.__AGUsageMonitorOverlay = handle;
|
||||
window[WINDOW_OVERLAY_KEY] = handle;
|
||||
return handle;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
* (Sidecar Webview `window.sidecar.fetch` + Main Window Loopback Bridge).
|
||||
*/
|
||||
|
||||
import { readInjectedWindowBridge } from '../../shared/window-bridge-protocol.mjs';
|
||||
|
||||
const inFlightGets = new Map();
|
||||
const activeControllers = new Map();
|
||||
|
||||
@@ -13,8 +15,7 @@ const activeControllers = new Map();
|
||||
* @returns {{ port: number, token: string, bundleVersion?: string, stylesCss?: string } | null}
|
||||
*/
|
||||
export function getWindowBridgeConfig() {
|
||||
if (typeof window === 'undefined') return null;
|
||||
const br = window.__AGUsageMonitorBridge;
|
||||
const br = readInjectedWindowBridge();
|
||||
const port = Number(br?.port || 0);
|
||||
if (br && Number.isInteger(port) && port > 0 && typeof br.token === 'string' && br.token) {
|
||||
return br;
|
||||
|
||||
@@ -20,33 +20,10 @@ import {
|
||||
} from '../core/formatters.js';
|
||||
import { isEnglishLocale, t } from '../i18n/index.js';
|
||||
|
||||
export const CAPSULE_METRIC_KEYS = Object.freeze([
|
||||
'context',
|
||||
'tps',
|
||||
'ttft',
|
||||
'avg_tps',
|
||||
'cost',
|
||||
'session_cost',
|
||||
'cache_hit',
|
||||
'session_tokens',
|
||||
'quota_auto',
|
||||
'gemini_5h',
|
||||
'gemini_weekly',
|
||||
'claude_5h',
|
||||
'claude_weekly',
|
||||
]);
|
||||
import { OVERVIEW_METRIC_KEYS, TOPBAR_SLOT_KEYS } from '../../shared/settings-normalization.mjs';
|
||||
|
||||
export const OVERVIEW_METRIC_KEYS = Object.freeze([
|
||||
'tps',
|
||||
'ttft',
|
||||
'avg_tps',
|
||||
'step_cost',
|
||||
'session_cost',
|
||||
'cache_hit',
|
||||
'session_tokens',
|
||||
'context_usage',
|
||||
'quota_tightest',
|
||||
]);
|
||||
export { OVERVIEW_METRIC_KEYS };
|
||||
export const CAPSULE_METRIC_KEYS = TOPBAR_SLOT_KEYS;
|
||||
|
||||
const THIRD_PARTY_FAMILY_RE = /claude|gpt|anthropic|openai|3p|sonnet|opus|haiku/i;
|
||||
|
||||
|
||||
@@ -7,6 +7,17 @@ import { createReactiveStore } from '../core/reactive.js';
|
||||
import { callSidecarApi, getWindowBridgeConfig, isWindowOverlayMode } from '../core/httpClient.js';
|
||||
import { isEnglishLocale, normalizeI18nLanguage, t } from '../i18n/index.js';
|
||||
import { normalizeClientFontScale, normalizeClientThemeAccent } from '../core/appearance.js';
|
||||
import {
|
||||
DEFAULT_OVERVIEW_METRICS,
|
||||
DEFAULT_TOPBAR_SLOTS,
|
||||
OVERVIEW_METRIC_KEYS,
|
||||
TOPBAR_SLOT_KEYS,
|
||||
normalizeOverviewMetrics,
|
||||
normalizeTopbarCapsuleSlots,
|
||||
normalizeWeeklyLimitMode,
|
||||
normalizeWindowMountMode,
|
||||
} from '../../shared/settings-normalization.mjs';
|
||||
import { WINDOW_BRIDGE_ROUTE_KEY, readInjectedWindowBridge } from '../../shared/window-bridge-protocol.mjs';
|
||||
|
||||
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;
|
||||
|
||||
@@ -25,7 +36,7 @@ export function extractHostRouteCascadeId() {
|
||||
if (m && CASCADE_UUID_RE.test(m[1])) {
|
||||
return m[1];
|
||||
}
|
||||
const extBridgeRouteId = String(window.__AGUsageMonitorBridge?.hostRouteCascadeId || '').trim();
|
||||
const extBridgeRouteId = String(readInjectedWindowBridge()?.[WINDOW_BRIDGE_ROUTE_KEY] || '').trim();
|
||||
if (extBridgeRouteId && CASCADE_UUID_RE.test(extBridgeRouteId)) {
|
||||
return extBridgeRouteId;
|
||||
}
|
||||
@@ -107,23 +118,9 @@ let loopActive = false;
|
||||
let loopIntervalMs = 2000;
|
||||
let loopTickFn = null;
|
||||
|
||||
export const CLIENT_TOPBAR_SLOT_KEYS = Object.freeze([
|
||||
'context',
|
||||
'tps',
|
||||
'ttft',
|
||||
'avg_tps',
|
||||
'cost',
|
||||
'session_cost',
|
||||
'cache_hit',
|
||||
'session_tokens',
|
||||
'quota_auto',
|
||||
'gemini_5h',
|
||||
'gemini_weekly',
|
||||
'claude_5h',
|
||||
'claude_weekly',
|
||||
]);
|
||||
export const CLIENT_TOPBAR_SLOT_KEYS = TOPBAR_SLOT_KEYS;
|
||||
|
||||
export const DEFAULT_CLIENT_TOPBAR_SLOTS = Object.freeze(['tps', 'ttft', 'context']);
|
||||
export const DEFAULT_CLIENT_TOPBAR_SLOTS = DEFAULT_TOPBAR_SLOTS;
|
||||
|
||||
export const CLIENT_OVERVIEW_MODULE_KEYS = Object.freeze([
|
||||
'metrics',
|
||||
@@ -141,24 +138,9 @@ export const DEFAULT_CLIENT_OVERVIEW_MODULES = Object.freeze([
|
||||
|
||||
export const DEFAULT_CLIENT_HOVER_MODULES = Object.freeze(['metrics', 'context', 'quotas']);
|
||||
|
||||
export const CLIENT_OVERVIEW_METRIC_KEYS = Object.freeze([
|
||||
'tps',
|
||||
'ttft',
|
||||
'avg_tps',
|
||||
'step_cost',
|
||||
'session_cost',
|
||||
'cache_hit',
|
||||
'session_tokens',
|
||||
'context_usage',
|
||||
'quota_tightest',
|
||||
]);
|
||||
export const CLIENT_OVERVIEW_METRIC_KEYS = OVERVIEW_METRIC_KEYS;
|
||||
|
||||
export const DEFAULT_CLIENT_OVERVIEW_METRICS = Object.freeze([
|
||||
'tps',
|
||||
'ttft',
|
||||
'avg_tps',
|
||||
'step_cost',
|
||||
]);
|
||||
export const DEFAULT_CLIENT_OVERVIEW_METRICS = DEFAULT_OVERVIEW_METRICS;
|
||||
|
||||
export const CLIENT_STEP_COLUMN_KEYS = Object.freeze([
|
||||
'step',
|
||||
@@ -308,12 +290,7 @@ function normalizeClientOrderedList(raw, { allowedKeys, defaultItems, minLen, ma
|
||||
* @returns {string[]}
|
||||
*/
|
||||
export function normalizeClientTopbarSlots(raw) {
|
||||
return normalizeClientOrderedList(raw, {
|
||||
allowedKeys: CLIENT_TOPBAR_SLOT_KEYS,
|
||||
defaultItems: DEFAULT_CLIENT_TOPBAR_SLOTS,
|
||||
minLen: 1,
|
||||
maxLen: 5,
|
||||
});
|
||||
return normalizeTopbarCapsuleSlots(raw);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -353,12 +330,7 @@ export function normalizeClientOverviewModules(raw) {
|
||||
* @returns {string[]}
|
||||
*/
|
||||
export function normalizeClientOverviewMetrics(raw) {
|
||||
return normalizeClientOrderedList(raw, {
|
||||
allowedKeys: CLIENT_OVERVIEW_METRIC_KEYS,
|
||||
defaultItems: DEFAULT_CLIENT_OVERVIEW_METRICS,
|
||||
minLen: 1,
|
||||
maxLen: 4,
|
||||
});
|
||||
return normalizeOverviewMetrics(raw);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -402,12 +374,7 @@ export function normalizeClientOrchestratorIdMode(mode) {
|
||||
* @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';
|
||||
return normalizeWindowMountMode(mode, legacyEnableOverlay);
|
||||
}
|
||||
|
||||
function isEquivalentTelemetry(prev, next) {
|
||||
@@ -423,15 +390,6 @@ function isEquivalentTelemetry(prev, next) {
|
||||
}
|
||||
return true;
|
||||
};
|
||||
const normMount = (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';
|
||||
};
|
||||
|
||||
// 1. 比对系统设置项(外观语言/主题/字号、模型显示策略、更新策略、挂载与结构布局配置)
|
||||
const pAct = prev.activeConversation;
|
||||
const nAct = next.activeConversation;
|
||||
@@ -503,8 +461,8 @@ function isEquivalentTelemetry(prev, next) {
|
||||
if ((pSet?.pluginUpdateMode ?? '') !== (nSet?.pluginUpdateMode ?? '')) return false;
|
||||
if (pSet?.autoUpdatePlugin !== nSet?.autoUpdatePlugin) return false;
|
||||
if (
|
||||
normMount(pSet?.windowMountMode, pSet?.enableWindowOverlay) !==
|
||||
normMount(nSet?.windowMountMode, nSet?.enableWindowOverlay)
|
||||
normalizeClientWindowMountMode(pSet?.windowMountMode, pSet?.enableWindowOverlay) !==
|
||||
normalizeClientWindowMountMode(nSet?.windowMountMode, nSet?.enableWindowOverlay)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
@@ -1137,9 +1095,7 @@ export async function saveSettingsPatch(patch) {
|
||||
safePatch.fontScale = normalizeClientFontScale(safePatch.fontScale);
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(safePatch, 'weeklyLimitMode')) {
|
||||
const mode = safePatch.weeklyLimitMode;
|
||||
safePatch.weeklyLimitMode =
|
||||
mode === 'custom_tokens' || mode === 'custom_cost' ? mode : 'official';
|
||||
safePatch.weeklyLimitMode = normalizeWeeklyLimitMode(safePatch.weeklyLimitMode);
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(safePatch, 'enableCliStatusLine')) {
|
||||
safePatch.enableCliStatusLine = Boolean(safePatch.enableCliStatusLine);
|
||||
|
||||
@@ -5,13 +5,6 @@
|
||||
import { createReactiveStore } from '../core/reactive.js';
|
||||
import { t } from '../i18n/index.js';
|
||||
|
||||
export const VIEW_TABS = Object.freeze([
|
||||
{ value: 'overview', label: '实时监控', icon: 'pulse' },
|
||||
{ value: 'consumption', label: '用量统计', icon: 'chart-bar' },
|
||||
{ value: 'steps', label: '调用明细', icon: 'table' },
|
||||
{ value: 'settings', label: '偏好设置', icon: 'sliders' },
|
||||
]);
|
||||
|
||||
export function getViewTabs() {
|
||||
return [
|
||||
{ value: 'overview', label: t('nav.overview'), icon: 'pulse' },
|
||||
|
||||
@@ -744,12 +744,6 @@
|
||||
min-height: 26px;
|
||||
}
|
||||
|
||||
.topbar-header-right {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.btn-ghost-sm {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -781,34 +775,6 @@
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.topbar-slot-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.topbar-slot-row {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 2px 4px 2px 6px;
|
||||
border: 1px solid var(--border-hairline);
|
||||
border-radius: var(--radius-xs);
|
||||
background: transparent;
|
||||
transition: border-color var(--dur-instant) var(--ease-fast);
|
||||
}
|
||||
|
||||
.topbar-slot-row:focus-within,
|
||||
.topbar-slot-row:has(.is-open) {
|
||||
z-index: 30;
|
||||
border-color: var(--border-strong);
|
||||
}
|
||||
|
||||
.topbar-slot-row .select-menu {
|
||||
max-height: 216px;
|
||||
}
|
||||
|
||||
.slot-index-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -52,7 +52,7 @@ export const SettingsView = defineComponent({
|
||||
|
||||
const generalTab = SettingsGeneralTab({ onLayoutChange: refreshScroll });
|
||||
const structureTab = SettingsStructureTab({ onLayoutChange: refreshScroll });
|
||||
const accountTab = SettingsAccountTab({ onLayoutChange: refreshScroll });
|
||||
const accountTab = SHOW_ACCOUNT_TAB ? SettingsAccountTab({ onLayoutChange: refreshScroll }) : null;
|
||||
const otherTab = SettingsOtherTab({ onLayoutChange: refreshScroll });
|
||||
|
||||
let showingAccount = false;
|
||||
@@ -60,25 +60,27 @@ export const SettingsView = defineComponent({
|
||||
const target =
|
||||
subTab === 'structure' ||
|
||||
subTab === 'other' ||
|
||||
(SHOW_ACCOUNT_TAB && subTab === 'account')
|
||||
(accountTab && subTab === 'account')
|
||||
? subTab
|
||||
: 'general';
|
||||
subNavSwitch.setValue(target);
|
||||
patchAttr(generalTab.el, 'hidden', target !== 'general');
|
||||
patchAttr(structureTab.el, 'hidden', target !== 'structure');
|
||||
patchAttr(structureTab.refs.thirdNavBar, 'hidden', target !== 'structure');
|
||||
patchAttr(accountTab.el, 'hidden', !SHOW_ACCOUNT_TAB || target !== 'account');
|
||||
patchAttr(otherTab.el, 'hidden', target !== 'other');
|
||||
const nextShowingAccount = SHOW_ACCOUNT_TAB && target === 'account' && activeView === 'settings';
|
||||
if (nextShowingAccount && !showingAccount) void accountTab.refs.load();
|
||||
showingAccount = nextShowingAccount;
|
||||
if (accountTab) {
|
||||
patchAttr(accountTab.el, 'hidden', target !== 'account');
|
||||
const nextShowingAccount = target === 'account' && activeView === 'settings';
|
||||
if (nextShowingAccount && !showingAccount) void accountTab.refs.load();
|
||||
showingAccount = nextShowingAccount;
|
||||
}
|
||||
refreshScroll();
|
||||
}
|
||||
|
||||
const contentContainer = h(
|
||||
'div',
|
||||
{},
|
||||
SHOW_ACCOUNT_TAB
|
||||
accountTab
|
||||
? [generalTab.el, structureTab.el, accountTab.el, otherTab.el]
|
||||
: [generalTab.el, structureTab.el, otherTab.el]
|
||||
);
|
||||
@@ -105,7 +107,7 @@ export const SettingsView = defineComponent({
|
||||
if (settings) structureTab.refs.renderSettings(settings);
|
||||
} else if (settingsSubTab === 'other') {
|
||||
if (settings) otherTab.refs.renderSettings(settings, telemetry.contextWindowModels || []);
|
||||
} else if (SHOW_ACCOUNT_TAB && settingsSubTab === 'account') {
|
||||
} else if (accountTab && settingsSubTab === 'account') {
|
||||
accountTab.refs.renderAccount(telemetry?.account, telemetry?.quotas);
|
||||
} else {
|
||||
if (settings) generalTab.refs.renderSettings(settings);
|
||||
@@ -145,7 +147,7 @@ export const SettingsView = defineComponent({
|
||||
});
|
||||
generalTab.refs.refreshLabels();
|
||||
structureTab.refs.refreshLabels();
|
||||
accountTab.refs.refreshLabels();
|
||||
accountTab?.refs.refreshLabels();
|
||||
otherTab.refs.refreshLabels();
|
||||
refreshScroll();
|
||||
}
|
||||
@@ -158,7 +160,7 @@ export const SettingsView = defineComponent({
|
||||
subNavSwitch.destroy();
|
||||
generalTab.destroy();
|
||||
structureTab.destroy();
|
||||
accountTab.destroy();
|
||||
accountTab?.destroy();
|
||||
otherTab.destroy();
|
||||
viewScrollbar.destroy();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user