Commit f41ea1d2 authored by 前端-许佳敏's avatar 前端-许佳敏

feat: 可自由组合pass平台菜单

parent f0962dda
......@@ -12,7 +12,7 @@
"api": "god-ytt",
"scripts:build": "node scripts/run",
"scripts:build-yxc": "node scripts/run http://yxc-web-demo.shushangyun.com/api",
"start:dev": "umi dev ",
"start:dev": "cross-env NODE_OPTIONS=--max_old_space_size=4096 umi dev",
"start:analyze": "ANALYZE=1 umi dev",
"clean": "rimraf node_modules",
"start": "yarn api && yarn scripts:build && cross-env NODE_OPTIONS=--max_old_space_size=4096 umi dev",
......
......@@ -152,7 +152,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
minWidth: '1280px'
}
: {}
console.log(currentRouter)
return currentRouter.noLayout ? props.children : (
<ProLayout
pageTitleRender={() => currentRouter ? currentRouter.name : window.location.href}
......@@ -179,6 +179,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
menuData={menuData}
pathname={location.pathname}
collapseState={collapsed}
currentRouter={currentRouter}
changeOpenKeys={(keys: string[]) => setOpenKeys(keys)}
/>}
footerRender={() => defaultFooterDom}
......
......@@ -20,6 +20,7 @@ export interface MenuSliderProps {
currentSelectKey: string[];
openKeys: string[];
changeOpenKeys: Function;
currentRouter: any;
}
const MenuSlider: React.FC<MenuSliderProps> = (props) => {
......
......@@ -13,12 +13,13 @@ const { Sider } = Layout
export interface OuterSiderProps {
menuData: Array<any>;
pathname: string | undefined;
UserStore?: any
currentRouter: any,
UserStore?: any,
}
const OuterSider: React.FC<OuterSiderProps> = observer((props) => {
const { menuData, pathname = "/" } = props
const { menuData, pathname = "/", currentRouter } = props
const authRouters = getRouters()
let defaultSelectedKeys = ""
......@@ -33,14 +34,19 @@ const OuterSider: React.FC<OuterSiderProps> = observer((props) => {
const getSubMenu = () => {
const subHeadMenus: Array<any> = []
menuData.forEach(item => {
if (pathname.indexOf(item.key) > -1) {
defaultSelectedKeys = item.key
// 为适配pass菜单自由组合变更, 使用code进行高亮显示
const code = currentRouter.relationParentCode
console.log(code, item.relationParentCode)
if (code && code === item.relationParentCode) {
defaultSelectedKeys = item.relationParentCode
}
!item.hideInMenu && isAuthPath(item.path) && subHeadMenus.push({
path: item.path,
title: item.name,
icon: item.icon,
key: item.key
key: item.key,
// 新增code属性 用于辨别子菜单是否属于该菜单下的属性
relationParentCode: item.relationParentCode,
})
})
return subHeadMenus
......@@ -60,7 +66,7 @@ const OuterSider: React.FC<OuterSiderProps> = observer((props) => {
<ul className={styles.menuBox}>
{
siderMenu.map(item => (
!item.hideInMenu && <li key={item.key} className={defaultSelectedKeys === item.key ? styles.currentItem : ''}>
!item.hideInMenu && <li key={item.key} className={defaultSelectedKeys === item.relationParentCode ? styles.currentItem : ''}>
<Link to={item.path}>
<CustomIcon type={item.icon} style={{width: 20, height: 20}}/>
<label>{item.title}</label>
......
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