feat: redirect logged-in users to welcome page instead of login page

This commit is contained in:
Soulter
2026-03-29 20:53:16 +08:00
parent 43a9262719
commit 9896b48c5e
3 changed files with 4 additions and 3 deletions

View File

@@ -34,7 +34,7 @@ router.beforeEach(async (to, from, next) => {
// 如果用户已登录且试图访问登录页面,则重定向到首页
if (to.path === '/auth/login' && auth.has_token()) {
return next(auth.returnUrl || '/');
return next('/welcome');
}
if (to.matched.some((record) => record.meta.requiresAuth)) {

View File

@@ -25,7 +25,8 @@ export const useAuthStore = defineStore({
localStorage.setItem('user', this.username);
localStorage.setItem('token', res.data.data.token);
localStorage.setItem('change_pwd_hint', res.data.data?.change_pwd_hint);
router.push(this.returnUrl || '/dashboard/default');
this.returnUrl = null;
router.push('/welcome');
} catch (error) {
return Promise.reject(error);
}

View File

@@ -25,7 +25,7 @@ function toggleTheme() {
onMounted(() => {
// 检查用户是否已登录,如果已登录则重定向
if (authStore.has_token()) {
router.push(authStore.returnUrl || '/');
router.push('/welcome');
return;
}