考试提交改为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.curItem=this.paper.items[this.curIndex];
},
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(){ //提交前处理
console.log('ssss')
let $this=this;
let score=this.countTest();
console.log('score='+score);
@@ -600,7 +601,7 @@ export default {
},
},
created() {
this.debouncedPresent = this.debounce(this.present, 500);
this.debouncedPresent = this.throttle(this.present, 5000);
},
}
</script>