import React, { useEffect } from "react"; import { Menu } from "antd"; //导出路由跳转hooks函数 import { useNavigate, Link, useLocation } from "react-router-dom"; import styles from "./index.module.less"; import logo from "../../assets/logo.png"; import "../../assets/iconfont/iconfont.css"; function getItem(label: any, key: any, icon: any, children: any, type: any) { return { key, icon, children, label, type, }; } const items = [ getItem( "首页概览", "/", , null, null ), getItem( "分类管理", "/resource-category", , null, null ), getItem( "资源管理", "3", , [ getItem("视频", "/videos", null, null, null), getItem("图片", "/images", null, null, null), ], null ), getItem( "课程中心", "4", , [getItem("线上课", "/course", null, null, null)], null ), getItem( "学员管理", "5", , [ getItem("学员", "/member", null, null, null), getItem("部门", "/department", null, null, null), ], null ), getItem( "系统设置", "6", , [ getItem("管理人员", "/system/administrator", null, null, null), getItem("系统配置", "/system/index", null, null, null), getItem("角色配置", "/system/adminroles", null, null, null), ], null ), ]; const children2Parent: any = { "/videos": ["3"], "/images": ["3"], "/member": ["4"], "/department": ["4"], "/course": ["5"], "/system/administrator": ["6"], "/system/adminroles": ["6"], "/system/index": ["6"], }; export const LeftMenu: React.FC = () => { const location = useLocation(); const navigate = useNavigate(); let defaultSelectedKeys: string[] = [location.pathname]; let defaultOpenKeys: string[] = []; if (children2Parent[location.pathname]) { defaultOpenKeys = children2Parent[location.pathname]; } const onClick = (e: any) => { navigate(e.key); }; useEffect(() => {}, [location]); return (
{ window.location.href = "/"; }} >
); };