mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
feat(panel): add experimental modern UI, sliding switchers, cycle range, and fluid animations
This commit is contained in:
@@ -47,6 +47,7 @@ import { SegmentedControl } from '../components/ui/SegmentedControl.js';
|
||||
/** 消耗统计顶栏支持的时间范围预设项 */
|
||||
function getConsumptionTimeRangeOptions() {
|
||||
return [
|
||||
{ value: 'cycle', label: t('cons.rangeCycle') },
|
||||
{ value: 'today', label: t('cons.rangeToday') },
|
||||
{ value: '24h', label: t('cons.range24h') },
|
||||
{ value: '7d', label: t('cons.range7d') },
|
||||
@@ -135,8 +136,7 @@ export const ConsumptionView = defineComponent({
|
||||
const customRangeBar = h(
|
||||
'div',
|
||||
{
|
||||
style:
|
||||
'display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 6px 8px; background: var(--surface-subtle); border: 1px solid var(--border-hairline); border-radius: var(--radius-xs);',
|
||||
className: 'cons-custom-range-bar',
|
||||
hidden: true,
|
||||
},
|
||||
[
|
||||
@@ -338,6 +338,7 @@ export const ConsumptionView = defineComponent({
|
||||
activeHoverTargetEl = null;
|
||||
}
|
||||
patchAttr(breakdownPopoverEl, 'hidden', true);
|
||||
patchClasses(breakdownPopoverEl, { 'is-tracking': false });
|
||||
}
|
||||
|
||||
function positionBreakdownPopover(anchorEl, pointerClientX = null) {
|
||||
@@ -413,8 +414,22 @@ export const ConsumptionView = defineComponent({
|
||||
},
|
||||
});
|
||||
|
||||
const wasHidden = breakdownPopoverEl.hasAttribute('hidden');
|
||||
patchAttr(breakdownPopoverEl, 'hidden', false);
|
||||
positionBreakdownPopover(anchorEl, pointerClientX);
|
||||
if (wasHidden) {
|
||||
patchClasses(breakdownPopoverEl, { 'is-tracking': false });
|
||||
void breakdownPopoverEl.offsetWidth;
|
||||
if (typeof window !== 'undefined' && typeof window.requestAnimationFrame === 'function') {
|
||||
window.requestAnimationFrame(() => {
|
||||
if (!breakdownPopoverEl.hasAttribute('hidden')) {
|
||||
patchClasses(breakdownPopoverEl, { 'is-tracking': true });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
patchClasses(breakdownPopoverEl, { 'is-tracking': true });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createMonthModelSegment() {
|
||||
|
||||
@@ -220,7 +220,6 @@ export const StepsDetailView = defineComponent({
|
||||
collapseAll: true,
|
||||
multiUnit: t('steps.unitAgent'),
|
||||
modelValue: selectedAgentScopes,
|
||||
icon: 'layers',
|
||||
placeholder: t('steps.allAgents'),
|
||||
className: 'steps-inline-scope-select',
|
||||
options: [{ value: 'all', label: t('steps.allAgents') }],
|
||||
@@ -503,7 +502,7 @@ export const StepsDetailView = defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
function renderStepsData(slice) {
|
||||
function renderStepsData(slice, { allowNewRowFade = false } = {}) {
|
||||
if (!slice) return;
|
||||
const uiSt = uiStore.getState();
|
||||
const locale = getEffectiveLocale();
|
||||
@@ -729,6 +728,12 @@ export const StepsDetailView = defineComponent({
|
||||
],
|
||||
});
|
||||
|
||||
const allConversationSteps = hasSubagents
|
||||
? aggregated?.recentSteps || []
|
||||
: slice.recentSteps || [];
|
||||
const shouldAnimateNewRows = Boolean(
|
||||
allowNewRowFade && slice.experimentalModernUi && !showModels
|
||||
);
|
||||
if (!showModels) {
|
||||
const colKeys = normalizeClientStepColumns(slice.stepTableColumns);
|
||||
renderStepTable(tableSteps, slice.cascadeId, colKeys, locale, {
|
||||
@@ -740,6 +745,8 @@ export const StepsDetailView = defineComponent({
|
||||
showStepSpeedColor: slice.showStepSpeedColor === true,
|
||||
stepTokenComboFormat: slice.stepTokenComboFormat,
|
||||
displaySettings,
|
||||
allConversationSteps,
|
||||
allowNewRowFade: shouldAnimateNewRows,
|
||||
});
|
||||
stepsScroll.refresh();
|
||||
}
|
||||
@@ -1070,6 +1077,7 @@ export const StepsDetailView = defineComponent({
|
||||
st.telemetry?.settings?.stepTokenComboFormat
|
||||
),
|
||||
stepTableColumns: st.telemetry?.settings?.stepTableColumns,
|
||||
experimentalModernUi: Boolean(st.telemetry?.settings?.experimentalModernUi),
|
||||
}),
|
||||
(slice) => {
|
||||
latestSlice = slice;
|
||||
@@ -1081,7 +1089,9 @@ export const StepsDetailView = defineComponent({
|
||||
return;
|
||||
}
|
||||
isDirty = false;
|
||||
renderStepsData(slice);
|
||||
renderStepsData(slice, {
|
||||
allowNewRowFade: uiStore.getState().stepsSubTab === 'steps',
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
|
||||
import { defineComponent } from '../../core/component.js';
|
||||
import {
|
||||
applyAppearanceToRoot,
|
||||
normalizeClientFontScale,
|
||||
normalizeClientModernUi,
|
||||
normalizeClientThemeAccent,
|
||||
} from '../../core/appearance.js';
|
||||
import { h, patchAttr, patchClasses, patchText } from '../../core/domPatch.js';
|
||||
@@ -39,6 +41,13 @@ function getFontScaleOptions() {
|
||||
];
|
||||
}
|
||||
|
||||
function getModernUiOptions() {
|
||||
return [
|
||||
{ value: 'off', label: t('settings.gen.modernUiOff') },
|
||||
{ value: 'on', label: t('settings.gen.modernUiOn') },
|
||||
];
|
||||
}
|
||||
|
||||
function getUpdateModeOptions() {
|
||||
return [
|
||||
{ value: 'manual', label: t('settings.gen.updateManual') },
|
||||
@@ -66,6 +75,7 @@ export const SettingsGeneralTab = defineComponent({
|
||||
let draftLanguage = 'zh-CN';
|
||||
let draftThemeAccent = 'host';
|
||||
let draftFontScale = 'md';
|
||||
let draftModernUi = false;
|
||||
let draftPluginUpdateMode = 'manual';
|
||||
let latestSettings = null;
|
||||
let latestCloudStatus = null;
|
||||
@@ -123,6 +133,14 @@ export const SettingsGeneralTab = defineComponent({
|
||||
className: 'settings-hint-text',
|
||||
text: t('settings.gen.fontHint'),
|
||||
});
|
||||
const modernUiLabelEl = h('span', {
|
||||
className: 'form-label',
|
||||
text: t('settings.gen.modernUi'),
|
||||
});
|
||||
const modernUiHintEl = h('span', {
|
||||
className: 'settings-hint-text',
|
||||
text: t('settings.gen.modernUiHint'),
|
||||
});
|
||||
|
||||
const languageSwitch = SegmentedControl({
|
||||
ariaLabel: t('settings.gen.language'),
|
||||
@@ -181,6 +199,38 @@ export const SettingsGeneralTab = defineComponent({
|
||||
},
|
||||
});
|
||||
|
||||
const modernUiSwitch = SegmentedControl({
|
||||
ariaLabel: t('settings.gen.modernUi'),
|
||||
modelValue: 'off',
|
||||
options: getModernUiOptions(),
|
||||
onUpdateModelValue: async (val) => {
|
||||
const nextModernUi = val === 'on';
|
||||
draftModernUi = nextModernUi;
|
||||
modernUiSwitch.setValue(nextModernUi ? 'on' : 'off');
|
||||
if (typeof document !== 'undefined' && document.documentElement) {
|
||||
applyAppearanceToRoot(
|
||||
document.documentElement,
|
||||
{
|
||||
...(latestSettings || {}),
|
||||
themeAccent: draftThemeAccent,
|
||||
fontScale: draftFontScale,
|
||||
experimentalModernUi: nextModernUi,
|
||||
},
|
||||
{ includeFontScale: true }
|
||||
);
|
||||
}
|
||||
showAppearanceFeedback(t('settings.saving'), 0);
|
||||
try {
|
||||
await saveSettingsPatch({ experimentalModernUi: nextModernUi });
|
||||
showAppearanceFeedback(t('settings.saved'), 1500);
|
||||
props.onLayoutChange?.();
|
||||
} catch {
|
||||
if (latestSettings) renderSettings(latestSettings);
|
||||
showAppearanceFeedback(t('settings.saveFailed'), 2500);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const appearancePanel = h('section', { className: 'panel' }, [
|
||||
h('div', { className: 'panel-header' }, [
|
||||
h('span', { className: 'panel-title' }, [
|
||||
@@ -192,6 +242,7 @@ export const SettingsGeneralTab = defineComponent({
|
||||
h('div', { className: 'form-row' }, [langLabelEl, languageSwitch.el]),
|
||||
h('div', { className: 'form-row' }, [accentLabelEl, themeColorPicker.el]),
|
||||
h('div', { className: 'form-row' }, [fontLabelEl, fontScaleSwitch.el, fontHintEl]),
|
||||
h('div', { className: 'form-row' }, [modernUiLabelEl, modernUiSwitch.el, modernUiHintEl]),
|
||||
]);
|
||||
|
||||
// --- Card 2: 版本更新 ---
|
||||
@@ -350,6 +401,7 @@ export const SettingsGeneralTab = defineComponent({
|
||||
draftLanguage = normalizeI18nLanguage(settings.language);
|
||||
draftThemeAccent = normalizeClientThemeAccent(settings.themeAccent);
|
||||
draftFontScale = normalizeClientFontScale(settings.fontScale);
|
||||
draftModernUi = normalizeClientModernUi(settings.experimentalModernUi);
|
||||
draftPluginUpdateMode = normalizeClientUpdateMode(
|
||||
settings.pluginUpdateMode,
|
||||
settings.autoUpdatePlugin
|
||||
@@ -364,6 +416,10 @@ export const SettingsGeneralTab = defineComponent({
|
||||
modelValue: draftFontScale,
|
||||
options: getFontScaleOptions(),
|
||||
});
|
||||
modernUiSwitch.setProps({
|
||||
modelValue: draftModernUi ? 'on' : 'off',
|
||||
options: getModernUiOptions(),
|
||||
});
|
||||
autoUpdateSelect.setProps({
|
||||
modelValue: draftPluginUpdateMode,
|
||||
options: getUpdateModeOptions(),
|
||||
@@ -425,6 +481,8 @@ export const SettingsGeneralTab = defineComponent({
|
||||
patchText(accentLabelEl, t('settings.gen.themeAccent'));
|
||||
patchText(fontLabelEl, t('settings.gen.fontScale'));
|
||||
patchText(fontHintEl, t('settings.gen.fontHint'));
|
||||
patchText(modernUiLabelEl, t('settings.gen.modernUi'));
|
||||
patchText(modernUiHintEl, t('settings.gen.modernUiHint'));
|
||||
patchText(updateTitleEl, t('settings.gen.updateTitle'));
|
||||
patchText(updateModeLabelEl, t('settings.gen.updateMode'));
|
||||
patchText(pricingCellLabelEl, t('settings.gen.pricingLabel'));
|
||||
@@ -441,6 +499,11 @@ export const SettingsGeneralTab = defineComponent({
|
||||
modelValue: draftFontScale,
|
||||
options: getFontScaleOptions(),
|
||||
});
|
||||
modernUiSwitch.setProps({
|
||||
ariaLabel: t('settings.gen.modernUi'),
|
||||
modelValue: draftModernUi ? 'on' : 'off',
|
||||
options: getModernUiOptions(),
|
||||
});
|
||||
autoUpdateSelect.setProps({
|
||||
modelValue: draftPluginUpdateMode,
|
||||
options: getUpdateModeOptions(),
|
||||
@@ -458,6 +521,7 @@ export const SettingsGeneralTab = defineComponent({
|
||||
languageSwitch.destroy();
|
||||
themeColorPicker.destroy();
|
||||
fontScaleSwitch.destroy();
|
||||
modernUiSwitch.destroy();
|
||||
autoUpdateSelect.destroy();
|
||||
});
|
||||
|
||||
@@ -467,6 +531,7 @@ export const SettingsGeneralTab = defineComponent({
|
||||
languageSwitch,
|
||||
themeColorPicker,
|
||||
fontScaleSwitch,
|
||||
modernUiSwitch,
|
||||
autoUpdateSelect,
|
||||
syncPricingBtn,
|
||||
updatePluginBtn,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import { defineComponent } from '../../core/component.js';
|
||||
import { h, patchAttr, patchClasses, patchText } from '../../core/domPatch.js';
|
||||
import { h, patchAttr, patchClasses, patchStyleVar, patchText } from '../../core/domPatch.js';
|
||||
import { getEffectiveLocale, t } from '../../i18n/index.js';
|
||||
import { createSvgIcon } from '../../icons/SvgIcon.js';
|
||||
import {
|
||||
@@ -177,10 +177,29 @@ export const SettingsStructureTab = defineComponent({
|
||||
'aria-selected': item.key === activeThirdTab ? 'true' : 'false',
|
||||
'data-structure-tab': item.key,
|
||||
onClick: () => {
|
||||
applyActiveThirdTab(item.key);
|
||||
if (uiStore.getState().settingsStructureTab !== item.key) {
|
||||
uiStore.setState({ settingsStructureTab: item.key });
|
||||
} else {
|
||||
applyActiveThirdTab(item.key);
|
||||
}
|
||||
},
|
||||
onKeydown: (e) => {
|
||||
if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
|
||||
e.preventDefault();
|
||||
const curIdx = Math.max(
|
||||
0,
|
||||
STRUCTURE_THIRD_TABS.findIndex((it) => it.key === item.key)
|
||||
);
|
||||
const delta = e.key === 'ArrowRight' ? 1 : -1;
|
||||
const nextIdx =
|
||||
(curIdx + delta + STRUCTURE_THIRD_TABS.length) % STRUCTURE_THIRD_TABS.length;
|
||||
const nextItem = STRUCTURE_THIRD_TABS[nextIdx];
|
||||
if (nextItem) {
|
||||
applyActiveThirdTab(nextItem.key);
|
||||
if (uiStore.getState().settingsStructureTab !== nextItem.key) {
|
||||
uiStore.setState({ settingsStructureTab: nextItem.key });
|
||||
}
|
||||
thirdNavBtnMap.get(nextItem.key)?.btn?.focus?.();
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
@@ -190,6 +209,7 @@ export const SettingsStructureTab = defineComponent({
|
||||
return btn;
|
||||
});
|
||||
|
||||
const thirdNavGlider = h('div', { className: 'thirdnav-glider', 'aria-hidden': 'true' });
|
||||
const thirdNavBar = h(
|
||||
'div',
|
||||
{
|
||||
@@ -197,7 +217,15 @@ export const SettingsStructureTab = defineComponent({
|
||||
role: 'tablist',
|
||||
'aria-label': t('settings.str.thirdTabAria'),
|
||||
},
|
||||
thirdNavBtns
|
||||
[thirdNavGlider, ...thirdNavBtns]
|
||||
);
|
||||
patchStyleVar(
|
||||
thirdNavBar,
|
||||
'--active-third-index',
|
||||
Math.max(
|
||||
0,
|
||||
STRUCTURE_THIRD_TABS.findIndex((it) => it.key === activeThirdTab)
|
||||
)
|
||||
);
|
||||
|
||||
// --- Pane 1: 挂载与胶囊栏 (`mount`) ---
|
||||
@@ -973,6 +1001,11 @@ export const SettingsStructureTab = defineComponent({
|
||||
function applyActiveThirdTab(nextRawTab) {
|
||||
const nextTab = normalizeStructureTabKey(nextRawTab);
|
||||
activeThirdTab = nextTab;
|
||||
const activeIdx = Math.max(
|
||||
0,
|
||||
STRUCTURE_THIRD_TABS.findIndex((it) => it.key === nextTab)
|
||||
);
|
||||
patchStyleVar(thirdNavBar, '--active-third-index', activeIdx);
|
||||
for (const [key, entry] of thirdNavBtnMap.entries()) {
|
||||
const isActive = key === nextTab;
|
||||
patchClasses(entry.btn, { 'is-active': isActive });
|
||||
|
||||
Reference in New Issue
Block a user