소스 검색

fix error reporting

Michael Wang 3 년 전
부모
커밋
e768f1c1a3
2개의 변경된 파일6개의 추가작업 그리고 3개의 파일을 삭제
  1. 2 0
      src/features/OnlineExam/Examing/setups/useAnswerQuestions.ts
  2. 4 3
      src/features/OnlineExam/Examing/setups/useSubmitPaper.tsx

+ 2 - 0
src/features/OnlineExam/Examing/setups/useAnswerQuestions.ts

@@ -21,6 +21,8 @@ type Answer = {
 export async function answerAllQuestions(
   ignoreDirty?: boolean
 ): Promise<boolean> {
+  // 根据线上错误排查:可能已经退出页面了,没有数据了
+  if (!store.exam.examQuestionList) return false;
   const answers: Answer[] = store.exam.examQuestionList
     .filter((eq) => (ignoreDirty ? true : eq.dirty))
     .filter((eq) => eq.gotQuestionContent)

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

@@ -69,13 +69,14 @@ export function useRealSubmitPaper(examId: number, examRecordDataId: number) {
     store.spinMessage = "正在交卷,请耐心等待...";
     logger({ cnl: ["server"], act: "正在交卷,请耐心等待..." });
     let delay = 0;
-    const oldSnapCount = store.exam.compareResultMap.size;
+    const oldSnapCount = store.exam.compareResultMap?.size;
     if (store.exam.faceCheckEnabled) {
       logger({ cnl: ["server"], act: "交卷前抓拍" });
       doSnap();
       await new Promise((resolve) => setTimeout(resolve, 3 * 1000));
-      const newSnapCount = store.exam.compareResultMap.size;
-      if (newSnapCount - oldSnapCount === 0) {
+      // 根据线上错误排查:可能已经退出页面了,没有数据了
+      const newSnapCount = store.exam.compareResultMap?.size;
+      if (store.exam.compareResultMap && newSnapCount - oldSnapCount === 0) {
         // 给抓拍照片多2秒处理时间
         delay = 8;
         logger({ cnl: ["server"], act: "交卷前抓拍", dtl: "3秒内未上传完毕" });