From 333ae7d55d90ee4798a6c575bc734421e46ed01d Mon Sep 17 00:00:00 2001
From: 张诺 <zhang_12370@163.com>
Date: 星期一, 20 四月 2026 16:16:37 +0800
Subject: [PATCH] 修正new的路由配置文件
---
src/store/modules/permission.js | 36 +++++++++++-------------------------
1 files changed, 11 insertions(+), 25 deletions(-)
diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js
index 8a2b1a9..f7a7044 100644
--- a/src/store/modules/permission.js
+++ b/src/store/modules/permission.js
@@ -45,6 +45,7 @@
const asyncRoutes = filterDynamicRoutes(dynamicRoutes)
asyncRoutes.forEach(route => { router.addRoute(route) })
this.setRoutes(rewriteRoutes)
+ // 灏嗚储鍔$鐞嗚矾鐢卞悎骞跺埌渚ц竟鏍�
this.setSidebarRouters(constantRoutes.concat(sidebarRoutes))
this.setDefaultRoutes(sidebarRoutes)
this.setTopbarRoutes(defaultRoutes)
@@ -85,28 +86,13 @@
function filterChildren(childrenMap, lastRouter = false) {
var children = []
- childrenMap.forEach((el, index) => {
- if (el.children && el.children.length) {
- if (el.component === 'ParentView' && !lastRouter) {
- el.children.forEach(c => {
- c.path = el.path + '/' + c.path
- if (c.children && c.children.length) {
- children = children.concat(filterChildren(c.children, c))
- return
- }
- children.push(c)
- })
- return
- }
+ childrenMap.forEach(el => {
+ el.path = lastRouter ? lastRouter.path + '/' + el.path : el.path
+ if (el.children && el.children.length && el.component === 'ParentView') {
+ children = children.concat(filterChildren(el.children, el))
+ } else {
+ children.push(el)
}
- if (lastRouter) {
- el.path = lastRouter.path + '/' + el.path
- if (el.children && el.children.length) {
- children = children.concat(filterChildren(el.children, el))
- return
- }
- }
- children = children.concat(el)
})
return children
}
@@ -129,14 +115,14 @@
}
export const loadView = (view) => {
- let res;
+ let res
for (const path in modules) {
- const dir = path.split('views/')[1].split('.vue')[0];
+ const dir = path.split('views/')[1].split('.vue')[0]
if (dir === view) {
- res = () => modules[path]();
+ res = () => modules[path]()
}
}
- return res;
+ return res
}
export default usePermissionStore
--
Gitblit v1.9.3