فهرست منبع

feat: 定时逻辑陶正

zhangjie 4 روز پیش
والد
کامیت
a1a20e9da2
1فایلهای تغییر یافته به همراه10 افزوده شده و 2 حذف شده
  1. 10 2
      src/components/shared/ScoringPanelWithConfirm.vue

+ 10 - 2
src/components/shared/ScoringPanelWithConfirm.vue

@@ -59,8 +59,10 @@ import bus from '@/utils/bus'
 import { useRoute } from 'vue-router'
 import type { ExtractApiResponse } from '@/api/api'
 import useMarkStore from '@/store/mark'
+import useSpentTime from '@/hooks/useSpentTime'
 
 const route = useRoute()
+const { getSpentTime, resume } = useSpentTime()
 
 interface MarkDelayItem {
   startScore: number
@@ -179,8 +181,9 @@ const onSubmit = (data: ExtractApiResponse<'getQuestionStruct'>) => {
           return 0
         }
       }
-
-      markStore.startCountdown(getMarkLevelSpeedLimit(totalScore.value))
+      const markLevelSpeedLimit = getMarkLevelSpeedLimit(totalScore.value)
+      const waitTime = markLevelSpeedLimit - Math.round(getSpentTime() / 1000)
+      markStore.startCountdown(Math.max(waitTime, 0))
     }, 10)
   })
 }
@@ -208,6 +211,11 @@ const onViewPapers = () => {
   previewModalVisible.value = true
 }
 
+watch(props.id, (newVal, oldVal) => {
+  if (newVal === oldVal) return
+  resume()
+})
+
 onUnmounted(() => {
   if (!props.showLimitTime) return
   markStore.clearCountdown()