Преглед на файлове

feat: (dashborad) autofill readonly prevent

gemercheung преди 2 години
родител
ревизия
64e815fc43
променени са 1 файла, в които са добавени 24 реда и са изтрити 5 реда
  1. 24 5
      src/views/sys/login/RegisterForm.vue

+ 24 - 5
src/views/sys/login/RegisterForm.vue

@@ -6,7 +6,8 @@
         <Input
           class="fix-auto-fill"
           size="large"
-          autoComplete="off"
+          autocomplete="off"
+          :readonly="preventAutoFill"
           v-model:value="formData.userName"
           placeholder="请输入手机号"
         />
@@ -22,9 +23,10 @@
       <FormItem name="code" class="enter-x">
         <CountdownInput
           size="large"
-          autoComplete="off"
+          autocomplete="off"
           class="fix-auto-fill"
           :count="60"
+          :readonly="preventAutoFill"
           :sendCodeApi="
             () => {
               return reg.test(formData.userName)
@@ -41,7 +43,8 @@
       <FormItem name="userPassword" class="enter-x">
         <StrengthMeter
           size="large"
-          autoComplete="off"
+          autocomplete="off"
+          :readonly="preventAutoFill"
           v-model:value="formData.userPassword"
           placeholder="请输入账号密码"
         />
@@ -78,7 +81,7 @@
   </template>
 </template>
 <script lang="ts" setup>
-  import { reactive, ref, unref, computed } from 'vue';
+  import { reactive, ref, unref, computed, watch } from 'vue';
   import LoginFormTitle from './LoginFormTitle.vue';
   // Checkbox
   import { Form, Input, Button } from 'ant-design-vue';
@@ -96,7 +99,7 @@
 
   const formRef = ref();
   const loading = ref(false);
-
+  const preventAutoFill = ref(true);
   const formData = reactive({
     userName: '',
     userPassword: '',
@@ -118,6 +121,22 @@
 
   const getShow = computed(() => unref(getLoginState) === LoginStateEnum.REGISTER);
 
+  watch(
+    () => getShow,
+    (data) => {
+      console.log('getShow', data.value);
+      if (data.value) {
+        setTimeout(() => {
+          preventAutoFill.value = !data.value;
+        }, 500);
+      }
+    },
+    {
+      immediate: true,
+      deep: true,
+    },
+  );
+
   async function handleRegister() {
     console.log('getFormRules', getFormRules);
     const data = await validForm();