From 483f44cb0e6aefd6bcbbad0daa15b6a570254402 Mon Sep 17 00:00:00 2001 From: zhangsir Date: Mon, 6 May 2024 15:08:00 +0800 Subject: [PATCH] =?UTF-8?q?5=E7=A7=92=E5=86=85=E7=82=B9=E5=87=BB=E5=8F=AA?= =?UTF-8?q?=E7=94=9F=E6=95=88=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/study/exam.vue | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pages/study/exam.vue b/pages/study/exam.vue index d1bc2af..abcc0a2 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,14 +352,14 @@ } }) }, - debounce(func, delay) { - let timerId; + throttle(func, delay) { + let lastExecTime = 0; return function (...args) { - if (timerId) clearTimeout(timerId); - timerId = setTimeout(() => { + const now = Date.now(); + if (now - lastExecTime >= delay) { func.apply(this, args); - timerId = null; - }, delay); + lastExecTime = now; + } }; }, present(){