瀏覽代碼

refactor: 将跳转放到最后

eric 5 月之前
父節點
當前提交
1cb53e943e
共有 1 個文件被更改,包括 10 次插入10 次删除
  1. 10 10
      playground/src/store/auth.ts

+ 10 - 10
playground/src/store/auth.ts

@@ -89,21 +89,21 @@ export const useAuthStore = defineStore('auth', () => {
 
       resetAllStores();
       accessStore.setLoginExpired(false);
-
-      // 回登录页带上当前路由地址
-      await router.replace({
-        path: LOGIN_PATH,
-        query: redirect
-          ? {
-              redirect: encodeURIComponent(router.currentRoute.value.fullPath),
-            }
-          : {},
-      });
     } catch {
       // 不做任何处理
     } finally {
       isLoggingOut.value = false; // 重置 标识
     }
+
+    // 回登录页带上当前路由地址
+    await router.replace({
+      path: LOGIN_PATH,
+      query: redirect
+        ? {
+            redirect: encodeURIComponent(router.currentRoute.value.fullPath),
+          }
+        : {},
+    });
   }
 
   async function fetchUserInfo() {