Browse Source

人脸检测不可用时,退出登录

Michael Wang 5 năm trước cách đây
mục cha
commit
53678f95c1
1 tập tin đã thay đổi với 16 bổ sung5 xóa
  1. 16 5
      src/features/OnlineExam/Examing/FaceMotion/FaceMotion.vue

+ 16 - 5
src/features/OnlineExam/Examing/FaceMotion/FaceMotion.vue

@@ -874,17 +874,28 @@ export default {
       });
       console.log(videoEl.readyState, faceapi.nets.tinyFaceDetector.params);
       console.log("increaseTestSpeed --- doing faceapi");
-      const result = await faceapi
-        .detectSingleFace(videoEl, options)
-        .withFaceLandmarks()
-        .withFaceExpressions();
+      const result = await Promise.race([
+        faceapi
+          .detectSingleFace(videoEl, options)
+          .withFaceLandmarks()
+          .withFaceExpressions(),
+        new Promise(resolve => setTimeout(resolve, 20 * 1000)),
+      ]);
       console.log("increaseTestSpeed --- result:", result);
+      this.$Spin.hide();
+      if (typeof result === "undefined") {
+        this.$Message.error({
+          content: "人脸检测功能不可用",
+          duration: 15,
+          closable: true,
+        });
+        this.logout("?LogoutReason=人脸检测功能不可用");
+      }
       if (!result) {
         console.log("increaseTestSpeed --- end failed");
       } else {
         console.log("increaseTestSpeed --- end successfully");
       }
-      this.$Spin.hide();
     },
     videoStartPlay() {
       const video = document.getElementById("inputVideo");