mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
feat: redirect logged-in users to welcome page instead of login page
This commit is contained in:
@@ -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)) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ function toggleTheme() {
|
||||
onMounted(() => {
|
||||
// 检查用户是否已登录,如果已登录则重定向
|
||||
if (authStore.has_token()) {
|
||||
router.push(authStore.returnUrl || '/');
|
||||
router.push('/welcome');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user