Skip to content

Commit 9896b48

Browse files
committed
feat: redirect logged-in users to welcome page instead of login page
1 parent 43a9262 commit 9896b48

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

dashboard/src/router/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ router.beforeEach(async (to, from, next) => {
3434

3535
// 如果用户已登录且试图访问登录页面,则重定向到首页
3636
if (to.path === '/auth/login' && auth.has_token()) {
37-
return next(auth.returnUrl || '/');
37+
return next('/welcome');
3838
}
3939

4040
if (to.matched.some((record) => record.meta.requiresAuth)) {

dashboard/src/stores/auth.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export const useAuthStore = defineStore({
2525
localStorage.setItem('user', this.username);
2626
localStorage.setItem('token', res.data.data.token);
2727
localStorage.setItem('change_pwd_hint', res.data.data?.change_pwd_hint);
28-
router.push(this.returnUrl || '/dashboard/default');
28+
this.returnUrl = null;
29+
router.push('/welcome');
2930
} catch (error) {
3031
return Promise.reject(error);
3132
}

dashboard/src/views/authentication/auth/LoginPage.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function toggleTheme() {
2525
onMounted(() => {
2626
// 检查用户是否已登录,如果已登录则重定向
2727
if (authStore.has_token()) {
28-
router.push(authStore.returnUrl || '/');
28+
router.push('/welcome');
2929
return;
3030
}
3131

0 commit comments

Comments
 (0)