Explorar el Código

优化抓拍照片统计

Michael Wang hace 3 años
padre
commit
341c306a3e

+ 15 - 14
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -194,19 +194,13 @@ onMounted(async () => {
 });
 
 // beforeDestroy() {
-//   clearInterval(this.initSnapInterval);
-//   clearInterval(this.snapInterval);
 //   this.updateExamState({
 //     exam: null,
 //     paperStruct: null,
 //     examQuestionList: null,
 //     questionAnswerFileUrl: [],
 //     pictureAnswer: {},
-//     snapNow: false,
-//     snapProcessingCount: 0,
 //   });
-//   // TODO: 是否是个错误点?this.$Modal 不存在?
-//   this.$Modal.remove();
 //   // 避免macos上下塘动。避免产生滚动条。
 //   document.body.classList.toggle("hide-body-scroll", false);
 // },
@@ -463,18 +457,15 @@ function onAudioAnswer(event: MessageEvent<string>) {
 let { snapId, doSnap, showSnapResult } = useFaceCompare();
 let { showFaceId } = useFaceLive(doSnap);
 
-function onCompareResult({
-  hasError,
-  fileName,
-}: {
-  hasError: boolean;
-  fileName: string;
-}) {
+const cmpResMap = new Map<string, boolean>();
+type CompareResult = { hasError: boolean; fileName: string };
+function onCompareResult({ hasError, fileName }: CompareResult) {
   if (hasError) {
     // 60秒后重试抓拍
     addInterval(doSnap, 60 * 1000);
   } else {
-    showSnapResult(fileName, examRecordDataId);
+    cmpResMap.set(fileName, false);
+    showSnapResult(fileName, examRecordDataId, cmpResMap);
   }
 }
 
@@ -601,6 +592,16 @@ function realSubmitPaper() {
   addTimeout(() => {
     store.decreaseGlobalMaskCount("realSubmitPaper");
     store.spinMessage = "";
+    const allFinished = [...cmpResMap].every((v) => v[1]);
+    const remained = [...cmpResMap].filter((v) => !v[1]);
+    logger({
+      cnl: ["server"],
+      act: "交卷前检测抓拍照片数量",
+      dtl: allFinished ? "完全检测" : "不完全检测",
+      ext: {
+        remainCount: remained.length,
+      },
+    });
     void router.push({
       name: "SubmitPaper",
       params: { examId, examRecordDataId },

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

@@ -64,6 +64,10 @@ onUnmounted(() => cancelHeartBeat && cancelHeartBeat());
 const CancelToken = axios.CancelToken;
 let cancelHeartBeat: Canceler;
 async function getRemainTimeFromServer() {
+  if (store.exam.remainTime <= 0) {
+    logger({ cnl: ["server"], act: "remainTime=0, stop heartbeat" });
+    return;
+  }
   try {
     logger({ cnl: ["server"], act: "发出心跳" });
     const res = await httpApp.get(

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

@@ -94,7 +94,8 @@ export function useFaceCompare() {
 
   async function showSnapResult(
     fileName: string,
-    examRecordDataId: string | number
+    examRecordDataId: string | number,
+    cmpRes: Map<string, boolean>
   ) {
     if (!fileName) return; // 交卷后提交照片会得不到照片名称
 
@@ -116,6 +117,7 @@ export function useFaceCompare() {
         } else if (!snapRes.isPass) {
           $message.error("请调整坐姿,诚信考试");
         }
+        cmpRes.set(fileName, true);
       } else {
         addTimeout(
           showSnapResult.bind(null, fileName, examRecordDataId),