From fdd689daf5cf4c2083e6160d932d70e91bad46e1 Mon Sep 17 00:00:00 2001
From: BirtYu <714851131@qq.com>
Date: 星期日, 13 四月 2025 22:51:38 +0800
Subject: [PATCH] Merge pull request #59 from zhitan-cloud/jiayu1.0

---
 zhitan-vue/src/store/modules/permission.js |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/zhitan-vue/src/store/modules/permission.js b/zhitan-vue/src/store/modules/permission.js
index c9d09e6..4eb8185 100644
--- a/zhitan-vue/src/store/modules/permission.js
+++ b/zhitan-vue/src/store/modules/permission.js
@@ -56,8 +56,27 @@
   })
 
 // 閬嶅巻鍚庡彴浼犳潵鐨勮矾鐢卞瓧绗︿覆锛岃浆鎹负缁勪欢瀵硅薄
-function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
+function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false, parentRoute = null) {
   return asyncRouterMap.filter(route => {
+    // 涓嶅啀杩囨护鎺夐椤电湅鏉跨浉鍏宠矾鐢�
+    /* 
+    // 杩囨护鎺夐椤电湅鏉跨浉鍏宠矾鐢�
+    if (route.name === 'Index' && route.meta && route.meta.title === '棣栭〉鐪嬫澘') {
+      return false;
+    }
+    
+    // 濡傛灉鏄椤电湅鏉跨殑瀛愯彍鍗曪紝涔熻繃婊ゆ帀
+    if (route.path === '/index' || route.path === 'index' || 
+        (route.meta && route.meta.title === '棣栭〉鐪嬫澘')) {
+      return false;
+    }
+    */
+    
+    // 璁剧疆鐖惰矾鐢卞紩鐢�
+    if (parentRoute) {
+      route.parent = parentRoute;
+    }
+    
     if (type && route.children) {
       route.children = filterChildren(route.children)
     }
@@ -82,7 +101,8 @@
       }
     }
     if (route.children != null && route.children && route.children.length) {
-      route.children = filterAsyncRouter(route.children, route, type)
+      // 灏嗗綋鍓嶈矾鐢变綔涓虹埗璺敱浼犻�掔粰瀛愯矾鐢�
+      route.children = filterAsyncRouter(route.children, route, type, route)
     } else {
       delete route['children']
       delete route['redirect']
@@ -97,6 +117,9 @@
     if (el.children && el.children.length) {
       if (el.component === 'ParentView' && !lastRouter) {
         el.children.forEach(c => {
+          // 璁剧疆鐖惰矾鐢卞紩鐢�
+          c.parent = el;
+          
           c.path = el.path + '/' + c.path
           if (c.children && c.children.length) {
             children = children.concat(filterChildren(c.children, c))
@@ -108,6 +131,9 @@
       }
     }
     if (lastRouter) {
+      // 璁剧疆鐖惰矾鐢卞紩鐢�
+      el.parent = lastRouter;
+      
       el.path = lastRouter.path + '/' + el.path
       if (el.children && el.children.length) {
         children = children.concat(filterChildren(el.children, el))

--
Gitblit v1.9.3