完整的管理系统,包含账户管理、卡片管理、套餐管理、财务管理等功能模块。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
29 lines
758 B
TypeScript
29 lines
758 B
TypeScript
/**
|
|
* 数据格式化相关工具函数
|
|
*/
|
|
|
|
// 时间戳转时间
|
|
export function timestampToTime(timestamp: number = Date.now(), isMs: boolean = true): string {
|
|
const date = new Date(isMs ? timestamp : timestamp * 1000)
|
|
return date.toISOString().replace('T', ' ').slice(0, 19)
|
|
}
|
|
|
|
// 数字格式化(千位分隔符)
|
|
export function commafy(num: number): string {
|
|
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
|
}
|
|
|
|
// 生成随机数
|
|
export function randomNum(min: number, max?: number): number {
|
|
if (max === undefined) {
|
|
max = min
|
|
min = 0
|
|
}
|
|
return Math.floor(Math.random() * (max - min + 1)) + min
|
|
}
|
|
|
|
// 移除HTML标签
|
|
export function removeHtmlTags(str: string = ''): string {
|
|
return str.replace(/<[^>]*>/g, '')
|
|
}
|