improve(login):优化登录页状态判断
This commit is contained in:
1 parent
798aa64918
commit
4a9fe1a5da
4 files changed
+34
-2
No files matched your search
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed } from 'vue'
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import type { FormInstance } from '@arco-design/web-vue'
|
||||
@@ -98,6 +98,16 @@ async function acceptAgreements() {
|
||||
}
|
||||
}
|
||||
|
||||
// Check if already logged in on mount
|
||||
import { onMounted } from 'vue'
|
||||
|
||||
onMounted(() => {
|
||||
// If already logged in, redirect to dashboard
|
||||
if (authStore.isLoggedIn) {
|
||||
const redirect = (route.query.redirect as string) || '/admin'
|
||||
router.replace(redirect)
|
||||
}
|
||||
})
|
||||
async function handleLogin() {
|
||||
try {
|
||||
const errors = await formRef.value?.validate()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useTenantAuthStore } from '@/stores/tenant-auth'
|
||||
import AuthLayout from '@/components/layout/AuthLayout.vue'
|
||||
import Icon from '@/components/common/Icon.vue'
|
||||
import SlideCaptcha from '@/components/common/SlideCaptcha.vue'
|
||||
@@ -8,6 +9,7 @@ import PasswordStrengthMeter from '@/components/common/PasswordStrengthMeter.vue
|
||||
import request, { extractApiError } from '@/utils/request'
|
||||
|
||||
const router = useRouter()
|
||||
const authStore = useTenantAuthStore()
|
||||
|
||||
const step = ref<1 | 2>(1)
|
||||
const loading = ref(false)
|
||||
@@ -42,6 +44,13 @@ function clearErrors() {
|
||||
Object.keys(errors).forEach((k) => delete errors[k])
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// Check if already logged in — if yes, redirect to dashboard
|
||||
if (authStore.isLoggedIn) {
|
||||
router.replace('/tenant/dashboard')
|
||||
}
|
||||
})
|
||||
|
||||
async function sendCode() {
|
||||
if (!form.email.trim() || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(form.email)) {
|
||||
errors.email = '请输入有效的邮箱地址'
|
||||
|
||||
@@ -77,6 +77,13 @@ function onAgreementsAccepted() {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// Check if already logged in — if yes, redirect to dashboard
|
||||
if (authStore.isLoggedIn) {
|
||||
const redirect = (route.query.redirect as string) || '/tenant/dashboard'
|
||||
router.replace(redirect)
|
||||
return
|
||||
}
|
||||
|
||||
nextTick(() => emailInput.value?.focus())
|
||||
await fetchSettings()
|
||||
})
|
||||
|
||||
@@ -48,6 +48,12 @@ function proceedAfterRegister() {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// Check if already logged in — if yes, redirect to dashboard
|
||||
if (authStore.isLoggedIn) {
|
||||
router.replace('/tenant/dashboard')
|
||||
return
|
||||
}
|
||||
|
||||
await fetchSettings()
|
||||
emailVerification.value = settings.value.register_email_verification === true
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user