Эх сурвалжийг харах

Merge branch 'dev_v4.1.3' into release_v4.1.3

chenhao 2 жил өмнө
parent
commit
e52f4dadc9

+ 6 - 5
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -42,11 +42,16 @@ const examRecordDataId = +route.params.examRecordDataId;
 store.exam.examId = examId;
 store.exam.examRecordDataId = examRecordDataId;
 
+//#region 人脸抓拍与活体检测
+let { snapId, doSnap, showSnapResult } = useFaceCompare();
+let { showFaceId } = useFaceLive(doSnap);
+
 useScreenTop(examRecordDataId);
 useWXSocket();
 const { userSubmitPaper, realSubmitPaper } = useRealSubmitPaper(
   examId,
-  examRecordDataId
+  examRecordDataId,
+  doSnap
 );
 
 async function userClickSubmit() {
@@ -126,10 +131,6 @@ function onStartAnswer({
   usedExamTimes.startTimestamp = Date.now()
 }
 
-//#region 人脸抓拍与活体检测
-let { snapId, doSnap, showSnapResult } = useFaceCompare();
-let { showFaceId } = useFaceLive(doSnap);
-
 type CompareResult = { hasError: boolean; fileName: string };
 function onCompareResult({ hasError, fileName }: CompareResult) {
   if (hasError) {

+ 6 - 3
src/features/OnlineExam/Examing/setups/useFaceCompare.ts

@@ -15,7 +15,7 @@ type Ret = {
     examRecordDataId: string | number
   ) => Promise<void>;
 };
-let singleton: Ret;
+let singleton: Ret | null;
 /** 人脸后台Face++比对 */
 export function useFaceCompare(): Ret {
   if (singleton) return singleton;
@@ -79,7 +79,7 @@ export function useFaceCompare(): Ret {
   watch(
     () => store.exam.SNAPSHOT_INTERVAL,
     () => {
-      if (store.exam.SNAPSHOT_INTERVAL) {
+      if (store.exam.SNAPSHOT_INTERVAL > 0) {
         // 考务设置抓拍间隔
         addInterval(() => {
           logger({
@@ -100,7 +100,10 @@ export function useFaceCompare(): Ret {
   }
 
   // 离开此页面时,可能还有心跳请求未返回
-  onUnmounted(() => cancelShow && cancelShow.abort());
+  onUnmounted(() => {
+    cancelShow && cancelShow.abort();
+    singleton && (singleton = null);
+  });
 
   let cancelShow: AbortController;
 

+ 5 - 3
src/features/OnlineExam/Examing/setups/useSubmitPaper.tsx

@@ -2,11 +2,13 @@ import router from "@/router";
 import { useTimers } from "@/setups/useTimers";
 import { store } from "@/store/store";
 import { answerAllQuestions } from "./useAnswerQuestions";
-import { useFaceCompare } from "./useFaceCompare";
 
-export function useRealSubmitPaper(examId: number, examRecordDataId: number) {
+export function useRealSubmitPaper(
+  examId: number,
+  examRecordDataId: number,
+  doSnap: () => void
+) {
   const { addTimeout } = useTimers();
-  const { doSnap } = useFaceCompare();
 
   async function userSubmitPaper(usedExamTimes: {
     usedExamSeconds: number;

+ 4 - 3
src/features/OnlineExam/FaceRecognition.vue

@@ -208,7 +208,7 @@ async function getSnapShot(compareSync: boolean): Promise<Blob | unknown> {
       }
       return;
     }
-    video.pause();
+    // video.pause();
     const canvas = document.createElement("canvas");
     canvas.width = 220;
     canvas.height = 165;
@@ -217,7 +217,8 @@ async function getSnapShot(compareSync: boolean): Promise<Blob | unknown> {
     context?.drawImage(video, 0, 0, 220, 165);
 
     canvas.toBlob((blob) => resolve(blob!), "image/png", 0.95);
-  }).finally(() => void videoStartPlay()); // finally 会在返回前执行,满足我们的要求
+  })
+  // .finally(() => void videoStartPlay()); // finally 会在返回前执行,满足我们的要求
 }
 
 // 用来比对两次抓拍照片的md5是否一样
@@ -296,7 +297,7 @@ async function uploadToServer(captureBlob: Blob): Promise<[string, string]> {
       dtl: "保存抓拍照片到服务器失败!",
       possibleError: e,
     });
-    $message.error("抓拍照片保存失败!");
+    $message.error("网络连接失败, 请更换网络环境重试");
     throw new Error("抓拍照片保存失败!");
   }
 

+ 2 - 2
src/features/UserLogin/useRemoteAppChecker.tsx

@@ -41,7 +41,7 @@ export function useRemoteAppChecker() {
         dtl: "读取remoteApplication.txt出错",
         ext: { errorType: "e-01", applicationNames },
       });
-      $message.error("系统检测出错(e-01),请退出程序后重试!", {
+      $message.error("请关闭远程控制程序后重试", {
         duration: 24 * 60 * 60 * 1000,
       });
       disableLoginBtnBecauseRemoteApp = true;
@@ -150,7 +150,7 @@ export function useRemoteAppChecker() {
           dtl: "unlink remoteApplication.txt 失败",
           possibleError: error,
         });
-        $message.error("系统检测出错(e-01),请退出程序后重试!", {
+        $message.error("请关闭远程控制程序后重试", {
           duration: 24 * 60 * 60 * 1000,
         });
         throw error;

+ 2 - 2
src/features/UserLogin/useVCamChecker.tsx

@@ -32,7 +32,7 @@ export function useVCamChecker() {
         dtl: "读取CameraInfo.txt出错",
         ext: { errorType: "e-02", applicationNames: cameraInfo },
       });
-      $message.error("系统检测出错(e-02),请退出程序后重试!", {
+      $message.error("请关闭虚拟摄像头软件或直接更换电脑", {
         duration: 24 * 60 * 60 * 1000,
       });
       return;
@@ -98,7 +98,7 @@ export function useVCamChecker() {
           dtl: "unlink CameraInfo.txt 失败",
           possibleError: error,
         });
-        $message.error("系统检测出错(e-02),请退出程序后重试!", {
+        $message.error("请关闭虚拟摄像头软件或直接更换电脑", {
           duration: 24 * 60 * 60 * 1000,
         });
         throw error;