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
+69
-27
@@ -45,17 +45,40 @@ import { NotificationsPanel } from '@/components/settings/notifications-panel';
|
||||
import { GlobalConfigPanel } from '@/components/settings/global-config-panel';
|
||||
import { SystemPanel } from '@/components/settings/system-panel';
|
||||
|
||||
const TABS: { key: SettingsTab; label: string; icon: typeof Sun }[] = [
|
||||
{ key: 'appearance', label: '外观', icon: Palette },
|
||||
{ key: 'data', label: '数据与格式', icon: RefreshCw },
|
||||
{ key: 'advanced', label: '高级', icon: Code2 },
|
||||
{ key: 'account', label: '账号安全', icon: ShieldCheck },
|
||||
{ key: 'system', label: '服务', icon: Server },
|
||||
{ key: 'notifications', label: '通知', icon: Bell },
|
||||
{ key: 'globalConfig', label: '全局配置', icon: SlidersHorizontal },
|
||||
{ key: 'about', label: '关于', icon: Info },
|
||||
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: '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() {
|
||||
// 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.
|
||||
@@ -98,32 +121,51 @@ export function SettingsPage() {
|
||||
function SettingsNav({ tab, onChange }: { tab: SettingsTab; onChange: (t: SettingsTab) => void }) {
|
||||
return (
|
||||
<nav
|
||||
aria-label="设置导航"
|
||||
className={cn(
|
||||
'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',
|
||||
)}
|
||||
>
|
||||
{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}
|
||||
{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(
|
||||
'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',
|
||||
'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',
|
||||
)}
|
||||
>
|
||||
<Icon className={cn('size-4 shrink-0', active && 'text-primary')} />
|
||||
{t.label}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
{group.title}
|
||||
</p>
|
||||
{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>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user