fixed: 首次进入没有名称.
This commit is contained in:
@@ -1,15 +1,28 @@
|
||||
import { RouteLocationNormalized, RouteRecordRaw } from 'vue-router';
|
||||
import { useUserStore } from '@/store';
|
||||
import { RouteLocationNormalized, RouteRecordNormalized, RouteRecordRaw } from 'vue-router';
|
||||
import { useAppStore, useUserStore } from '@/store';
|
||||
import { WHITE_ROUTER_LIST } from '@/router/constants';
|
||||
|
||||
export default function usePermission() {
|
||||
const appStore = useAppStore();
|
||||
const userStore = useUserStore();
|
||||
return {
|
||||
/**
|
||||
* 是否可访问路由
|
||||
*/
|
||||
accessRouter(route: RouteLocationNormalized | RouteRecordRaw) {
|
||||
// route.name
|
||||
// TODO
|
||||
// 检查路由是否存在于授权路由中
|
||||
const menuConfig = [...appStore.appAsyncMenus, ...WHITE_ROUTER_LIST];
|
||||
let exist = false;
|
||||
while (menuConfig.length && !exist) {
|
||||
const element = menuConfig.shift();
|
||||
if (element?.name === route.name) exist = true;
|
||||
if (element?.children) {
|
||||
menuConfig.push(
|
||||
...(element.children as unknown as RouteRecordNormalized[])
|
||||
);
|
||||
}
|
||||
}
|
||||
return exist;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user