From 620222f59c209ecd70be3e9cc94a7e7475237cfb Mon Sep 17 00:00:00 2001 From: tinyu Date: Thu, 28 Mar 2024 11:42:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=AE=BE=E7=BD=AE=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E6=8E=A7=E5=88=B6route?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/layout/index.vue | 8 ++++---- src/utils/modules/routeUtils.js | 13 ++++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/layout/index.vue b/src/components/layout/index.vue index 5ca4f11..3a14ba9 100644 --- a/src/components/layout/index.vue +++ b/src/components/layout/index.vue @@ -2,13 +2,13 @@ + background-color="#545c64" text-color="#fff" router active-text-color="#ffd04b"> 消息中心 diff --git a/src/utils/modules/routeUtils.js b/src/utils/modules/routeUtils.js index 60d92e1..64bac93 100644 --- a/src/utils/modules/routeUtils.js +++ b/src/utils/modules/routeUtils.js @@ -4,13 +4,16 @@ * @param {Function} processFn 处理函数 * @returns {Array} 数组数据 */ -export function coventRouteData(list, processFn) { +export function coventRouteData(list, processFn, Parentpath="/") { return list.map(item => { - let { children, component, ...rest } = item; + let { children, path, component, ...rest } = item; + if(!path.startsWith('/')){ + path = Parentpath+path + } if (children && Array.isArray(children)) { - children = coventRouteData(children, processFn) - return processFn({ children, ...rest }) + children = coventRouteData(children, processFn, `${path}/`) + return processFn({ children, path, ...rest }) } - return processFn(rest) + return processFn({path, ...rest}) }); } -- GitLab