From 613db5af01028c029334ef2b4fec27bf058edf8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=99=E7=A0=81=E7=94=9F=E8=8A=B1?= <18523774412@qq.com> Date: Sun, 20 Nov 2022 19:04:42 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=E4=BC=9A=E5=91=98=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=88=B0=E6=B3=A8=E5=86=8C=E8=A1=A8=E5=8D=95=E6=97=B6=E6=B8=85?= =?UTF-8?q?=E7=90=86=E7=94=A8=E6=88=B7=E5=90=8D=20close=20#I5ZYA6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/views/frontend/user/login.vue | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) 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) => {