From 4745c48798fc7d967a7fd4416c10050d4f79fb98 Mon Sep 17 00:00:00 2001
From: birt <2499248221@qq.com>
Date: 星期日, 13 四月 2025 21:43:49 +0800
Subject: [PATCH] 123

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

diff --git a/zhitan-vue/src/store/modules/permission.js b/zhitan-vue/src/store/modules/permission.js
index c9d09e6..ca7e5a2 100644
--- a/zhitan-vue/src/store/modules/permission.js
+++ b/zhitan-vue/src/store/modules/permission.js
@@ -56,8 +56,13 @@
   })
 
 // 閬嶅巻鍚庡彴浼犳潵鐨勮矾鐢卞瓧绗︿覆锛岃浆鎹负缁勪欢瀵硅薄
-function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
+function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false, parentRoute = null) {
   return asyncRouterMap.filter(route => {
+    // 璁剧疆鐖惰矾鐢卞紩鐢�
+    if (parentRoute) {
+      route.parent = parentRoute;
+    }
+    
     if (type && route.children) {
       route.children = filterChildren(route.children)
     }
@@ -82,7 +87,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 +103,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 +117,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