ant-design / ant-design-pro-layout

🌃 Powerful and easy to use beautiful layout
https://prolayout.ant.design/
MIT License
1k stars 239 forks source link

🐛[BUG] menuDataRender采用后台获取左侧菜单,第一次进入以及刷新页面,选中菜单未高亮 #587

Open mrhsiang opened 3 years ago

mrhsiang commented 3 years ago

🐛 bug 描述 [详细地描述 bug,让大家都能理解]

menuDataRender采用后台获取左侧菜单,第一次进入以及刷新页面,选中菜单未高亮 当采用config中配置的,页面一切正常,只有在后台动态返回的情况会出现菜单未高亮的情况

📷 复现步骤 [清晰描述复现步骤,让别人也能看到问题]

启动项目,页面进入时,默认选中路由 ‘/’,重定向至 ‘Welcome’, 但左侧菜单未高亮显示;对菜单某一个项点击选中时,此时出现高亮,接着在该高亮页面进行浏览器刷新操作,左侧菜单无法高亮,并且所有菜单折叠收起。

🏞 期望结果 [描述你原本期望看到的结果]

高亮正常

💻 复现代码 [提供可复现的代码,仓库,或线上示例]

BasicLayout: `/**

import DefaultFooterDom from './Footer'; import logo from '../assets/logo.svg';

const noMatch = ( <Result status={403} title="403" subTitle="Sorry, you are not authorized to access this page." extra={

}

/> );

/**

const BasicLayout = props => { const { dispatch, children, settings, menuData, location = { pathname: '/', }, } = props;

// 获取menu useEffect(() => { if (dispatch) { dispatch({ type: 'menu/fetchMenuList', }); } }, []);

/**

export default connect(({ global, settings, menu }) => ({ collapsed: global.collapsed, settings, menuData: menu.menuData }))(BasicLayout); `

menu后台返回数据结构: { message: { code: 200, level: 'normal', message: 'sucsess', }, data: [ { path: '/first', name: '一级菜单A', icon: 'smile', }, { path: '/second', name: '一级菜单B', icon: 'smile', authority: ['user'], children: [ { path: '/second/sub', name: '二级菜单B-1', }, ], }, { path: '/forth', name: '一级菜单D', icon: 'smile', authority: ['user', 'admin'], children: [ { path: '/forth/forth-sub-1', name: '二级菜单D-1', children: [ { path: '/forth/forth-sub-1/forth-sub-sub56757', name: '三级菜单D-1-1', }, ], }, ], }, { path: '/admin', name: 'admin', icon: 'smile', authority: ['admin'], children: [ { path: '/admin/sub-page', name: 'sub-page', authority: ['admin'], }, ], }, { name: 'list.table-list', path: '/list', icon: 'smile', }, ] }); }

© 版本信息

🚑 其他信息 [如截图等其他信息可以贴在这里]

johnnylc commented 3 years ago

580