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:
DrSmoothl committed 2026-06-28 22:25:39 +08:00
1 parent 196f98e97c
commit 2b15bc6710
1 file changed
+69 -27
@@ -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 }
{ key: 'appearance', label: '外观', icon: Palette },
{ key: 'data', label: '数据与格式', icon: RefreshCw }, // Three domains, rendered as macOS System-Settings-style sidebar sections:
{ key: 'advanced', label: '高级', icon: Code2 }, // the dashboard itself (控制台), the all-accounts SnowLuma protocol runtime,
{ key: 'account', label: '账号安全', icon: ShieldCheck }, // and the host/deployment (平台). Section headers show on the desktop rail
{ key: 'system', label: '服务', icon: Server }, // only; the mobile strip stays a flat wrap.
{ key: 'notifications', label: '通知', icon: Bell }, const TAB_GROUPS: { title: string; tabs: TabDef[] }[] = [
{ key: 'globalConfig', label: '全局配置', icon: SlidersHorizontal }, {
{ key: 'about', label: '关于', icon: Info }, title: '控制台',
tabs: [
{ key: 'appearance', label: '外观', icon: Palette },
{ key: 'data', label: '数据与格式', icon: RefreshCw },
{ key: 'account', label: '账号安全', icon: ShieldCheck },
],
},
{
title: 'SnowLuma',
tabs: [
{ 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 },
],
},
]; ];
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,32 +121,51 @@ 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) => (
const Icon = t.icon; <div
const active = tab === t.key; key={group.title}
return ( role="group"
<button aria-labelledby={`settings-nav-group-${gi}`}
key={t.key} className="contents lg:flex lg:flex-col lg:gap-1"
type="button" >
onClick={() => onChange(t.key)} <p
aria-current={active ? 'page' : undefined} id={`settings-nav-group-${gi}`}
className={cn( className={cn(
'inline-flex shrink-0 items-center gap-2.5 whitespace-nowrap rounded-lg px-3 py-2 text-sm font-medium transition-colors cursor-pointer outline-none focus-visible:ring-[3px] focus-visible:ring-ring/40 lg:w-full', 'hidden select-none px-3 pb-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/60 lg:block',
active gi === 0 ? 'lg:pt-1' : 'lg:pt-3',
? 'bg-accent text-foreground ring-1 ring-primary/20'
: 'text-muted-foreground hover:bg-accent/50 hover:text-foreground',
)} )}
> >
<Icon className={cn('size-4 shrink-0', active && 'text-primary')} /> {group.title}
{t.label} </p>
</button> {group.tabs.map((t) => {
); const Icon = t.icon;
})} const active = tab === t.key;
return (
<button
key={t.key}
type="button"
onClick={() => onChange(t.key)}
aria-current={active ? 'page' : undefined}
className={cn(
'inline-flex shrink-0 items-center gap-2.5 whitespace-nowrap rounded-lg px-3 py-2 text-sm font-medium transition-colors cursor-pointer outline-none focus-visible:ring-[3px] focus-visible:ring-ring/40 lg:w-full',
active
? 'bg-accent text-foreground ring-1 ring-primary/20'
: 'text-muted-foreground hover:bg-accent/50 hover:text-foreground',
)}
>
<Icon className={cn('size-4 shrink-0', active && 'text-primary')} />
{t.label}
</button>
);
})}
</div>
))}
</nav> </nav>
); );
} }