Commit cec0f45a authored by ddcat1115's avatar ddcat1115

improve SiderMenu

parent 42bfd964
......@@ -177,14 +177,17 @@ export default class SiderMenu extends PureComponent {
}
return ItemDom;
};
handleOpenChange = (openKeys) => {
const lastOpenKey = openKeys[openKeys.length - 1];
const isMainMenu = this.menus.some(
isMainMenu = (key) => {
return this.menus.some(
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({
openKeys: isMainMenu ? [lastOpenKey] : [...openKeys],
openKeys: moreThanOne ? [lastOpenKey] : [...openKeys],
});
};
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