feat(webui): kiosk (展示模式) for chrome-free wall displays (B2)

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.
This commit is contained in:
DrSmoothl committed 2026-06-16 14:32:57 +08:00
1 parent 72e0d6bcca
commit 1a0bc12ec0
6 files changed
+134 -26

No files matched your search

@@ -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') && <ThemeToggle />}
{shown.has('kiosk') && (
<Button
variant="ghost"
size="icon-sm"
onClick={enterKiosk}
aria-label="展示模式"
title="展示模式(隐藏侧栏与顶栏,Esc 退出)"
className="text-muted-foreground hover:text-foreground"
>
<Monitor className="size-4" />
</Button>
)}
<Button
variant="ghost"
size="icon-sm"