Przeglądaj źródła

build: :sparkles: 登录跳转调整

chaooo 2 lat temu
rodzic
commit
3554e3baa0

+ 6 - 3
src/layout/components/Navbar/UserInfo.vue

@@ -23,7 +23,7 @@ function logout() {
         tagsViewStore.delAllViews();
       })
       .then(() => {
-        router.push(`/login?redirect=${route.fullPath}`);
+        router.push("/login?redirect=/");
       });
   });
 }
@@ -46,20 +46,23 @@ function logout() {
   justify-items: center;
   margin: 0 20px 0 0;
   cursor: pointer;
+
   img {
     width: 40px;
     height: 40px;
     line-height: 40px;
     text-align: center;
-    border-radius: 20px;
     background: #494949;
+    border-radius: 20px;
   }
+
   span {
     margin-left: 12px;
     font-size: 16px;
     color: #494949;
+
     &.spl {
-      margin: 0 12px 0 12px;
+      margin: 0 12px;
       color: #d7d8d8;
     }
   }

+ 2 - 2
src/permission.ts

@@ -36,7 +36,7 @@ router.beforeEach(async (to, from, next) => {
         } catch (error) {
           // 移除 token 并跳转登录页
           await userStore.resetToken();
-          next(`/login?redirect=${to.path}`);
+          next("/login?redirect=/");
           NProgress.done();
         }
       } else {
@@ -50,7 +50,7 @@ router.beforeEach(async (to, from, next) => {
     if (whiteList.indexOf(to.path) !== -1) {
       next();
     } else {
-      next(`/login?redirect=${to.path}`);
+      next("/login?redirect=/");
       NProgress.done();
     }
   }

+ 2 - 0
src/store/modules/user.ts

@@ -4,6 +4,8 @@ import { resetRouter } from "@/router";
 import { store } from "@/store";
 import { useStorage } from "@vueuse/core";
 import { LoginData, LoginResult } from "@/api/auth/types";
+import { useRouter } from "vue-router";
+const router = useRouter();
 
 export const useUserStore = defineStore("user", () => {
   // state