提交 d8142220 authored 作者: 王鹏飞's avatar 王鹏飞

fix: 修改倒计时时间错误的问题,缓存试卷时间修改为5-10秒之间随机提交

上级 8323b7ca
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
import * as api from '@/api/base.js' import * as api from '@/api/base.js'
import QuestionList from '@/components/QuestionList.vue' import QuestionList from '@/components/QuestionList.vue'
import QuestionNum from '@/components/QuestionNum.vue' import QuestionNum from '@/components/QuestionNum.vue'
import { merge } from 'lodash-es' import { merge, random } from 'lodash-es'
export default { export default {
components: { QuestionList, QuestionNum }, components: { QuestionList, QuestionNum },
...@@ -230,10 +230,12 @@ export default { ...@@ -230,10 +230,12 @@ export default {
}, },
// 自动缓存试卷 // 自动缓存试卷
setCacheExamTimer() { setCacheExamTimer() {
// 10 秒缓存一次试卷 // 5-10 秒缓存一次试卷
const interval = random(5000, 10000)
console.log(interval)
this.cacheExamTimer = setInterval(() => { this.cacheExamTimer = setInterval(() => {
this.postCacheExam() this.postCacheExam()
}, 5000) }, interval)
}, },
// 倒计时 // 倒计时
setCountdownTimer() { setCountdownTimer() {
...@@ -246,7 +248,7 @@ export default { ...@@ -246,7 +248,7 @@ export default {
this.examTime = '00:00:00 倒计时' this.examTime = '00:00:00 倒计时'
} else { } else {
const leftTime = parseInt(countTime / 1000) const leftTime = parseInt(countTime / 1000)
const h = parseInt((leftTime / (60 * 60)) % 24) const h = parseInt((leftTime / (60 * 60)))
.toString() .toString()
.padStart(2, '0') .padStart(2, '0')
const m = parseInt((leftTime / 60) % 60) const m = parseInt((leftTime / 60) % 60)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论