From c1178027f0fab2791d02efcd7c52beff5fc7dc25 Mon Sep 17 00:00:00 2001
From: 无木 <netfan@foxmail.com>
Date: Thu, 15 Jul 2021 17:15:15 +0800
Subject: [PATCH] fix: fix homePage affix error

---
 src/router/routes/modules/about.ts |  2 +-
 src/store/modules/permission.ts    | 12 ++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/router/routes/modules/about.ts b/src/router/routes/modules/about.ts
index 31b0c06..d32c4f5 100644
--- a/src/router/routes/modules/about.ts
+++ b/src/router/routes/modules/about.ts
@@ -22,7 +22,7 @@ const dashboard: AppRouteModule = {
       meta: {
         title: t('routes.dashboard.about'),
         icon: 'simple-icons:about-dot-me',
-        // hideMenu: true,
+        hideMenu: true,
       },
     },
   ],
diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts
index a365f56..4e1cba0 100644
--- a/src/store/modules/permission.ts
+++ b/src/store/modules/permission.ts
@@ -123,15 +123,19 @@ export const usePermissionStore = defineStore({
        * */
       const patchHomeAffix = (routes: AppRouteRecordRaw[]) => {
         if (!routes || routes.length === 0) return;
-        const homePath = userStore.getUserInfo.homePath || PageEnum.BASE_HOME;
+        let homePath: string = userStore.getUserInfo.homePath || PageEnum.BASE_HOME;
         function patcher(routes: AppRouteRecordRaw[], parentPath = '') {
           if (parentPath) parentPath = parentPath + '/';
           routes.forEach((route: AppRouteRecordRaw) => {
-            const { path, children } = route;
+            const { path, children, redirect } = route;
             const currentPath = path.startsWith('/') ? path : parentPath + path;
             if (currentPath === homePath) {
-              route.meta = Object.assign({}, route.meta, { affix: true });
-              throw new Error('end');
+              if (redirect) {
+                homePath = route.redirect! as string;
+              } else {
+                route.meta = Object.assign({}, route.meta, { affix: true });
+                throw new Error('end');
+              }
             }
             children && children.length > 0 && patcher(children, currentPath);
           });
--
libgit2 0.23.3