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);