diff --git a/packages/webui/src/components/layout/main-layout.tsx b/packages/webui/src/components/layout/main-layout.tsx index 512abe9f..81515f8e 100644 --- a/packages/webui/src/components/layout/main-layout.tsx +++ b/packages/webui/src/components/layout/main-layout.tsx @@ -66,7 +66,13 @@ export function MainLayout({ status, onLogout, children }: MainLayoutProps) { }} className="relative h-full shrink-0 overflow-hidden" > - + {/* Fixed-width inner: the rail's content is ALWAYS laid out at the + expanded width and the aside simply clips it as `width` animates. + Nothing reflows during the transition, so icons never shift and + labels never wrap — they're revealed/clipped, not re-laid-out. */} +
+ +
)} diff --git a/packages/webui/src/components/layout/sidebar.tsx b/packages/webui/src/components/layout/sidebar.tsx index 7deec9fd..66563353 100644 --- a/packages/webui/src/components/layout/sidebar.tsx +++ b/packages/webui/src/components/layout/sidebar.tsx @@ -1,11 +1,13 @@ -import { Bug, Check, Eye, EyeOff, GripVertical, LayoutDashboard, Lock, PlugZap, Settings, Sparkles, SlidersHorizontal, Terminal } from 'lucide-react'; +import { Bug, Check, Eye, EyeOff, GripVertical, LayoutDashboard, Lock, Pin, PinOff, PlugZap, Settings, Sparkles, SlidersHorizontal, Terminal } from 'lucide-react'; import { motion, Reorder } from 'motion/react'; import { Link, useRouterState } from '@tanstack/react-router'; import { ScrollArea } from '@/components/ui/scroll-area'; import { cn } from '@/lib/utils'; import { APP_NAME, APP_VERSION } from '@/types'; import { useAppState } from '@/contexts/AppStateContext'; +import { useTheme } from '@/contexts/ThemeContext'; import { reconcileLayoutItems, useLayout } from '@/contexts/LayoutContext'; +import { useMediaQuery } from '@/hooks/use-media-query'; import type { AppPath } from '@/router'; export interface NavItem { @@ -39,6 +41,9 @@ export function Sidebar({ collapsed = false, onItemClick }: SidebarProps) { const pathname = useRouterState({ select: (s) => s.location.pathname }); const { updateInfo } = useAppState(); const { navItems, setNavItems, editing, setEditing } = useLayout(); + const { appearance, setAppearance } = useTheme(); + const isDesktop = useMediaQuery('(min-width: 768px)'); + const pinned = appearance.sidebarPinned; // Full reconciled nav (incl. hidden) — pinned forced visible, forward-compat. const reconciled = reconcileLayoutItems(navItems, NAV_ITEMS.map((i) => i.to), PINNED_NAV); @@ -56,21 +61,23 @@ export function Sidebar({ collapsed = false, onItemClick }: SidebarProps) { setNavItems(reconciled.map((i) => (i.id === id ? { ...i, visible: !i.visible } : i))); return ( -
- {/* Brand */} -
-
- SnowLuma -
- {!collapsed && ( -
-
- {APP_NAME} - v{APP_VERSION} -
- OneBot v11 控制台 +
+ {/* Brand — logo sits in a fixed 48px column centred in the collapsed + rail; the wordmark to its right is clipped (never unmounted) when the + rail narrows. */} +
+
+
+ SnowLuma
- )} +
+
+
+ {APP_NAME} + v{APP_VERSION} +
+ OneBot v11 控制台 +
{/* Nav */} @@ -92,7 +99,7 @@ export function Sidebar({ collapsed = false, onItemClick }: SidebarProps) { const meta = NAV_ITEMS.find((n) => n.to === item.id); if (!meta) return null; const Icon = meta.icon; - const pinned = (PINNED_NAV as string[]).includes(item.id); + const itemPinned = (PINNED_NAV as string[]).includes(item.id); return ( {meta.label} - {pinned ? ( + {itemPinned ? ( @@ -126,7 +133,7 @@ export function Sidebar({ collapsed = false, onItemClick }: SidebarProps) {
) : ( -