瀏覽代碼

优化禁止登陆button在刷新中的状态

Michael Wang 5 年之前
父節點
當前提交
ff920f6453
共有 1 個文件被更改,包括 13 次插入6 次删除
  1. 13 6
      src/features/Login/Login.vue

+ 13 - 6
src/features/Login/Login.vue

@@ -158,6 +158,7 @@ export default {
       disableLoginBtnBecauseRemoteApp: true,
       disableLoginBtnBecauseVCam: true,
       disableLoginBtnBecauseNoRemoteAppChecker: false,
+      disableLoginBtnBecauseRefreshServiceWorker: false,
       newVersionAvailable: false,
       VUE_APP_GIT_REPO_VERSION: process.env.VUE_APP_GIT_REPO_VERSION,
     };
@@ -170,10 +171,11 @@ export default {
       this.$Message.info({
         content: "正在更新版本...",
       });
+      this.disableLoginBtnBecauseRefreshServiceWorker = true;
       await new Promise(resolve => {
         setTimeout(() => {
           resolve();
-        }, 3000);
+        }, 2000);
       });
       location.reload(true);
     }
@@ -279,7 +281,10 @@ export default {
   beforeDestroy() {
     clearTimeout(this.loginTimeout);
     // clearInterval(this.checkNewVersionInterval);
-    document.removeEventListener(this.checkNewVersionListener);
+    document.removeEventListener(
+      "__newSWAvailable",
+      this.checkNewVersionListener
+    );
   },
   methods: {
     ...mapMutations(["updateUser", "updateTimeDifference", "updateQECSConfig"]),
@@ -438,6 +443,7 @@ export default {
           content: "正在获取新版本...",
         });
         localStorage.setItem("__swReload", "anything");
+        this.disableLoginBtnBecauseRefreshServiceWorker = true;
         await new Promise(resolve => {
           setTimeout(() => {
             resolve();
@@ -716,10 +722,11 @@ export default {
       //   this.disableLoginBtnBecauseNoRemoteAppChecker
       // );
       return (
-        this.isElectron &&
-        (this.disableLoginBtnBecauseRemoteApp ||
-          this.disableLoginBtnBecauseVCam ||
-          this.disableLoginBtnBecauseNoRemoteAppChecker)
+        (this.isElectron &&
+          (this.disableLoginBtnBecauseRemoteApp ||
+            this.disableLoginBtnBecauseVCam ||
+            this.disableLoginBtnBecauseNoRemoteAppChecker)) ||
+        this.disableLoginBtnBecauseRefreshServiceWorker
       );
     },
   },