Bladeren bron

心跳失败后,定时退出,否则长期停留在此界面,会发出很多无用请求

Michael Wang 5 jaren geleden
bovenliggende
commit
f976e6a662
2 gewijzigde bestanden met toevoegingen van 28 en 11 verwijderingen
  1. 28 10
      src/features/OnlineExam/Examing/RemainTime.vue
  2. 0 1
      src/features/OnlineExam/Examing/TextQuestionView.vue

+ 28 - 10
src/features/OnlineExam/Examing/RemainTime.vue

@@ -137,28 +137,45 @@ export default {
             "心跳",
             "失败10次-退出",
           ]);
-          const redirectUrl = sessionStorage.getItem("redirectUrl");
           this.logger({
             action: "发出心跳",
             error: "心跳失败",
             detail: `失败10次-退出`,
           });
           console.log(`失败10次-退出`);
+          // this.logout('心跳失败10次-退出');
+          // const redirectUrl = sessionStorage.getItem("redirectUrl");
+          // this.$Modal.error({
+          //   title: "网络连接异常",
+          //   content: "退出考试",
+          //   onOk: () => {
+          //     if (redirectUrl) {
+          //       window.location = redirectUrl;
+          //     } else {
+          //       this.$router.push(
+          //         "/login/" +
+          //           localStorage.getItem("domain") +
+          //           "?LogoutReason=心跳失败10次-退出"
+          //       );
+          //     }
+          //   },
+          // });
+          let clicked = false;
           this.$Modal.error({
             title: "网络连接异常",
             content: "退出考试",
             onOk: () => {
-              if (redirectUrl) {
-                window.location = redirectUrl;
-              } else {
-                this.$router.push(
-                  "/login/" +
-                    localStorage.getItem("domain") +
-                    "?LogoutReason=心跳失败10次-退出"
-                );
-              }
+              clicked = true;
+              this.logout("?LogoutReason=心跳失败10次-退出-clicked");
             },
           });
+          // 心跳失败后,定时退出,否则长期停留在此界面,会发出很多无用请求
+          this.exitTimeout = setTimeout(() => {
+            if (!clicked) {
+              this.$Modal.remove();
+              this.logout("?LogoutReason=心跳失败10次-退出-timeout");
+            }
+          }, 90 * 1000);
           return;
         }
         this.retryHeartbeatTimeout = setTimeout(() => {
@@ -175,6 +192,7 @@ export default {
       clearInterval(this.remainTimeInterval);
       clearTimeout(this.retryHeartbeatTimeout);
       clearInterval(this.enhancedRemainTimeInterval);
+      clearTimeout(this.exitTimeout);
     },
   },
 };

+ 0 - 1
src/features/OnlineExam/Examing/TextQuestionView.vue

@@ -304,7 +304,6 @@ export default {
     }, 6 * 1000);
   },
   beforeDestroy() {
-    clearTimeout(this.fetchQRCodeTimeout);
     clearInterval(this.fetchQRCodeInterval);
   },
   methods: {