浏览代码

一分钟不能启动摄像头,则退出考试

Michael Wang 5 年之前
父节点
当前提交
4cf6eef267
共有 1 个文件被更改,包括 27 次插入8 次删除
  1. 27 8
      src/features/OnlineExam/Examing/ExamingHome.vue

+ 27 - 8
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -246,18 +246,37 @@ export default {
 
       let initSnapshotTrialTimes = 0;
       this.initSnapInterval = setInterval(() => {
-        if (this.exam || initSnapshotTrialTimes > 3) {
-          // 超过3次后,强行抓拍,如果抓拍不成功,则会因抓拍不成功而退出。
+        if (initSnapshotTrialTimes >= 5) {
+          // 超过6次后,强行抓拍,如果抓拍不成功,则会因抓拍不成功而退出。
           clearInterval(this.initSnapInterval);
-          this.serverLog(
-            "debug/S-002001",
-            "进入考试后60秒内抓拍" + `(${(initSnapshotTrialTimes + 1) * 5}秒)`
-          );
-          this.toggleSnapNow(); // 开启抓拍才在进入考试时抓拍一张
+
+          const video = document.getElementById("video");
+          if (!video || video.readyState !== 4 || !video.srcObject.active) {
+            this.$Message.error({
+              content: "摄像头没有正常启用",
+              duration: 5,
+              closable: true,
+            });
+            window._hmt.push([
+              "_trackEvent",
+              "摄像头框",
+              "摄像头状态",
+              "摄像头没有正常启用-进入考试抓拍",
+            ]);
+
+            this.logout("?LogoutReason=" + "摄像头没有正常启用-退出");
+          } else {
+            this.serverLog(
+              "debug/S-002001",
+              "进入考试后60秒内抓拍-" +
+                `(第${initSnapshotTrialTimes + 1}次尝试)`
+            );
+            this.toggleSnapNow(); // 开启抓拍才在进入考试时抓拍一张
+          }
         } else {
           initSnapshotTrialTimes++;
         }
-      }, 20 * 1000);
+      }, 10 * 1000);
 
       //       let initSnapshotTrialTimes = 0;
       // const initSnapshot = setTimeout(() => {