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,
ReaderIcon,
LayersIcon,
FileIcon,
ColorWheelIcon,
HomeIcon,
} 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/comments",
},
{
icon: ,
label: "分类管理",
path: "/dashboard/categories",
},
{
icon: ,
label: "文件管理",
path: "/dashboard/files",
},
{
icon: ,
label: "主题管理",
path: "/dashboard/themes",
},
{
icon: ,
label: "系统设置",
path: "/dashboard/settings",
},
{
icon: ,
label: "用户管理",
path: "/dashboard/users",
},
{
icon: ,
label: "插件管理",
path: "/dashboard/plugins",
},
];
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)}
/>
)}
);
});