feat: 本次提交更新内容如下
定版本转移2025年7月17日
This commit is contained in:
@@ -1,46 +0,0 @@
|
||||
// 通用工具函数
|
||||
export const cn = (...classes: (string | undefined | null | false)[]) => {
|
||||
return classes.filter(Boolean).join(' ');
|
||||
};
|
||||
|
||||
// 格式化日期
|
||||
export const formatDate = (date: string | Date) => {
|
||||
return new Date(date).toLocaleDateString('zh-CN');
|
||||
};
|
||||
|
||||
// 格式化时间
|
||||
export const formatTime = (date: string | Date) => {
|
||||
return new Date(date).toLocaleTimeString('zh-CN');
|
||||
};
|
||||
|
||||
// 格式化日期时间
|
||||
export const formatDateTime = (date: string | Date) => {
|
||||
return new Date(date).toLocaleString('zh-CN');
|
||||
};
|
||||
|
||||
// 防抖函数
|
||||
export const debounce = <T extends (...args: any[]) => any>(
|
||||
func: T,
|
||||
wait: number
|
||||
): ((...args: Parameters<T>) => void) => {
|
||||
let timeout: NodeJS.Timeout;
|
||||
return (...args: Parameters<T>) => {
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => func(...args), wait);
|
||||
};
|
||||
};
|
||||
|
||||
// 节流函数
|
||||
export const throttle = <T extends (...args: any[]) => any>(
|
||||
func: T,
|
||||
wait: number
|
||||
): ((...args: Parameters<T>) => void) => {
|
||||
let inThrottle: boolean;
|
||||
return (...args: Parameters<T>) => {
|
||||
if (!inThrottle) {
|
||||
func(...args);
|
||||
inThrottle = true;
|
||||
setTimeout(() => (inThrottle = false), wait);
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user