diff --git a/pages/study/exam.vue b/pages/study/exam.vue index d1bc2af..b7d9651 100644 --- a/pages/study/exam.vue +++ b/pages/study/exam.vue @@ -92,8 +92,8 @@ if(this.examId){ this.loadExamInfo(); } - this.debouncedPresent = this.debounce(this.present, 500); - this.confirmStop = this.debounce(this.submitTest,500) + this.debouncedPresent = this.throttle(this.present, 5000); + this.confirmStop = this.throttle(this.submitTest,5000) }, methods: { changeTimer(){ @@ -352,16 +352,16 @@ } }) }, - debounce(func, delay) { - let timerId; - return function (...args) { - if (timerId) clearTimeout(timerId); - timerId = setTimeout(() => { - func.apply(this, args); - timerId = null; - }, delay); - }; - }, + throttle(func, delay) { + let lastExecTime = 0; + return function (...args) { + const now = Date.now(); + if (now - lastExecTime >= delay) { + func.apply(this, args); + lastExecTime = now; + } + }; + }, present(){ let $this=this; let score=this.countTest();