SyuanYu 2 месяцев назад
Родитель
Сommit
7d76971d4a
1 измененных файлов с 11 добавлено и 1 удалено
  1. 11 1
      frontend/src/stores/main.ts

+ 11 - 1
frontend/src/stores/main.ts

@@ -168,7 +168,17 @@ export const useMainStore = defineStore("MainStoreId", {
             const response = await api.getMe(token);
             this.setLoggedIn(true);
             this.setUserProfile(response.data);
-            router.push("/main/dashboard");
+            // router.push("/main/dashboard");
+
+            // 取得網址路徑
+            const currentPath = window.location.pathname;
+
+            if (currentPath === "/login") {
+              router.push("/main/dashboard");
+            } else {
+              // 跳轉至目前路徑
+              router.push(currentPath);
+            }
           } catch (error) {
             await this.removeLogIn();
           }