fix: 重命名 utils.ts 为 detailUtils.ts 避免与 utils/ 目录冲突

This commit is contained in:
2026-07-27 15:29:17 +08:00
parent 078c56ef62
commit fe1bcf67df
@@ -0,0 +1,27 @@
/** 格式化时长(秒 → "MM:SS" */
export const formatDuration = (seconds: number): string => {
if (!seconds || seconds <= 0) return "00:00"
const m = Math.floor(seconds / 60)
const s = Math.floor(seconds % 60)
return `${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`
}
/** 格式化文件大小(MB */
export const formatFileSize = (mb: number): string => {
if (!mb || mb <= 0) return "-"
if (mb < 1024) return `${mb.toFixed(1)} MB`
return `${(mb / 1024).toFixed(2)} GB`
}
/** 格式化日期 */
export const formatDate = (dateStr: string): string => {
if (!dateStr) return "-"
const d = new Date(dateStr)
return d.toLocaleDateString("zh-CN", {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
})
}