From acd82e817644e75fb61088d3dfb937859d7f3819 Mon Sep 17 00:00:00 2001
From: yinbangzhong <zhongbangyin@126.com>
Date: 星期三, 07 八月 2024 16:27:15 +0800
Subject: [PATCH] 登录跳转权限配置页面

---
 src/router/guard/userLoginInfo.ts |   62 +++++++++++++++---------------
 1 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/src/router/guard/userLoginInfo.ts b/src/router/guard/userLoginInfo.ts
index 876976d..8facaf8 100644
--- a/src/router/guard/userLoginInfo.ts
+++ b/src/router/guard/userLoginInfo.ts
@@ -9,36 +9,36 @@
     NProgress.start();
     const userStore = useUserStore();
     next();
-    // if (isLogin()) {
-    //   if (userStore.role) {
-    //     next();
-    //   } else {
-    //     try {
-    //       await userStore.info();
-    //       next();
-    //     } catch (error) {
-    //       await userStore.logout();
-    //       next({
-    //         name: 'login',
-    //         query: {
-    //           redirect: to.name,
-    //           ...to.query,
-    //         } as LocationQueryRaw,
-    //       });
-    //     }
-    //   }
-    // } else {
-    //   if (to.name === 'login') {
-    //     next();
-    //     return;
-    //   }
-    //   next({
-    //     name: 'login',
-    //     query: {
-    //       redirect: to.name,
-    //       ...to.query,
-    //     } as LocationQueryRaw,
-    //   });
-    // }
+    if (isLogin()) {
+      if (userStore.role) {
+        next();
+      } else {
+        try {
+          await userStore.info();
+          next();
+        } catch (error) {
+          await userStore.logout();
+          next({
+            name: 'login',
+            query: {
+              redirect: to.name,
+              ...to.query,
+            } as LocationQueryRaw,
+          });
+        }
+      }
+    } else {
+      if (to.name === 'login') {
+        next();
+        return;
+      }
+      next({
+        name: 'login',
+        query: {
+          redirect: to.name,
+          ...to.query,
+        } as LocationQueryRaw,
+      });
+    }
   });
 }

--
Gitblit v1.8.0