From 1a0bc12ec0c05bd43a18526692fdc2770737b50b Mon Sep 17 00:00:00 2001 From: DrSmoothl <1787882683@qq.com> Date: Tue, 16 Jun 2026 14:32:57 +0800 Subject: [PATCH] =?UTF-8?q?feat(webui):=20kiosk=20(=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F)=20for=20chrome-free=20wall=20displays=20(B2?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A session-sticky kiosk mode for showing the dashboard on a wall display: - Entry: `?kiosk=1` URL param (stripped after read) or a top-bar button (toggleable via topbarItems 'kiosk'). - Hides the sidebar + top bar (MainLayout) and any in-content edit entry marked data-kiosk-hide (the overview 编辑布局 toolbar) via an html[data-kiosk] CSS rule. - Exit: Esc key or a dim corner button. Purely cosmetic — never touches auth and issues no token. A new KioskProvider (sessionStorage-backed, mounted under LayoutProvider) owns the state. Completes the B2 dashboard/components batch. --- .../src/components/layout/main-layout.tsx | 44 +++++++++---- .../webui/src/components/layout/top-bar.tsx | 18 +++++- .../src/components/pages/overview-page.tsx | 5 +- packages/webui/src/contexts/KioskContext.tsx | 64 +++++++++++++++++++ packages/webui/src/index.css | 6 ++ packages/webui/src/router/app-layout.tsx | 23 ++++--- 6 files changed, 134 insertions(+), 26 deletions(-) create mode 100644 packages/webui/src/contexts/KioskContext.tsx 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 (