From 1eba771ad9835e3923669f9d16ba95c075e9ccb0 Mon Sep 17 00:00:00 2001 From: kun <1422840143@qq.com> Date: Mon, 11 Mar 2024 18:37:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20BUG=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routers/modules/dynamicRouter.ts | 12 ++++++++---- src/views/loading/index.vue | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/routers/modules/dynamicRouter.ts b/src/routers/modules/dynamicRouter.ts index a012afe..6500f64 100644 --- a/src/routers/modules/dynamicRouter.ts +++ b/src/routers/modules/dynamicRouter.ts @@ -11,7 +11,7 @@ const modules = import.meta.glob("@/views/**/*.vue"); /** * 初始化动态路由 */ -export const initDynamicRouter = async (params?: any) => { +export const initDynamicRouter = async (params?: any, defaultUrl?: any) => { const authStore = AuthStore(); const globalStore = GlobalStore(); try { @@ -44,7 +44,7 @@ export const initDynamicRouter = async (params?: any) => { } if (item.meta.isFull) { router.addRoute(item); - if (globalStore.path) { + if (globalStore.path && !defaultUrl) { console.log("big"); router.push(globalStore.path); @@ -56,14 +56,18 @@ export const initDynamicRouter = async (params?: any) => { router.addRoute("layout", item); if (globalStore.path) { // console.log("exec"); - if (globalStore.path == item.path) { + if (globalStore.path == item.path && !defaultUrl) { router.push(globalStore.path); ++toNum; } else { - if (item.path != "/" && toNum < 1) { + if (item.path != "/" && toNum < 1 && !defaultUrl) { router.push(item.path); ++toNum; } + if (item.path != "/" && toNum < 1 && defaultUrl) { + router.push(defaultUrl); + ++toNum; + } } // globalStore.setPath(null); } else { diff --git a/src/views/loading/index.vue b/src/views/loading/index.vue index c51a0d4..e981929 100644 --- a/src/views/loading/index.vue +++ b/src/views/loading/index.vue @@ -48,7 +48,7 @@ const tokenIdentify = async () => { keepAlive.setKeepAliveName(); await sendMessage({ isSuccess: true }, 2); globalStore.setPath(data["惠州项目"][0].modulePath); - await initDynamicRouter({ moduleId: data["惠州项目"][0].moduleId }); + await initDynamicRouter({ moduleId: data["惠州项目"][0].moduleId }, route.query.routeUrl); globalStore.moduleId = data["惠州项目"][0].moduleId; // if (responseData.accountType === 2) { // await sendMessage({ isSuccess: true }, 2);