perf: 已登录状态访问登录页面自动跳转到首页

This commit is contained in:
xiaojunnuo
2026-02-09 23:08:13 +08:00
parent 519bf3184a
commit bd8caff0b7
2 changed files with 9 additions and 5 deletions
@@ -101,6 +101,14 @@ function setupAccessGuard(router: Router) {
return r.meta?.auth || r.meta?.permission;
});
if (to.path === LOGIN_PATH && accessStore.accessToken) {
return {
path: DEFAULT_HOME_PATH,
// 携带当前跳转的页面,登录后重新跳转该页面
replace: true,
};
}
if (!needAuth) {
return true;
}
@@ -113,12 +113,7 @@ export default defineComponent({
setup() {
const { t } = useI18n();
const route = useRoute();
const router = useRouter();
const userStore = useUserStore();
if (userStore.getToken) {
router.push("/");
return;
}
const queryBindCode = ref(route.query.bindCode as string | undefined);
@@ -256,6 +251,7 @@ export default defineComponent({
}
return sysPublicSettings.oauthOnly && settingStore.isPlus && sysPublicSettings.oauthEnabled;
});
return {
t,
loading,