|
@ -3,6 +3,7 @@ import PerfectScrollbar from 'perfect-scrollbar'; |
|
|
import { connect } from 'react-redux'; |
|
|
import { connect } from 'react-redux'; |
|
|
import { Nav } from '@douyinfe/semi-ui'; |
|
|
import { Nav } from '@douyinfe/semi-ui'; |
|
|
import { push } from 'react-router-redux'; |
|
|
import { push } from 'react-router-redux'; |
|
|
|
|
|
import { useLocation } from 'react-router'; |
|
|
|
|
|
|
|
|
let scrollbar = null |
|
|
let scrollbar = null |
|
|
const homePath = '/equipmentWarehouse/nvr' |
|
|
const homePath = '/equipmentWarehouse/nvr' |
|
@ -45,7 +46,6 @@ const Sider = props => { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
console.log(nextItems) |
|
|
|
|
|
setItems(nextItems) |
|
|
setItems(nextItems) |
|
|
|
|
|
|
|
|
const { selectedKeys, openKeys } = initKeys( |
|
|
const { selectedKeys, openKeys } = initKeys( |
|
@ -74,9 +74,9 @@ const Sider = props => { |
|
|
dispatch(push(homePath)) |
|
|
dispatch(push(homePath)) |
|
|
} |
|
|
} |
|
|
}, []) |
|
|
}, []) |
|
|
|
|
|
let routeSelectedKey = [useLocation().pathname.split('/')[1]]//没有子目录的 |
|
|
|
|
|
let routeSelectedKeys = [useLocation().pathname.split('/')[2]]//有子目录的 |
|
|
useEffect(()=>{ |
|
|
useEffect(()=>{ |
|
|
console.log(1) |
|
|
|
|
|
let pathname_ = pathname == '/' ? homePath : pathname |
|
|
let pathname_ = pathname == '/' ? homePath : pathname |
|
|
const initKeys = (items, lastKeys) => { |
|
|
const initKeys = (items, lastKeys) => { |
|
|
for (let it of items) { |
|
|
for (let it of items) { |
|
@ -93,15 +93,13 @@ const Sider = props => { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return lastKeys |
|
|
return lastKeys |
|
|
return { |
|
|
|
|
|
selectedKeys: [], |
|
|
|
|
|
openKeys: [] |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(routeSelectedKeys[0]){ |
|
|
|
|
|
setSelectedKeys(routeSelectedKeys) |
|
|
} |
|
|
} |
|
|
const lastSelectedKeys = localStorage.getItem('vcmp_selected_sider') |
|
|
else{ |
|
|
console.log(lastSelectedKeys) |
|
|
setSelectedKeys(routeSelectedKey) |
|
|
if (lastSelectedKeys) { |
|
|
|
|
|
setSelectedKeys(JSON.parse(lastSelectedKeys)) |
|
|
|
|
|
} |
|
|
} |
|
|
const lastOpenKeys = localStorage.getItem('vcmp_open_sider') |
|
|
const lastOpenKeys = localStorage.getItem('vcmp_open_sider') |
|
|
if (lastOpenKeys) { |
|
|
if (lastOpenKeys) { |
|
@ -114,7 +112,6 @@ const Sider = props => { |
|
|
scrollbar.update(); |
|
|
scrollbar.update(); |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
console.log(selectedKeys,openKeys) |
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<div id={'page-slider'} style={{ height: clientHeight, position: 'relative' }}> |
|
|
<div id={'page-slider'} style={{ height: clientHeight, position: 'relative' }}> |
|
|
<Nav |
|
|
<Nav |
|
|