From c4b49d08cef0805e17646eef03e1c1a62316c3b2 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期六, 05 十一月 2022 10:41:52 +0800
Subject: [PATCH] 1.产能规划优化
---
src/store/modules/permission.js | 28 ++++++++++++++++++----------
1 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js
index 2b74277..216c241 100644
--- a/src/store/modules/permission.js
+++ b/src/store/modules/permission.js
@@ -13,28 +13,37 @@
/**
* 鎶婂悗鍙拌繑鍥炶彍鍗曠粍瑁呮垚routes瑕佹眰鐨勬牸寮�
* @param {*} routes
+ * @param {*} menu
*/
-export function getAsyncRoutes(routes2, menu) {
+export function getAsyncRoutes(routes, menu) {
+ // menu 涓璮lag "0" 琛ㄧず true "1"琛ㄧずfalse
const menuCode = []// 灏嗗悗绔痗ode鍙栧嚭瀛樻垚鏁扮粍褰㈠紡
+ const menuNameAndCode = []// 灏嗗悗绔痗ode涓巒ame鍙栧嚭瀛樻垚鏁扮粍褰㈠紡
menu.forEach(item => {
- menuCode.push(item.code)
- if (item.children && item.children.length > 0) {
- item.children.forEach(it => {
- menuCode.push(it.code)
- })
+ if (item.flag === '0') {
+ menuCode.push(item.code)
+ menuNameAndCode.push({ code: item.code, name: item.name })
+ if (item.children && item.children.length > 0) {
+ item.children.forEach(it => {
+ if (it.flag === '0') {
+ menuCode.push(it.code)
+ menuNameAndCode.push({ code: it.code, name: it.name })
+ }
+ })
+ }
}
})
- const routes = routes2
- const newRoutes = []
+ const newRoutes = [] // 鏂拌矾鐢�
routes.forEach(item => {
if (menuCode.includes(item.code) && item.children && item.children.length > 0) {
- console.log(item)
+ item.meta.title = menuNameAndCode.find(item2 => item2.code === item.code).name
const children = []
let flag = false// 鍒ゆ柇鏄惁鏈塩hildren瀛樿繘鍘�
item.children.forEach(it => {
if (menuCode.includes(it.code)) {
+ it.meta.title = menuNameAndCode.find(item2 => item2.code === it.code).name
children.push(it)
flag = true
}
@@ -90,7 +99,6 @@
generateRoutes({ commit }, menu) {
return new Promise(resolve => {
const newRoutes = getAsyncRoutes(asyncRoutes, menu)
- console.log(newRoutes, 2)
commit('SET_ROUTES', newRoutes)
resolve(newRoutes)
})
--
Gitblit v1.9.3