Quellcode durchsuchen

!799 fix: 注册表单校验未失效问题
Merge pull request !799 from 山野羡民/N/A

芋道源码 vor 7 Monaten
Ursprung
Commit
6c0cb191ed
1 geänderte Dateien mit 9 neuen und 3 gelöschten Zeilen
  1. 9 3
      src/views/Login/components/RegisterForm.vue

+ 9 - 3
src/views/Login/components/RegisterForm.vue

@@ -38,7 +38,7 @@
         </el-form-item>
       </el-col>
       <el-col :span="24" class="px-10px">
-        <el-form-item prop="username">
+        <el-form-item prop="nickname">
           <el-input
             v-model="registerData.registerForm.nickname"
             placeholder="昵称"
@@ -104,7 +104,7 @@ import { useIcon } from '@/hooks/web/useIcon'
 import * as authUtil from '@/utils/auth'
 import { usePermissionStore } from '@/store/modules/permission'
 import * as LoginApi from '@/api/login'
-import { LoginStateEnum, useLoginState } from './useLogin'
+import { LoginStateEnum, useLoginState, useFormValid } from './useLogin'
 
 defineOptions({ name: 'RegisterForm' })
 
@@ -113,6 +113,7 @@ const iconHouse = useIcon({ icon: 'ep:house' })
 const iconAvatar = useIcon({ icon: 'ep:avatar' })
 const iconLock = useIcon({ icon: 'ep:lock' })
 const formLogin = ref()
+const {validForm} = useFormValid(formLogin)
 const { handleBackLogin, getLoginState } = useLoginState()
 const { currentRoute, push } = useRouter()
 const permissionStore = usePermissionStore()
@@ -170,6 +171,7 @@ const registerData = reactive({
   }
 })
 
+const loading = ref() // ElLoading.service 返回的实例
 // 提交注册
 const handleRegister = async (params: any) => {
   loading.value = true
@@ -183,6 +185,11 @@ const handleRegister = async (params: any) => {
       registerData.registerForm.captchaVerification = params.captchaVerification
     }
 
+    const data = await validForm()
+    if (!data) {
+      return
+    }
+
     const res = await LoginApi.register(registerData.registerForm)
     if (!res) {
       return
@@ -242,7 +249,6 @@ const getTenantByWebsite = async () => {
     }
   }
 }
-const loading = ref() // ElLoading.service 返回的实例
 
 watch(
   () => currentRoute.value,