From d7d445617fa0d733637ba521b56791bbe7b51996 Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Thu, 4 Sep 2025 10:18:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20format=20time=20=E5=B7=B2=E7=BB=8F?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=88=B0=20@vben/utils?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-ele/src/utils/formatTime.ts | 32 ---------------------------- apps/web-ele/src/utils/index.ts | 1 - 2 files changed, 33 deletions(-) delete mode 100644 apps/web-ele/src/utils/formatTime.ts diff --git a/apps/web-ele/src/utils/formatTime.ts b/apps/web-ele/src/utils/formatTime.ts deleted file mode 100644 index c2f8698e..00000000 --- a/apps/web-ele/src/utils/formatTime.ts +++ /dev/null @@ -1,32 +0,0 @@ -// TODO @xingyu:要不要融合到 /packages/@core/base/shared/src/utils/time.ts 里? -/** - * 将毫秒,转换成时间字符串。例如说,xx 分钟 - * - * @param ms 毫秒 - * @returns {string} 字符串 - */ -export function formatPast2(ms: number): string { - // 定义时间单位常量,便于维护 - const SECOND = 1000; - const MINUTE = 60 * SECOND; - const HOUR = 60 * MINUTE; - const DAY = 24 * HOUR; - - // 计算各时间单位 - const day = Math.floor(ms / DAY); - const hour = Math.floor((ms % DAY) / HOUR); - const minute = Math.floor((ms % HOUR) / MINUTE); - const second = Math.floor((ms % MINUTE) / SECOND); - - // 根据时间长短返回不同格式 - if (day > 0) { - return `${day} 天${hour} 小时 ${minute} 分钟`; - } - if (hour > 0) { - return `${hour} 小时 ${minute} 分钟`; - } - if (minute > 0) { - return `${minute} 分钟`; - } - return second > 0 ? `${second} 秒` : `${0} 秒`; -} diff --git a/apps/web-ele/src/utils/index.ts b/apps/web-ele/src/utils/index.ts index da4b8f04..534c67e5 100644 --- a/apps/web-ele/src/utils/index.ts +++ b/apps/web-ele/src/utils/index.ts @@ -1,6 +1,5 @@ export * from './bean'; export * from './dict'; -export * from './formatTime'; export * from './formCreate'; export * from './rangePickerProps'; export * from './routerHelper';