This commit is contained in:
zhu
2026-05-09 15:21:39 +08:00
parent 521eea47d2
commit 2c038e8c0c
8 changed files with 297 additions and 38 deletions

14
src/utils/format.ts Normal file
View File

@@ -0,0 +1,14 @@
/**
* 格式化秒为hh:mm:ss
*/
export function formatSecond(seconds: number) {
if (seconds <= 0) return "Expired";
const d = Math.floor(seconds / (3600 * 24));
const h = Math.floor((seconds % (3600 * 24)) / 3600);
const m = Math.floor((seconds % 3600) / 60);
if (d > 0) return `${d}d ${h}h`; // 大于1天显示 天+小时
if (h > 0) return `${h}h ${m}m`; // 小于1天显示 小时+分钟
return `<1h`; // 小于1小时显示 <1h
}