import { Layout } from "interface/layout"; import { ThemeModeToggle } from "hooks/ThemeMode"; import { Container, Flex, Box, Link, Button } from "@radix-ui/themes"; import { HamburgerMenuIcon, Cross1Icon, PersonIcon, ExitIcon, DashboardIcon, GearIcon, FileTextIcon, ImageIcon, ReaderIcon, LayersIcon, } from "@radix-ui/react-icons"; import { Theme } from "@radix-ui/themes"; import { useState, useEffect } from "react"; import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"; import throttle from "lodash/throttle"; // 定义侧边栏菜单项 const menuItems = [ { icon: , label: "仪表盘", path: "/dashboard", }, { icon: , label: "文章管理", path: "/dashboard/posts", }, { icon: , label: "媒体管理", path: "/dashboard/media", }, { icon: , label: "评论管理", path: "/dashboard/comments", }, { icon: , label: "分类管理", path: "/dashboard/categories", }, { icon: , label: "系统设置", path: "/dashboard/settings", }, ]; export default new Layout(({ children }) => { const [sidebarCollapsed, setSidebarCollapsed] = useState(false); const [mobileMenuOpen, setMobileMenuOpen] = useState(false); useEffect(() => { const handleResize = throttle(() => { if (window.innerWidth >= 1024) { setMobileMenuOpen(false); } }, 200); window.addEventListener("resize", handleResize); return () => { window.removeEventListener("resize", handleResize); handleResize.cancel(); }; }, []); return ( {/* 侧边栏 */} {/* Logo区域 */} A 后台管理 {/* 菜单列表区域添加滚动 */} {menuItems.map((item) => ( {item.icon} {item.label} ))} {/* 主内容区域 */} {/* 顶部导航栏 */} {/* 左侧菜单按钮 */} {mobileMenuOpen ? ( ) : ( )} {/* 右侧用户菜单 */} 个人设置 退出登录 {/* 页面内容区域 */} {children} {/* 移动端菜单遮罩 */} {mobileMenuOpen && ( setMobileMenuOpen(false)} /> )} ); });