|
@@ -1,7 +1,7 @@
|
|
import React, { useState, useEffect } from 'react'
|
|
import React, { useState, useEffect } from 'react'
|
|
-import { Layout, Menu, Breadcrumb } from 'antd'
|
|
|
|
|
|
+import { Layout, Menu } from 'antd'
|
|
import { Route } from 'react-router-dom'
|
|
import { Route } from 'react-router-dom'
|
|
-import { MailOutlined, MehOutlined } from '@ant-design/icons'
|
|
|
|
|
|
+import { MehOutlined } from '@ant-design/icons'
|
|
import './index.scss'
|
|
import './index.scss'
|
|
import '@ant-design/pro-table/dist/table.css'
|
|
import '@ant-design/pro-table/dist/table.css'
|
|
import { routes } from '../router/config'
|
|
import { routes } from '../router/config'
|
|
@@ -12,29 +12,28 @@ const { Header, Content, Sider } = Layout
|
|
const reallyRoutes = routes.map(item => item.children ? item.children : item).flat()
|
|
const reallyRoutes = routes.map(item => item.children ? item.children : item).flat()
|
|
|
|
|
|
const AdminLayout: any = (props) => {
|
|
const AdminLayout: any = (props) => {
|
|
-
|
|
|
|
- useEffect(() => {
|
|
|
|
- setCurrentKeys([props.history.location.pathname])
|
|
|
|
- }, [])
|
|
|
|
- const [currnetKeys, setCurrentKeys]: any = useState(["/admin/role"])
|
|
|
|
|
|
+ const [currentKeys, setCurrentKeys]: any = useState(["/admin/role"])
|
|
|
|
|
|
const switchRoute = route => {
|
|
const switchRoute = route => {
|
|
props.history.push(route.path)
|
|
props.history.push(route.path)
|
|
setCurrentKeys([route.path])
|
|
setCurrentKeys([route.path])
|
|
}
|
|
}
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ setCurrentKeys([props.history.location.pathname])
|
|
|
|
+ }, [props.history.location.pathname])
|
|
|
|
|
|
return (
|
|
return (
|
|
<Layout style={{ minHeight: '100vh' }}>
|
|
<Layout style={{ minHeight: '100vh' }}>
|
|
<Sider style={{ backgroundColor: 'white' }}>
|
|
<Sider style={{ backgroundColor: 'white' }}>
|
|
- <Menu mode="inline" selectedKeys={currnetKeys}>
|
|
|
|
|
|
+ <Menu mode="inline" selectedKeys={currentKeys}>
|
|
{
|
|
{
|
|
- routes.map((route, index) => {
|
|
|
|
|
|
+ routes.map((route) => {
|
|
return (
|
|
return (
|
|
route.children
|
|
route.children
|
|
?
|
|
?
|
|
- <Menu.SubMenu title={route.title}>
|
|
|
|
|
|
+ <Menu.SubMenu key={route.path} title={route.title}>
|
|
{
|
|
{
|
|
- route.children.filter(item => !item.hideInMenu).map((child, childIndex) =>
|
|
|
|
|
|
+ route.children.filter(item => !item.hideInMenu).map(child =>
|
|
<Menu.Item
|
|
<Menu.Item
|
|
key={child.path}
|
|
key={child.path}
|
|
onClick={() => switchRoute(child)}
|
|
onClick={() => switchRoute(child)}
|
|
@@ -64,8 +63,7 @@ const AdminLayout: any = (props) => {
|
|
</Header>
|
|
</Header>
|
|
<Content className='layout-content'>
|
|
<Content className='layout-content'>
|
|
{
|
|
{
|
|
- reallyRoutes.
|
|
|
|
- map(route =>
|
|
|
|
|
|
+ reallyRoutes.map(route =>
|
|
<Route
|
|
<Route
|
|
exact
|
|
exact
|
|
path={route.path}
|
|
path={route.path}
|