diff --git a/packages/webui/src/components/layout/top-bar.tsx b/packages/webui/src/components/layout/top-bar.tsx index e86993ee..6b2cf7ff 100644 --- a/packages/webui/src/components/layout/top-bar.tsx +++ b/packages/webui/src/components/layout/top-bar.tsx @@ -7,6 +7,14 @@ import { Badge } from '@/components/ui/badge'; import { ThemeToggle } from '@/components/theme-toggle'; import { ConfirmDialog } from '@/components/confirm-dialog'; import { NAV_ITEMS } from '@/components/layout/sidebar'; +import { reconcileLayoutItems, useLayout } from '@/contexts/LayoutContext'; + +// Toggleable top-bar elements (the menu/title/logout are essential and always +// render). Labels drive the settings toggles; ids match `topbarItems`. +export const TOPBAR_CATALOGUE: { id: string; label: string }[] = [ + { id: 'status', label: '连接状态徽章' }, + { id: 'theme', label: '主题切换按钮' }, +]; interface TopBarProps { status: string; @@ -34,6 +42,15 @@ export function TopBar({ const PageIcon = meta?.icon; const online = status === '已连接'; + // Which optional top-bar elements the operator has kept (reconciled against + // the live catalogue, so a new element defaults to shown). + const { topbarItems } = useLayout(); + const shown = new Set( + reconcileLayoutItems(topbarItems, TOPBAR_CATALOGUE.map((t) => t.id)) + .filter((i) => i.visible) + .map((i) => i.id), + ); + return (
{/* Collapse toggle (desktop) / menu (mobile) */} @@ -73,17 +90,19 @@ export function TopBar({
- - - {status} - + {shown.has('status') && ( + + + {status} + + )} - + {shown.has('theme') && }