import React from 'react'; import {Layout, Menu} from "antd"; import { BorderBottomOutlined, HeatMapOutlined, MacCommandOutlined, OneToOneOutlined, SlidersOutlined, UploadOutlined, UserOutlined, VideoCameraOutlined, WindowsOutlined } from "@ant-design/icons"; import CollapsedStore from "../../store/CollapsedStore.ts"; import {observer} from "mobx-react-lite"; import {useLocation, useNavigate} from "react-router-dom"; import {MyItemType} from "../../pages/UniService/type.ts"; function SiderBlock() { const { Sider} = Layout; const navigate = useNavigate(); const menuItems:MyItemType[] = [ { key: '1', icon: , label: '统一服务', to:'/' }, { key: '2', icon: , label: '报警联动', to:'/alarm' }, { key: '3', icon: , label: '设备接入', to:'/devicesInsert' }, { key: '4', icon: , label: '阈值修改', to:'/threshold' }, { key: '5', icon: , label: '报警查看处理', to:'/CheckProcess' }, { key: '6', icon: , label: '参数监测', to:'/monitor' }, { key: '7', icon: , label: '远程控制', to:'/remoteControl' }, { key: '8', icon: , label: '远程自检', to:'/remoteCheck' }, { key: '9', icon: , label: '定时任务', to:'/timingTask' }, { key: '10', icon: , label: '历史统计', to:'/history' }, ]; const selectedKeys = ['1']; const {pathname} = useLocation(); const currentMenu = menuItems.find(item => item.to == pathname); if (currentMenu) { selectedKeys[0] = currentMenu.key; } const onMenuSelect = ({key}) => { const item:MyItemType | undefined= menuItems.find(item => item.key === key); if (item) { if(item.to){ navigate(item.to) } } }; return ( <>
{!CollapsedStore.collapsed? (
智慧灯杆系统
): }
({ key: item.key, icon: item.icon, label: item.label, }))} /> ); } export default observer(SiderBlock);