Files
youlai-app/src/utils/index.ts
Mickey wu 325316d0b0 fix: 修复类型定义及多处逻辑缺陷
- 补充字典项备注字段及部门排序必填约束
- 使用 Ref/ComputedRef 替代 ReturnType 简化类型
- 兜底胶囊按钮默认尺寸,避免获取失败时导航栏异常
- 移除不可靠的新版 API 降级调用,统一使用 getSystemInfoSync
- 修复防抖函数定时器未清空及类型不严谨问题
2026-05-25 21:55:04 +08:00

19 lines
451 B
TypeScript

/**
* 防抖函数
* @param fn 函数
* @param delay 延迟时间
* @returns
*/
const debounce = <T extends (...args: any[]) => any>(fn: T, delay: number) => {
let timer: ReturnType<typeof setTimeout> | null = null;
return function (this: any, ...args: Parameters<T>) {
if (timer !== null) clearTimeout(timer);
timer = setTimeout(() => {
fn.apply(this, args);
timer = null;
}, delay);
};
};
export { debounce };