diff --git a/web/src/views/frontend/user/login.vue b/web/src/views/frontend/user/login.vue index 72e1db92..d55b4def 100644 --- a/web/src/views/frontend/user/login.vue +++ b/web/src/views/frontend/user/login.vue @@ -299,8 +299,8 @@ import { onResetForm } from '/@/utils/common' import { useUserInfo } from '/@/stores/userInfo' import { useRouter } from 'vue-router' import { useRoute } from 'vue-router' -import type { ElForm, FormItemRule } from 'element-plus' -var timer: NodeJS.Timer +import type { FormItemRule, FormInstance } from 'element-plus' +let timer: NodeJS.Timer const { t } = useI18n() const route = useRoute() @@ -308,8 +308,8 @@ const router = useRouter() const userInfo = useUserInfo() const siteConfig = useSiteConfig() const memberCenter = useMemberCenter() -const formRef = ref>() -const retrieveFormRef = ref>() +const formRef = ref() +const retrieveFormRef = ref() interface State { form: { @@ -413,7 +413,7 @@ const onChangeCaptcha = () => { state.form.captcha = '' state.form.captchaId = uuid() } -const onSubmit = (formRef: InstanceType | undefined = undefined) => { +const onSubmit = (formRef: FormInstance | undefined = undefined) => { formRef!.validate((valid) => { if (valid) { state.formLoading = true @@ -432,7 +432,7 @@ const onSubmit = (formRef: InstanceType | undefined = undefined) } }) } -const onSubmitRetrieve = (formRef: InstanceType | undefined = undefined) => { +const onSubmitRetrieve = (formRef: FormInstance | undefined = undefined) => { formRef!.validate((valid) => { if (valid) { state.submitRetrieveLoading = true @@ -453,7 +453,7 @@ const onSubmitRetrieve = (formRef: InstanceType | undefined = und }) } -const sendRegisterCaptcha = (formRef: InstanceType | undefined = undefined) => { +const sendRegisterCaptcha = (formRef: FormInstance | undefined = undefined) => { if (state.codeSendCountdown > 0) return formRef!.validateField([state.form.registerType, 'username', 'password']).then((valid) => { if (valid) { @@ -470,7 +470,7 @@ const sendRegisterCaptcha = (formRef: InstanceType | undefined = }) } -const sendRetrieveCaptcha = (formRef: InstanceType | undefined = undefined) => { +const sendRetrieveCaptcha = (formRef: FormInstance | undefined = undefined) => { if (state.codeSendCountdown > 0) return formRef!.validateField('account').then((valid) => { if (valid) { @@ -487,10 +487,10 @@ const sendRetrieveCaptcha = (formRef: InstanceType | undefined = }) } -const switchTab = (formRef: InstanceType | undefined = undefined, tab: 'login' | 'register') => { +const switchTab = (formRef: FormInstance | undefined = undefined, tab: 'login' | 'register') => { state.form.tab = tab - // 切换登录或者注册tab时重置表单,避免切换后保存之前表单的状态 - onResetForm(formRef) + if (tab == 'register') state.form.username = '' + if (formRef) formRef.clearValidate() } const startTiming = (seconds: number) => {