|
|
@ -16,51 +16,7 @@ const Sider = (props) => { |
|
|
|
useEffect(() => { |
|
|
|
const { sections, dispatch, user } = props; |
|
|
|
let nextItems = leftItems |
|
|
|
// let pathname_ = pathname == '/' ? homePath : pathname |
|
|
|
// const initKeys = (items, lastKeys) => { |
|
|
|
// // console.log('1111111',items); |
|
|
|
// for (let it of items) { |
|
|
|
// if (it.to && it.to == pathname_) { |
|
|
|
// // console.log('22222222222',it.itemKey); |
|
|
|
// lastKeys.selectedKeys.push(it.itemKey) |
|
|
|
// return lastKeys |
|
|
|
// } else if (it.items && it.items.length) { |
|
|
|
// const preLastKeys = JSON.parse(JSON.stringify(lastKeys)) |
|
|
|
// preLastKeys.openKeys.push(it.itemKey) |
|
|
|
// const nextKeys = initKeys(it.items, JSON.parse(JSON.stringify(preLastKeys))) |
|
|
|
// if (nextKeys.selectedKeys.length > preLastKeys.selectedKeys.length || nextKeys.openKeys.length > preLastKeys.openKeys.length) { |
|
|
|
// return nextKeys |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// return lastKeys |
|
|
|
// return { |
|
|
|
// selectedKeys: [], |
|
|
|
// openKeys: [] |
|
|
|
// } |
|
|
|
// } |
|
|
|
setItems(nextItems) |
|
|
|
// const { selectedKeys, openKeys } = initKeys( |
|
|
|
// nextItems, |
|
|
|
// { |
|
|
|
// selectedKeys: [], |
|
|
|
// openKeys: [] |
|
|
|
// } |
|
|
|
// ) |
|
|
|
// if (selectedKeys.length || openKeys.length) { |
|
|
|
// setSelectedKeys(selectedKeys) |
|
|
|
// setOpenKeys(openKeys) |
|
|
|
// } else { |
|
|
|
// const lastSelectedKeys = localStorage.getItem('vcmp_selected_sider') |
|
|
|
// if (lastSelectedKeys) { |
|
|
|
// setSelectedKeys(JSON.parse(lastSelectedKeys)) |
|
|
|
// } |
|
|
|
// const lastOpenKeys = localStorage.getItem('vcmp_open_sider') |
|
|
|
// if (lastOpenKeys) { |
|
|
|
// setOpenKeys(JSON.parse(lastOpenKeys)) |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
scrollbar = new PerfectScrollbar('#page-slider', { suppressScrollX: true }); |
|
|
|
if (pathname == '/') { |
|
|
|
dispatch(push(homePath)) |
|
|
@ -79,11 +35,11 @@ const Sider = (props) => { |
|
|
|
else { |
|
|
|
setSelectedKeys(routeSelectedKey) |
|
|
|
} |
|
|
|
const lastOpenKeys = localStorage.getItem('vcmp_open_sider') |
|
|
|
const lastOpenKeys = localStorage.getItem('poms_open_sider') |
|
|
|
if (lastOpenKeys) { |
|
|
|
setOpenKeys(JSON.parse(lastOpenKeys)) |
|
|
|
} |
|
|
|
}, [window.localStorage.vcmp_open_sider, window.localStorage.vcmp_selected_sider, leftChange]) |
|
|
|
}, [window.localStorage.poms_open_sider, window.localStorage.poms_selected_sider, leftChange]) |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
if (scrollbar) { |
|
|
@ -102,12 +58,13 @@ const Sider = (props) => { |
|
|
|
if (selectItem.to) { |
|
|
|
dispatch(push(selectItem.to)) |
|
|
|
} |
|
|
|
let myfatherKey = selectItem.to |
|
|
|
localStorage.setItem('poms_selected_sider', JSON.stringify([myfatherKey.split('/')[1]])) |
|
|
|
setSelectedKeys(selectedKeys) |
|
|
|
localStorage.setItem('vcmp_selected_sider', JSON.stringify(selectedKeys)) |
|
|
|
}} |
|
|
|
onOpenChange={({ openKeys }) => { |
|
|
|
setOpenKeys(openKeys) |
|
|
|
localStorage.setItem('vcmp_open_sider', JSON.stringify(openKeys)) |
|
|
|
localStorage.setItem('poms_open_sider', JSON.stringify(openKeys)) |
|
|
|
}} |
|
|
|
items={items} |
|
|
|
/> |
|
|
|