This commit is contained in:
FalconFly 2024-01-09 11:10:57 +08:00
commit a8d947bc7f
4 changed files with 47 additions and 0 deletions

25
JS/Debounce.js Normal file
View File

@ -0,0 +1,25 @@
/**
* 防抖方法实例化一个Debounce对象然后调用run方法执行防抖函数
*/
class Debounce {
constructor(time) {
//执行间隔
this.timeout = time;
//计时器
this.timer = null;
}
//等待时间结束后执行方法
run(func, ...args) {
if (this.timer) {
clearTimeout(this.timer);
this.timer = null;
}
if (this.timer == null) {
this.timer = setTimeout(() => {
func(...args);
this.timer = null;
}, this.timeout);
}
}
}

20
JS/DebounceImmediately.js Normal file
View File

@ -0,0 +1,20 @@
/**
* DebounceImmediately跟Debounce的区别是会首先立即执行一次
*/
class DebounceImmediately {
constructor(time) {
//执行间隔
this.timeout = time;
//计时器
this.timer = null;
}
run(func, ...args) {
if (this.timer) {
return;
}
this.timer = setTimeout(() => {
this.timer = null;
}, this.timeout);
func(...args);
}
}

1
JS/print.min.css vendored Normal file
View File

@ -0,0 +1 @@
.printModal{font-family:sans-serif;display:flex;text-align:center;font-weight:300;font-size:30px;left:0;top:0;position:absolute;color:#0460b5;width:100%;height:100%;background-color:hsla(0,0%,100%,.91)}.printClose{position:absolute;right:10px;top:10px}.printClose:before{content:"\00D7";font-family:Helvetica Neue,sans-serif;font-weight:100;line-height:1px;padding-top:.5em;display:block;font-size:2em;text-indent:1px;overflow:hidden;height:1.25em;width:1.25em;text-align:center;cursor:pointer}

1
JS/print.min.js vendored Normal file

File diff suppressed because one or more lines are too long