Procházet zdrojové kódy

网络中断更加友好

Michael Wang před 6 roky
rodič
revize
d0aad2874f

+ 33 - 25
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -49,11 +49,6 @@ export default {
     return { showFaceId: false, faceEnable: false, timeouted: false };
   },
   async created() {
-    // if (!this.$route.params.order) {
-    //   // created can access this.$route?
-    //   this.$router.push(this.$route.fullPath + "/order/1");
-    //   return;
-    // }
     this.timeoutTimeout = setTimeout(() => (this.timeouted = true), 30 * 1000);
     await this.initData();
 
@@ -83,6 +78,11 @@ export default {
         this.$route.params.examId +
         `/IS_FACE_ENABLE`
     );
+    if (faceEnable.data === undefined) {
+      this.$Message.error("获取人脸检测设置失败");
+      this.logout();
+      return;
+    }
     if (faceEnable.data) {
       this.faceEnable = true;
 
@@ -95,6 +95,11 @@ export default {
           this.$route.params.examId +
           `/SNAPSHOT_INTERVAL`
       );
+      if (snapshotInterval.data === undefined) {
+        this.$Message.error("获取人脸抓拍间隔设置失败");
+        this.logout();
+        return;
+      }
       if (snapshotInterval.data) {
         // 考务设置抓拍间隔
         this.snapInterval = setInterval(() => {
@@ -107,15 +112,6 @@ export default {
       () => this.answerAllQuestions(),
       10 * 1000 // 10秒检查是否有更改需要提交答案
     );
-
-    // this.$Modal.info({
-    //   // title: "活体检测",
-    //   header: "",
-    //   footerHide: true,
-    //   render: h => {
-    //     return <FaceId />;
-    //   }
-    // });
   },
   beforeDestroy() {
     clearTimeout(this.timeoutTimeout);
@@ -135,9 +131,25 @@ export default {
       "resetExamQuestionDirty"
     ]),
     async initData() {
-      const exam = await this.$http.get(
-        "/api/ecs_exam_work/exam/" + this.$route.params.examId
-      );
+      const [exam, paperStruct, examQuestionListData] = await Promise.all([
+        this.$http.get("/api/ecs_exam_work/exam/" + this.$route.params.examId),
+        this.$http.get(
+          "/api/ecs_oe_student/examRecordPaperStruct/getExamRecordPaperStruct?examRecordDataId=" +
+            this.$route.params.examRecordDataId
+        ),
+        this.$http.get("/api/ecs_oe_student/examQuestion/findExamQuestionList")
+      ]);
+
+      if (
+        exam.data === undefined ||
+        paperStruct.data === undefined ||
+        examQuestionListData.data === undefined
+      ) {
+        this.$Message.error("获取试卷信息失败");
+        this.logout();
+        return;
+      }
+
       if (exam.data.examType === "PRACTICE") {
         const practiceType = (await this.$http.get(
           "/api/ecs_exam_work/exam/examOrgProperty/" +
@@ -146,18 +158,11 @@ export default {
         )).data;
         this.practiceType = practiceType; // IN_PRACTICE NO_ANSWER
       }
-      const paperStruct = (await this.$http.get(
-        "/api/ecs_oe_student/examRecordPaperStruct/getExamRecordPaperStruct?examRecordDataId=" +
-          this.$route.params.examRecordDataId
-      )).data;
-
-      let examQuestionList = (await this.$http.get(
-        "/api/ecs_oe_student/examQuestion/findExamQuestionList"
-      )).data;
 
       // init subNumber
       let questionId = null;
       let i = 1;
+      let examQuestionList = examQuestionListData.data;
       examQuestionList = examQuestionList.map(eq => {
         if (questionId == eq.questionId) {
           eq.subNumber = i++;
@@ -332,6 +337,9 @@ export default {
     },
     reloadPage() {
       window.location.reload();
+    },
+    logout() {
+      this.$router.push("/login/" + localStorage.getItem("domain"));
     }
   },
   computed: {

+ 0 - 1
src/features/OnlineExam/OnlineExamHome.vue

@@ -31,7 +31,6 @@ export default {
     )).data;
 
     if (examingRes) {
-      console.debug(examingRes);
       this.$router.push(
         `/online-exam/exam/${examingRes.examId}/examRecordData/${
           examingRes.examRecordDataId