浏览代码

照片上传同步

Michael Wang 6 年之前
父节点
当前提交
990adafa90
共有 3 个文件被更改,包括 15 次插入3 次删除
  1. 2 2
      src/components/FaceRecognition/FaceRecognition.vue
  2. 6 1
      src/features/OnlineExam/Examing/ExamingHome.vue
  3. 7 0
      src/store.js

+ 2 - 2
src/components/FaceRecognition/FaceRecognition.vue

@@ -51,7 +51,7 @@ export default {
     });
   },
   methods: {
-    ...mapMutations(["toggleSnapNow"]),
+    ...mapMutations(["toggleSnapNow", "decreaseSnapCount"]),
     async openCamera() {
       const video = this.$refs.video;
       if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
@@ -80,7 +80,7 @@ export default {
       const [fileName, captureFilePath] = await this.uploadToServer(
         captureBlob
       );
-
+      this.decreaseSnapCount();
       await this.faceCompare(fileName, captureFilePath);
       const video = this.$refs.video;
       video && video.play();

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

@@ -269,9 +269,13 @@ export default {
       });
       this.toggleSnapNow();
       // 确保抓拍指令在交卷前执行
-      setTimeout(() => this.realSubmitPaperStep2(), 1500);
+      setTimeout(() => this.realSubmitPaperStep2(), 1000);
     },
     async realSubmitPaperStep2() {
+      if (this.snapProcessingCount > 0) {
+        setTimeout(() => this.realSubmitPaperStep2(), 300);
+        return;
+      }
       try {
         const res = await this.$http.get(
           "/api/ecs_oe_student/examControl/endExam"
@@ -310,6 +314,7 @@ export default {
       "paperStruct",
       "examQuestionList",
       "snapNow",
+      "snapProcessingCount",
       "shouldSubmitPaper"
     ]),
     previousQuestionOrder: vm => {

+ 7 - 0
src/store.js

@@ -27,11 +27,18 @@ const examingHomeModule = {
     examQuestionList: null,
     questionFilterType: "ALL",
     snapNow: false,
+    snapProcessingCount: 0,
     shouldSubmitPaper: false
   },
   mutations: {
     toggleSnapNow(state) {
       state.snapNow = !state.snapNow;
+      if (state.snapNow) {
+        state.snapProcessingCount++;
+      }
+    },
+    decreaseSnapCount(state) {
+      state.snapProcessingCount--;
     },
     updateExamState(state, payload) {
       state = Object.assign(state, payload);