From 065523c0aabdc706bbf93ad1c9a9a8a668381f39 Mon Sep 17 00:00:00 2001 From: zhangqihang Date: Mon, 5 Feb 2024 14:18:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/addRouters.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/addRouters.js b/src/addRouters.js index edf19ca..8637921 100644 --- a/src/addRouters.js +++ b/src/addRouters.js @@ -6,7 +6,7 @@ import { cloneDeep } from "lodash-es"; import pinia from "./pinia"; import children from "@/components/children/index"; import { MODEL } from "@/assets/js/constant"; -import asyncRouter from "@/assets/js/asyncRouter"; +// import asyncRouter from "@/assets/js/asyncRouter"; import { getAsyncRouter } from "@/request/api"; // import { getRouteTreeAll } from "@/request/system_management.js"; @@ -30,10 +30,10 @@ router.beforeEach(async (to, from, next) => { // 变量里没有储存路由 // pinia里没有储存路由,去后台获取路由 if (routerStore.getRouters.length === 0) { - await getAsyncRouter(); + const resData = await getAsyncRouter(); // const resData = await getRouteTreeAll(); - // storageRouter = resData.menuList; // 后台请求得到的路由数据 - storageRouter = asyncRouter; // 死路由 + storageRouter = resData.routeList; // 后台请求得到的路由数据 + // storageRouter = asyncRouter; // 死路由 routerStore.setRouters(storageRouter); // 存储路由 routerGo(to, next); // 执行路由跳转方法 } else { @@ -76,6 +76,7 @@ function routerGo(to, next) { function filterAsyncRouter(asyncRouterMap) { // 遍历后台传来的路由字符串,转换为组件对象 return asyncRouterMap.filter((route) => { + route.meta = JSON.parse(route.meta); if (route.component) { if (route.component === "children") { route.component = children;