考试提交改为5秒内只执行一次

This commit is contained in:
zhangsir
2024-05-07 08:48:14 +08:00
parent 18461264c5
commit e04f249245

View File

@@ -408,17 +408,18 @@ export default {
this.curIndex++; this.curIndex++;
this.curItem=this.paper.items[this.curIndex]; this.curItem=this.paper.items[this.curIndex];
}, },
debounce(func, delay) { throttle(func, delay) {
let timerId; let lastExecTime = 0;
return function (...args) { return function (...args) {
if (timerId) clearTimeout(timerId); const now = Date.now();
timerId = setTimeout(() => { if (now - lastExecTime >= delay) {
func.apply(this, args); func.apply(this, args);
timerId = null; lastExecTime = now;
}, delay); }
}; };
}, },
present(){ //提交前处理 present(){ //提交前处理
console.log('ssss')
let $this=this; let $this=this;
let score=this.countTest(); let score=this.countTest();
console.log('score='+score); console.log('score='+score);
@@ -600,7 +601,7 @@ export default {
}, },
}, },
created() { created() {
this.debouncedPresent = this.debounce(this.present, 500); this.debouncedPresent = this.throttle(this.present, 5000);
}, },
} }
</script> </script>