refactor:会员切换到注册表单时清理用户名 close #I5ZYA6

This commit is contained in:
妙码生花 2022-11-20 19:04:42 +08:00
parent d964b98a49
commit 613db5af01

View File

@ -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<InstanceType<typeof ElForm>>()
const retrieveFormRef = ref<InstanceType<typeof ElForm>>()
const formRef = ref<FormInstance>()
const retrieveFormRef = ref<FormInstance>()
interface State {
form: {
@ -413,7 +413,7 @@ const onChangeCaptcha = () => {
state.form.captcha = ''
state.form.captchaId = uuid()
}
const onSubmit = (formRef: InstanceType<typeof ElForm> | undefined = undefined) => {
const onSubmit = (formRef: FormInstance | undefined = undefined) => {
formRef!.validate((valid) => {
if (valid) {
state.formLoading = true
@ -432,7 +432,7 @@ const onSubmit = (formRef: InstanceType<typeof ElForm> | undefined = undefined)
}
})
}
const onSubmitRetrieve = (formRef: InstanceType<typeof ElForm> | undefined = undefined) => {
const onSubmitRetrieve = (formRef: FormInstance | undefined = undefined) => {
formRef!.validate((valid) => {
if (valid) {
state.submitRetrieveLoading = true
@ -453,7 +453,7 @@ const onSubmitRetrieve = (formRef: InstanceType<typeof ElForm> | undefined = und
})
}
const sendRegisterCaptcha = (formRef: InstanceType<typeof ElForm> | 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<typeof ElForm> | undefined =
})
}
const sendRetrieveCaptcha = (formRef: InstanceType<typeof ElForm> | 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<typeof ElForm> | undefined =
})
}
const switchTab = (formRef: InstanceType<typeof ElForm> | 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) => {