Commit cec0f45a authored by ddcat1115's avatar ddcat1115

improve SiderMenu

parent 42bfd964
...@@ -177,14 +177,17 @@ export default class SiderMenu extends PureComponent { ...@@ -177,14 +177,17 @@ export default class SiderMenu extends PureComponent {
} }
return ItemDom; return ItemDom;
}; };
handleOpenChange = (openKeys) => { isMainMenu = (key) => {
const lastOpenKey = openKeys[openKeys.length - 1]; return this.menus.some(
const isMainMenu = this.menus.some(
item => item =>
lastOpenKey && (item.key === lastOpenKey || item.path === lastOpenKey), key && (item.key === key || item.path === key),
); );
}
handleOpenChange = (openKeys) => {
const lastOpenKey = openKeys[openKeys.length - 1];
const moreThanOne = openKeys.filter(openKey => this.isMainMenu(openKey)).length > 1;
this.setState({ this.setState({
openKeys: isMainMenu ? [lastOpenKey] : [...openKeys], openKeys: moreThanOne ? [lastOpenKey] : [...openKeys],
}); });
}; };
render() { render() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment