diff --git a/src/components/layout/MainLayout.tsx b/src/components/layout/MainLayout.tsx index 8572de7..e8edf65 100644 --- a/src/components/layout/MainLayout.tsx +++ b/src/components/layout/MainLayout.tsx @@ -207,8 +207,6 @@ export function MainLayout() { const { showNotification } = useNotificationStore(); const location = useLocation(); - const apiBase = useAuthStore((state) => state.apiBase); - const connectionStatus = useAuthStore((state) => state.connectionStatus); const logout = useAuthStore((state) => state.logout); const config = useConfigStore((state) => state.config); @@ -224,18 +222,17 @@ export function MainLayout() { const [sidebarCollapsed, setSidebarCollapsed] = useState(false); const [languageMenuOpen, setLanguageMenuOpen] = useState(false); const [themeMenuOpen, setThemeMenuOpen] = useState(false); - const [brandExpanded, setBrandExpanded] = useState(true); const contentRef = useRef(null); const languageMenuRef = useRef(null); const themeMenuRef = useRef(null); - const brandCollapseTimer = useRef | null>(null); const headerRef = useRef(null); const fullBrandName = 'CLI Proxy API Management Center'; const abbrBrandName = t('title.abbr'); const isLogsPage = location.pathname.startsWith('/logs'); + const showSidebarLabels = !sidebarCollapsed || sidebarOpen; - // 将顶栏高度写入 CSS 变量,确保侧栏/内容区计算一致,防止滚动时抖动 + // 将顶部悬浮控制区高度写入 CSS 变量,供移动端粘性元素和浮层避让。 useLayoutEffect(() => { const updateHeaderHeight = () => { const height = headerRef.current?.offsetHeight; @@ -296,19 +293,6 @@ export function MainLayout() { }; }, []); - // 5秒后自动收起品牌名称 - useEffect(() => { - brandCollapseTimer.current = setTimeout(() => { - setBrandExpanded(false); - }, 5000); - - return () => { - if (brandCollapseTimer.current) { - clearTimeout(brandCollapseTimer.current); - } - }; - }, []); - useEffect(() => { if (!languageMenuOpen) { return; @@ -361,19 +345,6 @@ export function MainLayout() { }; }, [themeMenuOpen]); - const handleBrandClick = useCallback(() => { - if (!brandExpanded) { - setBrandExpanded(true); - // 点击展开后,5秒后再次收起 - if (brandCollapseTimer.current) { - clearTimeout(brandCollapseTimer.current); - } - brandCollapseTimer.current = setTimeout(() => { - setBrandExpanded(false); - }, 5000); - } - }, [brandExpanded]); - const toggleLanguageMenu = useCallback(() => { setLanguageMenuOpen((prev) => !prev); setThemeMenuOpen(false); @@ -409,15 +380,6 @@ export function MainLayout() { }); }, [fetchConfig]); - const statusClass = - connectionStatus === 'connected' - ? 'success' - : connectionStatus === 'connecting' - ? 'warning' - : connectionStatus === 'error' - ? 'error' - : 'muted'; - const navItems = [ { path: '/', label: t('nav.dashboard'), icon: sidebarIcons.dashboard }, { path: '/config', label: t('nav.config_management'), icon: sidebarIcons.config }, @@ -508,176 +470,157 @@ export function MainLayout() { }; return ( -
+
+