| | |
| | | import { cloneDeep } from 'lodash-es' |
| | | import remainingRouter from '@/router/modules/remaining' |
| | | import { flatMultiLevelRoutes, generateRoute } from '@/utils/routerHelper' |
| | | import { CACHE_KEY, useCache } from '@/hooks/web/useCache' |
| | | import {CACHE_KEY, useSessionCache} from '@/hooks/web/useCache' |
| | | |
| | | const { wsCache } = useCache() |
| | | const { wsSessionCache } = useSessionCache() |
| | | |
| | | export interface PermissionState { |
| | | routers: AppRouteRecordRaw[] |
| | |
| | | return new Promise<void>(async (resolve) => { |
| | | // 获得菜单列表,它在登录的时候,setUserInfoAction 方法中已经进行获取 |
| | | let res: AppCustomRouteRecordRaw[] = [] |
| | | if (wsCache.get(CACHE_KEY.ROLE_ROUTERS)) { |
| | | res = wsCache.get(CACHE_KEY.ROLE_ROUTERS) as AppCustomRouteRecordRaw[] |
| | | if (wsSessionCache.get(CACHE_KEY.ROLE_ROUTERS)) { |
| | | res = wsSessionCache.get(CACHE_KEY.ROLE_ROUTERS) as AppCustomRouteRecordRaw[] |
| | | } |
| | | const routerMap: AppRouteRecordRaw[] = generateRoute(res) |
| | | // 动态路由,404一定要放到最后面 |