mirror of
https://github.com/zuiidea/antd-admin
synced 2026-10-21 15:04:26 +00:00
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 (
|
||||
<Menu.SubMenu key={item.key} title={<span>{item.icon ? <Icon type={item.icon} /> : ''}{siderFold && topMenus.indexOf(item.key) >= 0 ? '' : item.name}</span>}>
|
||||
{getMenus(item.child, siderFold, `${parentPath}${item.key}/`)}
|
||||
<Menu.SubMenu key={linkTo} title={<span>{item.icon ? <Icon type={item.icon} /> : ''}{siderFold && topMenus.indexOf(item.key) >= 0 ? '' : item.name}</span>}>
|
||||
{getMenus(item.child, siderFold, `${linkTo}/`)}
|
||||
</Menu.SubMenu>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<Menu.Item key={item.key}>
|
||||
<Link to={parentPath + item.key}>
|
||||
<Menu.Item key={linkTo}>
|
||||
<Link to={linkTo}>
|
||||
{item.icon ? <Icon type={item.icon} /> : ''}
|
||||
{siderFold && topMenus.indexOf(item.key) >= 0 ? '' : item.name}
|
||||
</Link>
|
||||
@@ -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}
|
||||
</Menu>
|
||||
|
||||
Reference in New Issue
Block a user