diff --git a/packages/webui/src/components/layout/main-layout.tsx b/packages/webui/src/components/layout/main-layout.tsx index a21602b9..30dfe59e 100644 --- a/packages/webui/src/components/layout/main-layout.tsx +++ b/packages/webui/src/components/layout/main-layout.tsx @@ -1,6 +1,7 @@ import { useEffect, useState, type ReactNode } from 'react'; import { motion, AnimatePresence } from 'motion/react'; import { useRouterState } from '@tanstack/react-router'; +import { Minimize2 } from 'lucide-react'; import { Sheet, SheetContent, SheetDescription, SheetTitle } from '@/components/ui/sheet'; import { ScrollArea } from '@/components/ui/scroll-area'; import { Sidebar } from '@/components/layout/sidebar'; @@ -8,6 +9,7 @@ import { TopBar } from '@/components/layout/top-bar'; import { useMediaQuery } from '@/hooks/use-media-query'; import { useTheme } from '@/contexts/ThemeContext'; import { useLayout } from '@/contexts/LayoutContext'; +import { useKiosk } from '@/contexts/KioskContext'; import { cn } from '@/lib/utils'; interface MainLayoutProps { @@ -33,6 +35,7 @@ export function MainLayout({ status, onLogout, children }: MainLayoutProps) { // “减少动效” setting actually felt. const reduce = appearance.reduceMotion || appearance.disableMotion; const { editing } = useLayout(); + const { kiosk, exit: exitKiosk } = useKiosk(); // Force the sidebar open while editing layout so its drag-to-reorder list // has room (it returns to the user's collapsed pref on 完成). const effectiveCollapsed = collapsed && !editing; @@ -45,8 +48,8 @@ export function MainLayout({ status, onLogout, children }: MainLayoutProps) { return (
- {/* Desktop sidebar */} - {!isMobile && ( + {/* Desktop sidebar (hidden in kiosk) */} + {!isMobile && !kiosk && ( )} - {/* Mobile sidebar in sheet */} - {isMobile && ( + {/* Mobile sidebar in sheet (hidden in kiosk) */} + {isMobile && !kiosk && ( {/* Radix Dialog (the Sheet primitive) requires an accessible name + @@ -71,17 +74,32 @@ export function MainLayout({ status, onLogout, children }: MainLayoutProps) { )} + {/* Kiosk: chrome-free, with a corner button (+ Esc) to exit. */} + {kiosk && ( + + )} + {/* Main column */}
- setCollapsed((v) => !v)} - onOpenMobile={() => setMobileOpen(true)} - onLogout={onLogout} - isMobile={isMobile} - editing={editing} - /> + {!kiosk && ( + setCollapsed((v) => !v)} + onOpenMobile={() => setMobileOpen(true)} + onLogout={onLogout} + isMobile={isMobile} + editing={editing} + /> + )}
diff --git a/packages/webui/src/components/layout/top-bar.tsx b/packages/webui/src/components/layout/top-bar.tsx index 6b2cf7ff..e5268484 100644 --- a/packages/webui/src/components/layout/top-bar.tsx +++ b/packages/webui/src/components/layout/top-bar.tsx @@ -1,5 +1,5 @@ import { useState } from 'react'; -import { LogOut, Menu, PanelLeftClose, PanelLeftOpen } from 'lucide-react'; +import { LogOut, Menu, Monitor, PanelLeftClose, PanelLeftOpen } from 'lucide-react'; import { motion, AnimatePresence } from 'motion/react'; import { useRouterState } from '@tanstack/react-router'; import { Button } from '@/components/ui/button'; @@ -8,12 +8,14 @@ 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'; +import { useKiosk } from '@/contexts/KioskContext'; // 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: '主题切换按钮' }, + { id: 'kiosk', label: '展示模式按钮' }, ]; interface TopBarProps { @@ -45,6 +47,7 @@ export function TopBar({ // 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 { enter: enterKiosk } = useKiosk(); const shown = new Set( reconcileLayoutItems(topbarItems, TOPBAR_CATALOGUE.map((t) => t.id)) .filter((i) => i.visible) @@ -104,6 +107,19 @@ export function TopBar({ {shown.has('theme') && } + {shown.has('kiosk') && ( + + )} +