Prechádzať zdrojové kódy

登录按钮两次点击之间的延迟

Michael Wang 6 rokov pred
rodič
commit
f8882138e5
1 zmenil súbory, kde vykonal 10 pridanie a 1 odobranie
  1. 10 1
      src/features/Login/Login.vue

+ 10 - 1
src/features/Login/Login.vue

@@ -83,6 +83,7 @@
                 class="qm-primary-button"
                 long
                 :disabled="disableLoginBtn"
+                :loading="loginBtnLoading"
                 @click="login"
               >
                 登录
@@ -142,6 +143,7 @@ export default {
         ],
       },
       disableLoginBtn: true,
+      loginBtnLoading: false,
       VUE_APP_GIT_REPO_VERSION: process.env.VUE_APP_GIT_REPO_VERSION,
     };
   },
@@ -289,6 +291,9 @@ export default {
       this.disableLoginBtn = false;
     }
   },
+  beforeDestroy() {
+    clearTimeout(this.loginTimeout);
+  },
   methods: {
     ...mapMutations(["updateUser", "updateTimeDifference"]),
     async login() {
@@ -297,7 +302,11 @@ export default {
       }
       await this.checkNewVersion();
       this.disableLoginBtn = true;
-      setTimeout(() => (this.disableLoginBtn = false), 5000);
+      this.loginBtnLoading = true;
+      this.loginTimeout = setTimeout(() => {
+        this.disableLoginBtn = false;
+        this.loginBtnLoading = false;
+      }, 10 * 1000);
       // https://www.cnblogs.com/weiqinl/p/6708993.html
       const valid = await this.$refs.loginForm.validate();
       if (valid) {