|
|
@ -4,6 +4,7 @@ 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 { getTenantId } from '@/utils/auth' |
|
|
|
|
|
|
|
const { wsCache } = useCache() |
|
|
|
|
|
|
@ -33,11 +34,19 @@ export const usePermissionStore = defineStore('permission', { |
|
|
|
actions: { |
|
|
|
async generateRoutes(): Promise<unknown> { |
|
|
|
return new Promise<void>(async (resolve) => { |
|
|
|
let names =[{"text":"长春1379","value":1},{"text":"成都1397","value":2},{"text":"长春2379","value":3}] |
|
|
|
let tenant = names.find(item=>item.value == getTenantId()) |
|
|
|
// 获得菜单列表,它在登录的时候,setUserInfoAction 方法中已经进行获取
|
|
|
|
let res: AppCustomRouteRecordRaw[] = [] |
|
|
|
if (wsCache.get(CACHE_KEY.ROLE_ROUTERS)) { |
|
|
|
res = wsCache.get(CACHE_KEY.ROLE_ROUTERS) as AppCustomRouteRecordRaw[] |
|
|
|
res.forEach(item=>{ |
|
|
|
if(item.name == '富维海拉供应商系统'&&tenant){ |
|
|
|
item.name = item.name + tenant['text'] |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
console.log('菜单res',res) |
|
|
|
const routerMap: AppRouteRecordRaw[] = generateRoute(res) |
|
|
|
// 动态路由,404一定要放到最后面
|
|
|
|
this.addRouters = routerMap.concat([ |
|
|
|