Bladeren bron

断点续考只在登录时检测

Michael Wang 6 jaren geleden
bovenliggende
commit
56db8f0fae
2 gewijzigde bestanden met toevoegingen van 31 en 31 verwijderingen
  1. 31 1
      src/features/Login/Login.vue
  2. 0 30
      src/features/OnlineExam/OnlineExamHome.vue

+ 31 - 1
src/features/Login/Login.vue

@@ -204,7 +204,7 @@ export default {
           const user = { ...data, ...student };
           this.updateUser(user);
           window.localStorage.setItem("user-for-reload", JSON.stringify(user));
-          this.$router.push("/online-exam");
+          await this.checkExamInProgress();
         } catch (error) {
           this.$Message.error({
             content: "获取学生信息失败,请重试!",
@@ -215,6 +215,36 @@ export default {
         this.errorInfo = data.desc;
       }
     },
+    async checkExamInProgress() {
+      try {
+        // 断点续考
+        const examingRes = (await this.$http.get(
+          "/api/ecs_oe_student/examControl/checkExamInProgress"
+        )).data;
+        if (examingRes) {
+          this.$Spin.show({
+            render: () => {
+              return <div style="font-size: 24px">正在进入断点续考...</div>;
+            }
+          });
+          this.$router.push(
+            `/online-exam/exam/${examingRes.examId}/examRecordData/${
+              examingRes.examRecordDataId
+            }/order/1` +
+              (examingRes.faceVerifyMinute
+                ? `?faceVerifyMinute=${examingRes.faceVerifyMinute}`
+                : "")
+          );
+          setTimeout(() => this.$Spin.hide(), 1000);
+          return;
+        }
+        this.$router.push("/online-exam");
+      } catch (error) {
+        this.$Message.error("获取断点续考信息异常,退出登录");
+        this.logout();
+        return;
+      }
+    },
     closeApp() {
       window.close();
     }

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

@@ -25,36 +25,6 @@ export default {
     };
   },
   async mounted() {
-    this.$Spin.show({
-      render: () => {
-        return <div style="font-size: 24px">正在获取断点续考信息...</div>;
-      }
-    });
-    try {
-      // 断点续考
-      const examingRes = (await this.$http.get(
-        "/api/ecs_oe_student/examControl/checkExamInProgress"
-      )).data;
-
-      if (examingRes) {
-        this.$router.push(
-          `/online-exam/exam/${examingRes.examId}/examRecordData/${
-            examingRes.examRecordDataId
-          }/order/1` +
-            (examingRes.faceVerifyMinute
-              ? `?faceVerifyMinute=${examingRes.faceVerifyMinute}`
-              : "")
-        );
-        return;
-      }
-    } catch (error) {
-      this.$Message.error("获取断点续考信息异常,退出登录");
-      this.logout();
-      return;
-    } finally {
-      this.$Spin.hide();
-    }
-
     const res = await this.$http.get(
       "/api/ecs_oe_student/examControl/queryExamList"
     );