Преглед на файлове

fix 前端实时检测,检测不到人脸时,没提示

Michael Wang преди 5 години
родител
ревизия
63c6c3e59e
променени са 1 файла, в които са добавени 18 реда и са изтрити 19 реда
  1. 18 19
      src/features/OnlineExam/Examing/FaceTracking.vue

+ 18 - 19
src/features/OnlineExam/Examing/FaceTracking.vue

@@ -191,7 +191,11 @@ export default {
 
         this.multipleTimeUsage = roundAvg;
       }
-      if (result.length >= 2) {
+      // init this.showWaringTime
+      this.showWaringTime = this.showWaringTime || Date.now();
+
+      if (result.length >= 2 && Date.now() - this.showWaringTime > 20 * 1000) {
+        this.showWaringTime = Date.now();
         this.$Message.warning({
           content: "请独立完成考试",
           duration: 5,
@@ -199,28 +203,23 @@ export default {
         });
       }
 
-      if (result.length === 0) {
-        this.findFirst = !this.findFirst; // 两次才告警
-        if (!this.findFirst) {
-          this.$Message.warning({
-            content: "请调整坐姿,诚信考试",
-            duration: 5,
-            closable: true,
-          });
-        }
+      if (result.length === 0 && Date.now() - this.showWaringTime > 20 * 1000) {
+        this.showWaringTime = Date.now();
+        this.$Message.warning({
+          content: "请调整坐姿,诚信考试",
+          duration: 5,
+          closable: true,
+        });
       }
 
       if (
         (!result || result.length !== 1) &&
         !videoEl.classList.contains("video-warning")
       ) {
-        this.findFirst = !this.findFirst; // 两次才告警
-        if (!this.findFirst) {
-          videoEl.classList.add("video-warning");
-          this.warningTimeout = setTimeout(function() {
-            videoEl.classList.remove("video-warning");
-          }, 3000);
-        }
+        videoEl.classList.add("video-warning");
+        this.warningTimeout = setTimeout(function() {
+          videoEl.classList.remove("video-warning");
+        }, 3000);
       }
 
       this.detectFacesTimeout = setTimeout(() => this.detectFaces(), 10 * 1000);
@@ -233,11 +232,11 @@ export default {
 @keyframes warning-people {
   0% {
     /* border: solid 5px white; */
-    box-shadow: 0 0 100px white;
+    box-shadow: 0 0 20px white;
   }
   100% {
     /* border: solid 5px red; */
-    box-shadow: 0 0 100px gold;
+    box-shadow: 0 0 20px gold;
   }
 }