mirror of
https://github.com/jiangrui1994/CloudSaver.git
synced 2026-01-12 16:18:45 +08:00
refactor:优化移动端页面
This commit is contained in:
@@ -14,3 +14,16 @@ export function isMobileDevice() {
|
||||
window.innerWidth <= 768
|
||||
);
|
||||
}
|
||||
|
||||
export function throttle<T extends (...args: any[]) => any>(fn: T, delay: number): T {
|
||||
let lastTime = 0;
|
||||
|
||||
return function (this: any, ...args: Parameters<T>) {
|
||||
const now = Date.now();
|
||||
|
||||
if (now - lastTime >= delay) {
|
||||
fn.apply(this, args);
|
||||
lastTime = now;
|
||||
}
|
||||
} as T;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user