diff --git a/src/components/layout/main.less b/src/components/layout/main.less index 5e4bc9e..55c8604 100644 --- a/src/components/layout/main.less +++ b/src/components/layout/main.less @@ -157,12 +157,14 @@ &.ant-menu-vertical { .ant-menu-sub { + height: 0; opacity: 0; transition: none; } .ant-menu-submenu-active { .ant-menu-sub { + height: auto; opacity: 1; } } diff --git a/src/components/layout/menu.js b/src/components/layout/menu.js index 925bdc5..ad131b4 100644 --- a/src/components/layout/menu.js +++ b/src/components/layout/menu.js @@ -4,19 +4,19 @@ import { Link } from 'dva/router' import { menu } from '../../utils' const topMenus = menu.map(item => item.key) -const getMenus = function (menuArray, siderFold, parentPath) { - parentPath = parentPath || '/' +const getMenus = function (menuArray, siderFold, parentPath = '/') { return menuArray.map(item => { + const linkTo = parentPath +item.key if (item.child) { return ( - {item.icon ? : ''}{siderFold && topMenus.indexOf(item.key) >= 0 ? '' : item.name}}> - {getMenus(item.child, siderFold, `${parentPath}${item.key}/`)} + {item.icon ? : ''}{siderFold && topMenus.indexOf(item.key) >= 0 ? '' : item.name}}> + {getMenus(item.child, siderFold, `${linkTo}/`)} ) } return ( - - + + {item.icon ? : ''} {siderFold && topMenus.indexOf(item.key) >= 0 ? '' : item.name} @@ -30,7 +30,7 @@ function Menus ({ siderFold, darkTheme, location, handleClickNavMenu, navOpenKey const getAncestorKeys = (key) => { const map = { - navigation2: ['navigation'], + '/navigation/navigation2': ['/navigation'], } return map[key] || [] } @@ -59,7 +59,7 @@ function Menus ({ siderFold, darkTheme, location, handleClickNavMenu, navOpenKey mode={siderFold ? 'vertical' : 'inline'} theme={darkTheme ? 'dark' : 'light'} onClick={handleClickNavMenu} - defaultSelectedKeys={[location.pathname.split('/')[location.pathname.split('/').length - 1] || 'dashboard']} + defaultSelectedKeys={[location.pathname !== "/" ? location.pathname : '/dashboard']} > {menuItems}