1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| import React from 'react' import { Menu, Layout } from 'antd' import { AppstoreOutlined, MailOutlined, SettingOutlined } from '@ant-design/icons'; import { useNavigate,useLocation } from 'react-router-dom'
import '../style/layout.less';
const { Sider } = Layout;
function getItem(label, key, icon, children, type) { const item = {key,icon,children,label,type,} return item; }
const items = [ getItem('字典表', '/dictionaryTable', <MailOutlined />), getItem('工单管理', '/order', <AppstoreOutlined />, [ getItem('工单列表', '/order/orderList'), getItem('工单统计', '/order/orderStatistics') ]), getItem('系统设置', '/systemSetting', <AppstoreOutlined />, [ getItem('菜单设置', '/menuControl') ]), getItem('资产管理', '/assetManagement', <SettingOutlined />), getItem('区域管理', '/regionalManagement', <SettingOutlined />,) ];
const AppAside = (props) => {
const localhost = useLocation();
const openKeys = localhost.pathname.split('/')[1];
const onClick = (e) => { navigation(e.key) };
const navigation = useNavigate();
return ( <Sider width={250} className="layout-sider-box" collapsed={props.collapsed}> {props.collapsed? <div className="sider-logo-box vertical-horizontal-center f20">Logo</div> : <div className="sider-logo-box vertical-horizontal-center f30">Logo</div>} <Menu onClick={onClick} defaultSelectedKeys={['/dictionaryTable']} defaultOpenKeys={['/' + openKeys]} mode="inline" theme="dark" items={items} /> </Sider> ) }
export default (props) => { return <AppAside {...props}/>; }
|