|
|
@@ -17,9 +17,10 @@ import { |
|
|
patchRouteWithRemoteMenus, |
|
|
patchRouteWithRemoteMenus, |
|
|
setRemoteMenu, |
|
|
setRemoteMenu, |
|
|
} from './services/session'; |
|
|
} from './services/session'; |
|
|
|
|
|
import './styles/menu.less'; |
|
|
export { requestConfig as request } from './requestConfig'; |
|
|
export { requestConfig as request } from './requestConfig'; |
|
|
// const isDev = process.env.NODE_ENV === 'development'; |
|
|
// const isDev = process.env.NODE_ENV === 'development'; |
|
|
|
|
|
|
|
|
|
|
|
import { menuItemRender } from '@/utils/menuRender'; |
|
|
/** |
|
|
/** |
|
|
* @see https://umijs.org/zh-CN/plugins/plugin-initial-state |
|
|
* @see https://umijs.org/zh-CN/plugins/plugin-initial-state |
|
|
* */ |
|
|
* */ |
|
|
@@ -139,10 +140,8 @@ export const layout: RuntimeConfig['layout'] = ({ initialState }) => { |
|
|
onClick: () => { |
|
|
onClick: () => { |
|
|
// 点击菜单项,删除所有的页面 state 缓存 |
|
|
// 点击菜单项,删除所有的页面 state 缓存 |
|
|
removeAllPageCacheState(); |
|
|
removeAllPageCacheState(); |
|
|
|
|
|
// console.log('click menu'); |
|
|
}, |
|
|
}, |
|
|
// onSelect: (e) => { |
|
|
|
|
|
// console.log(e); |
|
|
|
|
|
// }, |
|
|
|
|
|
}, |
|
|
}, |
|
|
...initialState?.settings, |
|
|
...initialState?.settings, |
|
|
token: { |
|
|
token: { |
|
|
@@ -150,51 +149,36 @@ export const layout: RuntimeConfig['layout'] = ({ initialState }) => { |
|
|
colorTextMenu: themes['textColor'], |
|
|
colorTextMenu: themes['textColor'], |
|
|
colorTextMenuSelected: themes['primaryColor'], |
|
|
colorTextMenuSelected: themes['primaryColor'], |
|
|
colorTextMenuActive: themes['primaryColor'], |
|
|
colorTextMenuActive: themes['primaryColor'], |
|
|
|
|
|
colorTextMenuItemHover: themes['primaryColor'], |
|
|
colorBgMenuItemSelected: 'rgba(197, 232, 255, 0.8)', |
|
|
colorBgMenuItemSelected: 'rgba(197, 232, 255, 0.8)', |
|
|
colorMenuBackground: themes['siderBGColor'], |
|
|
colorMenuBackground: themes['siderBGColor'], |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
// menuItemRender: (itemProps, defaultDom, props) => { |
|
|
|
|
|
// console.log('menuItemProps', itemProps); |
|
|
|
|
|
// console.log('defaultDom', defaultDom); |
|
|
|
|
|
// console.log('props', props); |
|
|
|
|
|
|
|
|
|
|
|
// const { pathname } = window.location; |
|
|
|
|
|
// const isSelected = pathname === itemProps.path; |
|
|
|
|
|
|
|
|
|
|
|
// // 根据菜单项的状态动态显示不同的 icon |
|
|
|
|
|
// const icon = isSelected ? 'icon-developmentEnvironment-icon' : 'icon-kaifahuanjing'; |
|
|
|
|
|
// return ( |
|
|
|
|
|
// <Link to={itemProps.path || ''} target={itemProps.target}> |
|
|
|
|
|
// <KFIcon type={icon} /> |
|
|
|
|
|
// {itemProps.name} |
|
|
|
|
|
// </Link> |
|
|
|
|
|
// ); |
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
|
menuItemRender: menuItemRender(false), |
|
|
|
|
|
subMenuItemRender: menuItemRender(true), |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
export const onRouteChange: RuntimeConfig['onRouteChange'] = async (e) => { |
|
|
export const onRouteChange: RuntimeConfig['onRouteChange'] = async (e) => { |
|
|
const { location } = e; |
|
|
const { location } = e; |
|
|
const menus = getRemoteMenu(); |
|
|
const menus = getRemoteMenu(); |
|
|
console.log('onRouteChange', e); |
|
|
|
|
|
|
|
|
// console.log('onRouteChange', e); |
|
|
if (menus === null && location.pathname !== PageEnum.LOGIN) { |
|
|
if (menus === null && location.pathname !== PageEnum.LOGIN) { |
|
|
console.log('refresh'); |
|
|
|
|
|
history.go(0); |
|
|
history.go(0); |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
export const patchRoutes: RuntimeConfig['patchRoutes'] = (e) => { |
|
|
export const patchRoutes: RuntimeConfig['patchRoutes'] = (e) => { |
|
|
console.log('patchRoutes', e); |
|
|
|
|
|
|
|
|
//console.log('patchRoutes', e); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
export const patchClientRoutes: RuntimeConfig['patchClientRoutes'] = (e) => { |
|
|
export const patchClientRoutes: RuntimeConfig['patchClientRoutes'] = (e) => { |
|
|
console.log('patchClientRoutes', e); |
|
|
|
|
|
|
|
|
//console.log('patchClientRoutes', e); |
|
|
patchRouteWithRemoteMenus(e.routes); |
|
|
patchRouteWithRemoteMenus(e.routes); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
export function render(oldRender: () => void) { |
|
|
export function render(oldRender: () => void) { |
|
|
console.log('render'); |
|
|
|
|
|
|
|
|
//console.log('render'); |
|
|
const token = getAccessToken(); |
|
|
const token = getAccessToken(); |
|
|
if (!token || token?.length === 0) { |
|
|
if (!token || token?.length === 0) { |
|
|
oldRender(); |
|
|
oldRender(); |
|
|
|