浏览代码

交卷按钮防抖优化

刘洋 10 月之前
父节点
当前提交
41bf4b4e9f
共有 1 个文件被更改,包括 13 次插入1 次删除
  1. 13 1
      src/features/OnlineExam/Examing/ExamingHome.vue

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

@@ -59,17 +59,24 @@ const { userSubmitPaper, realSubmitPaper } = useRealSubmitPaper(
   doSnap
 );
 
+let userClickSubmitLoading = $ref(false);
 async function userClickSubmit() {
+  if (userClickSubmitLoading) {
+    return;
+  }
+  userClickSubmitLoading = true;
   try {
     let res: any = await httpApp.post(
       "/api/ecs_oe_student/examControl/check/time"
     );
     console.log("/api/ecs_oe_student/examControl/check/time", res);
+    userClickSubmitLoading = false;
   } catch (error) {
     // $message.error("校验交卷时间失败", {
     //   duration: 15,
     //   closable: true,
     // });
+    userClickSubmitLoading = false;
     return;
   }
   store.increaseGlobalMaskCount("userClickSubmit");
@@ -284,7 +291,12 @@ const userInfo = $computed(() => {
         {{ userInfo }}
       </div>
       <QuestionFilters></QuestionFilters>
-      <n-button type="success" @click="userClickSubmit">交卷</n-button>
+      <n-button
+        type="success"
+        :disabled="userClickSubmitLoading"
+        @click="userClickSubmit"
+        >交卷</n-button
+      >
     </div>
     <div id="examing-home-question" class="main">
       <QuestionView />