2
0
Эх сурвалжийг харах

feat: 评卷任务结束后手动调用一次获取任务

chenhao 2 жил өмнө
parent
commit
a9c178045d

+ 9 - 6
src/features/mark/Mark.vue

@@ -180,18 +180,19 @@ async function updateTask() {
   }
 }
 
-// 5秒更新一次tasks
-addInterval(() => {
-  // console.log("get task", store.tasks);
+function nextTask() {
   // 正在预绘制中,则不要再取任务,以免拖慢当前任务的绘制
   if (!preDrawing) {
     if (store.tasks.length < (store.setting.prefetchCount ?? 3)) {
       // 回看打开时,停止取任务
       if (!store.historyOpen)
-        updateTask().catch((e) => console.log("定时获取任务出错", e));
+        return updateTask().catch((e) => console.log("定时获取任务出错", e));
     }
   }
-}, 5 * 1000);
+}
+
+// 5秒更新一次tasks
+addInterval(nextTask, 5 * 1000);
 
 // 不需要
 // addInterval(() => {
@@ -203,7 +204,7 @@ onMounted(async () => {
   await updateSetting();
   await updateStatus();
   await updateGroups();
-  await updateTask();
+  await nextTask();
 });
 
 const __debounceUpdate = debounce(() => {
@@ -375,6 +376,8 @@ const saveTaskToServer = async () => {
   if (!res) return;
   // 故意不在此处同步等待,因为不必等待
   updateStatus().catch((e) => console.log("保存任务后获取status出错", e));
+  // 获取下一个任务
+  void nextTask();
   if (res.data.success && store.currentTask) {
     void message.success({ content: "保存成功", key: mkey, duration: 2 });
     if (!store.historyOpen) {