Browse Source

心跳异常5次则退出考试

Michael Wang 6 năm trước cách đây
mục cha
commit
41b552eb68
2 tập tin đã thay đổi với 23 bổ sung5 xóa
  1. 1 1
      .env.development
  2. 22 4
      src/features/OnlineExam/Examing/RemainTime.vue

+ 1 - 1
.env.development

@@ -1,4 +1,4 @@
 VUE_APP_TK_SERVER_URL=http://192.168.10.39:8868
 VUE_APP_FACEPP_KEY=kEz_MSSjkNuHL3fHhCvv62fXkAo-vobE
 VUE_APP_FACEPP_SECRET=aQMioMGUDShMnQmfM1_H_kPTP2pJva6J
-VUE_APP_WK_SERVER_SOCKET=ws://192.168.10.39:8878/oewebsocket/
+VUE_APP_WK_SERVER_SOCKET=wss://ecs-dev.qmth.com.cn:8878/oewebsocket/

+ 22 - 4
src/features/OnlineExam/Examing/RemainTime.vue

@@ -15,6 +15,7 @@ export default {
     };
   },
   async mounted() {
+    this.heartbeatErrorNum = 0;
     this.getRemainTimeFromServer();
     this.first = true;
     this.remainTime += 60 * 1000; //补偿心跳
@@ -38,10 +39,27 @@ export default {
   methods: {
     ...mapMutations(["setShouldSubmitPaper"]),
     async getRemainTimeFromServer() {
-      const res = await this.$http.get(
-        "/api/ecs_oe_student/examControl/examHeartbeat"
-      );
-      this.remainTime = res.data;
+      try {
+        const res = await this.$http.get(
+          "/api/ecs_oe_student/examControl/examHeartbeat"
+        );
+        this.remainTime = res.data;
+        this.heartbeatErrorNum = 0;
+      } catch (e) {
+        this.heartbeatErrorNum++;
+        if (this.heartbeatErrorNum === 5) {
+          // 心跳异常5次则退出考试
+          this.$Modal.error({
+            title: "网络连接异常",
+            content: "退出考试",
+            onOk: () => {
+              this.$router.push("/login/" + localStorage.getItem("domain"));
+            }
+          });
+          return;
+        }
+        this.getRemainTimeFromServer();
+      }
     }
   },
   computed: {