浏览代码

fix(@six/hospital-guide): 修复跳转链接重定向打开 Root页

cc12458 3 天之前
父节点
当前提交
117923e6ff
共有 2 个文件被更改,包括 7 次插入3 次删除
  1. 5 1
      apps/hospital-guide/src/router/guard.ts
  2. 2 2
      apps/hospital-guide/src/router/routes/core.ts

+ 5 - 1
apps/hospital-guide/src/router/guard.ts

@@ -104,6 +104,10 @@ function setupAccessGuard(router: Router) {
     });
     const path =
       to.path === DEFAULT_PATH ? preferences.app.defaultHomePath : to.path;
+    const redirect =
+      decodeURIComponent(<string>from.query.redirect) === DEFAULT_PATH
+        ? void 0
+        : from.query.redirect;
 
     if (!userInfo.homePath) {
       userStore.updateHomePath(
@@ -115,7 +119,7 @@ function setupAccessGuard(router: Router) {
     accessStore.setAccessMenus(accessibleMenus);
     accessStore.setAccessRoutes(accessibleRoutes);
     accessStore.setIsAccessChecked(true);
-    const redirectPath = (from.query.redirect ??
+    const redirectPath = (redirect ??
       (path === preferences.app.defaultHomePath
         ? userInfo.homePath ||
           preferences.app.defaultHomePath ||

+ 2 - 2
apps/hospital-guide/src/router/routes/core.ts

@@ -1,6 +1,6 @@
 import type { RouteRecordRaw } from 'vue-router';
 
-import { LOGIN_PATH } from '@vben/constants';
+import { DEFAULT_PATH, LOGIN_PATH } from '@vben/constants';
 import { preferences } from '@vben/preferences';
 
 import { $t } from '#/locales';
@@ -35,7 +35,7 @@ const coreRoutes: RouteRecordRaw[] = [
     },
     name: 'Root',
     path: '/',
-    redirect: preferences.app.defaultHomePath || void 0,
+    redirect: preferences.app.defaultHomePath || DEFAULT_PATH,
     children: [],
   },
   {