考试5秒内只能提交一次

This commit is contained in:
zhangsir
2024-05-06 15:42:58 +08:00
parent efa84f6703
commit f3e9168e76

View File

@@ -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();