import styles from "./Menu.module.less"; import clsx from "clsx"; import { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; export default function Menu() { let navigate = useNavigate(); const [active, setActive] = useState(""); useEffect(() => { initMenu(); }, []); async function initMenu() { // const config = LogicalSize; // console.log({ LogicalSize: new LogicalSize() }); // console.log(window); // setHeight(await window); } const menuConfig = [ { label: "常用", child: [ { label: "文件整理", path: "/file-sort", }, { label: "文件清理", path: "/file-clear", }, { label: "重复文件", path: "/duplicateFile", }, ], }, { label: "系统", child: [ { label: "字符查询", }, { label: "设置", path: "/setting", }, { label: "关于我们", path: "/about", }, ], }, ]; function menuHandle(path: string, label: string) { setActive(label); navigate(path); } return (
占位符:
{menuConfig.map((item) => (
{item.label}
{item?.child?.length > 0 && item?.child.map((childItem) => (
menuHandle(childItem.path || "", childItem.label) } > {childItem.label}
))}
))}
); }