刘洋 7 月之前
父節點
當前提交
922ca87619
共有 2 個文件被更改,包括 29 次插入4 次删除
  1. 1 0
      .eslintrc.js
  2. 28 4
      src/features/OnlineExam/Examing/UploadPhotos.vue

+ 1 - 0
.eslintrc.js

@@ -44,6 +44,7 @@ module.exports = {
     // TODO: https://github.com/vuejs/rfcs/discussions/369  defineProps deconstructure retain reactivity
     // eslint-disable-next-line vue/no-setup-props-destructure
     "vue/no-setup-props-destructure": "off",
+    "@typescript-eslint/no-unsafe-argument": "off",
   },
   ignorePatterns: [
     // FIXME: ignore lang="tsx" don't know how to fix

+ 28 - 4
src/features/OnlineExam/Examing/UploadPhotos.vue

@@ -3,7 +3,7 @@ import VueQrcode from "@chenfengyuan/vue-qrcode";
 import draggable from "vuedraggable";
 import "viewerjs/dist/viewer.css";
 import Viewer from "viewerjs";
-import { watch } from "vue";
+import { watch, onBeforeUnmount } from "vue";
 import { store } from "@/store/store";
 import { Eye, TrashOutline, Checkmark } from "@vicons/ionicons5";
 import { useHandGetAnswer } from "./setups/useWXSocket";
@@ -11,12 +11,29 @@ const { loading: handLoading, handler: handHandler } = useHandGetAnswer();
 
 const examQuestion = $computed(() => store.exam.currentQuestion);
 const examRecordDataId = store.exam.examRecordDataId;
+let timer: any = null;
+let freeze = $ref(0);
+
 const handGetAnswer = () => {
+  freeze = 20;
+  timer = setInterval(() => {
+    freeze = freeze - 1;
+    if (freeze == 0) {
+      clearInterval(timer);
+      timer = null;
+    }
+  }, 1000);
   handHandler({
     examRecordDataId: examRecordDataId,
     questionOrder: examQuestion.order,
   });
 };
+onBeforeUnmount(() => {
+  if (timer) {
+    clearInterval(timer);
+    timer = null;
+  }
+});
 const props = defineProps<{
   defaultList: string[];
   qrValue: string;
@@ -31,7 +48,6 @@ const emit = defineEmits<{
 }>();
 
 let uploadList: string[] = $ref([]);
-
 watch(
   () => props.defaultList,
   () => (uploadList = [...props.defaultList])
@@ -54,7 +70,14 @@ watch(
       // } else {
       //   totalList.push(...[...new Set(value.fileUrl.split(","))]);
       // }
-      totalList.push(...[...new Set(value.fileUrl.split(","))]);
+
+      // totalList.push(...[...new Set(value.fileUrl.split(","))]);
+      let arr = [...new Set(value.fileUrl.split(","))];
+      for (let i = 0; i < arr.length; i++) {
+        if (!totalList.includes(arr[i])) {
+          totalList.push(arr[i]);
+        }
+      }
     }
   }
 );
@@ -278,8 +301,9 @@ function prepareUpload() {
               type="primary"
               size="large"
               :loading="handLoading"
+              :disabled="freeze > 0"
               @click="handGetAnswer"
-              >刷新</n-button
+              >{{ freeze > 0 ? `倒计时${freeze}s` : "刷新" }}</n-button
             >
             <span style="margin-left: 10px">同步拍照作答</span>
           </div>