Browse Source

update router

SyuanYu 2 tháng trước cách đây
mục cha
commit
7d76971d4a
1 tập tin đã thay đổi với 11 bổ sung1 xóa
  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();
           }