weixin_52219567 1 день назад
Родитель
Сommit
2af8097f7d
1 измененных файлов с 11 добавлено и 3 удалено
  1. 11 3
      src/layout/components/workbench.vue

+ 11 - 3
src/layout/components/workbench.vue

@@ -52,7 +52,8 @@
             <div class="popover-bos">
               <div class="popover-title">{{ item1.title }}</div>
               <template v-for="(item2, index2) in item1.children" :key="index2">
-                <div class="popover-list" :class="{ 'popover-hig': activeMenu == item2.path }" @click="onPath(item2.path)">
+                <div class="popover-list" :class="{ 'popover-hig': activeMenu == item2.path }"
+                  @click="onPath(item2.path)">
                   {{ item2.title }}
                 </div>
               </template>
@@ -98,6 +99,7 @@ interface MenuItem {
 }
 
 // 注意:这里定义的是完整的全量菜单结构,后续会根据权限动态修改 children 和 show
+const menuLists = ref<any>([]);
 const menuList = ref<MenuItem[]>([
   {
     path: '/enterprise',
@@ -243,8 +245,8 @@ const processMenuPermissions = (apiMenuList: any[]) => {
 const checkCurrentRoutePermission = () => {
   const currentPath = route.path;
   const publicPaths = ['/', '/login', '/404'];
-  if (!publicPaths.includes(currentPath) && !allowedPaths.value.has(currentPath)) {
-    router.push('/');
+  if (!publicPaths.includes(currentPath) && !allowedPaths.value.has(currentPath) && menuLists.value.includes(currentPath)) {
+    onPath('/');
   }
 };
 
@@ -256,6 +258,12 @@ onMounted(() => {
   }
   window.addEventListener('resize', handleResize);
 
+  menuList.value.forEach((item1: any) => {
+    item1.children.forEach((item2: any) => {
+      menuLists.value.push(item2.path);
+    });
+  });
+
   getInfo().then((res1) => {
     if (res1.code == 200) {
       userInfo.value = res1.data;