feat(webui): group Settings sidebar into 控制台 / SnowLuma / 平台
The flat tab strip mixed three domains — the dashboard itself, the all-accounts SnowLuma protocol runtime, and the host/platform. Regroup into 3 labelled sections (macOS System-Settings idiom): section headers show on the desktop rail; the mobile strip stays a flat wrap via display:contents. Each group is a role=group + aria-labelledby; the nav gains an aria-label. This gives '全局配置' (and future global protocol knobs) a principled home and ends the mixing. Phase 4 (final) of the global-settings split.
This commit is contained in:
1 file changed
+47
-5
@@ -45,17 +45,40 @@ import { NotificationsPanel } from '@/components/settings/notifications-panel';
|
|||||||
import { GlobalConfigPanel } from '@/components/settings/global-config-panel';
|
import { GlobalConfigPanel } from '@/components/settings/global-config-panel';
|
||||||
import { SystemPanel } from '@/components/settings/system-panel';
|
import { SystemPanel } from '@/components/settings/system-panel';
|
||||||
|
|
||||||
const TABS: { key: SettingsTab; label: string; icon: typeof Sun }[] = [
|
interface TabDef { key: SettingsTab; label: string; icon: typeof Sun }
|
||||||
|
|
||||||
|
// Three domains, rendered as macOS System-Settings-style sidebar sections:
|
||||||
|
// the dashboard itself (控制台), the all-accounts SnowLuma protocol runtime,
|
||||||
|
// and the host/deployment (平台). Section headers show on the desktop rail
|
||||||
|
// only; the mobile strip stays a flat wrap.
|
||||||
|
const TAB_GROUPS: { title: string; tabs: TabDef[] }[] = [
|
||||||
|
{
|
||||||
|
title: '控制台',
|
||||||
|
tabs: [
|
||||||
{ key: 'appearance', label: '外观', icon: Palette },
|
{ key: 'appearance', label: '外观', icon: Palette },
|
||||||
{ key: 'data', label: '数据与格式', icon: RefreshCw },
|
{ key: 'data', label: '数据与格式', icon: RefreshCw },
|
||||||
{ key: 'advanced', label: '高级', icon: Code2 },
|
|
||||||
{ key: 'account', label: '账号安全', icon: ShieldCheck },
|
{ key: 'account', label: '账号安全', icon: ShieldCheck },
|
||||||
{ key: 'system', label: '服务', icon: Server },
|
],
|
||||||
{ key: 'notifications', label: '通知', icon: Bell },
|
},
|
||||||
|
{
|
||||||
|
title: 'SnowLuma',
|
||||||
|
tabs: [
|
||||||
{ key: 'globalConfig', label: '全局配置', icon: SlidersHorizontal },
|
{ key: 'globalConfig', label: '全局配置', icon: SlidersHorizontal },
|
||||||
|
{ key: 'notifications', label: '通知', icon: Bell },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '平台',
|
||||||
|
tabs: [
|
||||||
|
{ key: 'system', label: '服务', icon: Server },
|
||||||
|
{ key: 'advanced', label: '高级', icon: Code2 },
|
||||||
{ key: 'about', label: '关于', icon: Info },
|
{ key: 'about', label: '关于', icon: Info },
|
||||||
|
],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const TABS: TabDef[] = TAB_GROUPS.flatMap((g) => g.tabs);
|
||||||
|
|
||||||
export function SettingsPage() {
|
export function SettingsPage() {
|
||||||
// Active tab lives in the URL (`?tab=`) so it's deep-linkable — e.g. the
|
// Active tab lives in the URL (`?tab=`) so it's deep-linkable — e.g. the
|
||||||
// sidebar update banner jumps straight to 关于. Default tab omits the param.
|
// sidebar update banner jumps straight to 关于. Default tab omits the param.
|
||||||
@@ -98,12 +121,29 @@ export function SettingsPage() {
|
|||||||
function SettingsNav({ tab, onChange }: { tab: SettingsTab; onChange: (t: SettingsTab) => void }) {
|
function SettingsNav({ tab, onChange }: { tab: SettingsTab; onChange: (t: SettingsTab) => void }) {
|
||||||
return (
|
return (
|
||||||
<nav
|
<nav
|
||||||
|
aria-label="设置导航"
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex flex-wrap gap-1 rounded-xl border bg-card p-1.5',
|
'flex flex-wrap gap-1 rounded-xl border bg-card p-1.5',
|
||||||
'lg:w-52 lg:shrink-0 lg:flex-col lg:flex-nowrap lg:self-start lg:sticky lg:top-4 lg:max-h-[calc(100vh-6rem)] lg:overflow-y-auto',
|
'lg:w-52 lg:shrink-0 lg:flex-col lg:flex-nowrap lg:self-start lg:sticky lg:top-4 lg:max-h-[calc(100vh-6rem)] lg:overflow-y-auto',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{TABS.map((t) => {
|
{TAB_GROUPS.map((group, gi) => (
|
||||||
|
<div
|
||||||
|
key={group.title}
|
||||||
|
role="group"
|
||||||
|
aria-labelledby={`settings-nav-group-${gi}`}
|
||||||
|
className="contents lg:flex lg:flex-col lg:gap-1"
|
||||||
|
>
|
||||||
|
<p
|
||||||
|
id={`settings-nav-group-${gi}`}
|
||||||
|
className={cn(
|
||||||
|
'hidden select-none px-3 pb-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/60 lg:block',
|
||||||
|
gi === 0 ? 'lg:pt-1' : 'lg:pt-3',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{group.title}
|
||||||
|
</p>
|
||||||
|
{group.tabs.map((t) => {
|
||||||
const Icon = t.icon;
|
const Icon = t.icon;
|
||||||
const active = tab === t.key;
|
const active = tab === t.key;
|
||||||
return (
|
return (
|
||||||
@@ -124,6 +164,8 @@ function SettingsNav({ tab, onChange }: { tab: SettingsTab; onChange: (t: Settin
|
|||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
</nav>
|
</nav>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user