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