fix(webui): hide sidebar pin controls in menu mode
Keep sidebar pinning available in desktop navigation and hide its controls when navigation uses the menu. Fixes #485
This commit is contained in:
4 files changed
+18
-10
No files matched your search
@@ -6,7 +6,7 @@ import { Sheet, SheetContent, SheetDescription, SheetTitle } from '@/components/
|
||||
import { ScrollArea } from '@/components/ui/scroll-area';
|
||||
import { Sidebar } from '@/components/layout/sidebar';
|
||||
import { TopBar } from '@/components/layout/top-bar';
|
||||
import { useFinePointer, useMediaQuery } from '@/hooks/use-media-query';
|
||||
import { useDesktopSidebar } from '@/hooks/use-media-query';
|
||||
import { useTheme } from '@/contexts/ThemeContext';
|
||||
import { useLayout } from '@/contexts/LayoutContext';
|
||||
import { useKiosk } from '@/contexts/KioskContext';
|
||||
@@ -20,9 +20,7 @@ interface MainLayoutProps {
|
||||
}
|
||||
|
||||
export function MainLayout({ status, onLogout, notice, children }: MainLayoutProps) {
|
||||
const isWide = useMediaQuery('(min-width: 768px)');
|
||||
const canHover = useFinePointer();
|
||||
const isMobile = !isWide || !canHover;
|
||||
const isMobile = !useDesktopSidebar();
|
||||
const { appearance } = useTheme();
|
||||
const customBg = appearance.background.type !== 'none';
|
||||
// Framer's reducedMotion only suppresses transforms, so the always-present
|
||||
@@ -55,7 +53,7 @@ export function MainLayout({ status, onLogout, notice, children }: MainLayoutPro
|
||||
initial={false}
|
||||
animate={{ width: showCollapsed ? 64 : 248 }}
|
||||
transition={reduce ? { duration: 0 } : { duration: 0.26, ease: [0.4, 0, 0.1, 1] }}
|
||||
onMouseEnter={() => { if (canHover) setHovered(true); }}
|
||||
onMouseEnter={() => setHovered(true)}
|
||||
onMouseLeave={() => setHovered(false)}
|
||||
onFocusCapture={(e) => {
|
||||
// Only *keyboard* focus (focus-visible) peeks the rail open. A mouse
|
||||
|
||||
@@ -7,7 +7,7 @@ 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 { useDesktopSidebar } from '@/hooks/use-media-query';
|
||||
import type { AppPath } from '@/router';
|
||||
import type { UiLayoutItem } from '@/types';
|
||||
|
||||
@@ -95,7 +95,7 @@ export function Sidebar({ collapsed = false, onItemClick }: SidebarProps) {
|
||||
const { updateInfo } = useAppState();
|
||||
const { navItems, setNavItems, editing, setEditing } = useLayout();
|
||||
const { appearance, setAppearance } = useTheme();
|
||||
const isDesktop = useMediaQuery('(min-width: 768px)');
|
||||
const isDesktop = useDesktopSidebar();
|
||||
const pinned = appearance.sidebarPinned;
|
||||
|
||||
// Full reconciled nav (incl. hidden) — pinned forced visible, forward-compat.
|
||||
|
||||
@@ -35,6 +35,7 @@ import {
|
||||
import { DEFAULT_LAYOUT, DEFAULT_PAGES, reconcileLayoutItems, useLayout } from '@/contexts/LayoutContext';
|
||||
import { useActionFeedback } from '@/contexts/ActionFeedbackContext';
|
||||
import { useSession } from '@/contexts/SessionContext';
|
||||
import { useDesktopSidebar } from '@/hooks/use-media-query';
|
||||
import { NAV_ITEMS } from '@/components/layout/sidebar';
|
||||
import { TOPBAR_CATALOGUE } from '@/components/layout/top-bar';
|
||||
import { TotpPanel } from '@/components/settings/totp-panel';
|
||||
@@ -375,6 +376,7 @@ function TopbarPanel() {
|
||||
}
|
||||
|
||||
function AppearancePanel() {
|
||||
const isDesktop = useDesktopSidebar();
|
||||
const { appearance, setAppearance, uploadBackground, removeBackground, resolved } = useTheme();
|
||||
const a = appearance;
|
||||
// A Catppuccin flavor fixes its own light/dark + darkness, so the mode and
|
||||
@@ -566,9 +568,11 @@ function AppearancePanel() {
|
||||
<SettingRow label="高对比模式" hint="加强边框与次要文字的对比度。" layout="inline">
|
||||
<ToggleSwitch value={a.highContrast} onChange={(highContrast) => setAppearance({ highContrast })} ariaLabel="高对比模式" />
|
||||
</SettingRow>
|
||||
<SettingRow label="钉住侧栏展开" hint="侧栏常驻展开,不再收成图标轨、也不随悬停自动收起。" layout="inline">
|
||||
<ToggleSwitch value={a.sidebarPinned} onChange={(sidebarPinned) => setAppearance({ sidebarPinned })} ariaLabel="钉住侧栏展开" />
|
||||
</SettingRow>
|
||||
{isDesktop && (
|
||||
<SettingRow label="钉住侧栏展开" hint="侧栏常驻展开,不再收成图标轨、也不随悬停自动收起。" layout="inline">
|
||||
<ToggleSwitch value={a.sidebarPinned} onChange={(sidebarPinned) => setAppearance({ sidebarPinned })} ariaLabel="钉住侧栏展开" />
|
||||
</SettingRow>
|
||||
)}
|
||||
</Group>
|
||||
|
||||
<ConfirmDialog
|
||||
|
||||
Reference in new issue
Block a user