From 304cdaacc0eabd4648bc2c7f02450d8f16df5351 Mon Sep 17 00:00:00 2001 From: Fe <677@luqiqi.com> Date: Tue, 23 Sep 2025 02:23:15 +0000 Subject: [PATCH] =?UTF-8?q?update=20web/src/utils/common.ts.=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=A0=BC=E5=BC=8F=E5=8C=96=E6=A0=87=E5=87=86=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E7=9A=84=E8=BF=94=E5=9B=9E=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fe <677@luqiqi.com> --- web/src/utils/common.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/src/utils/common.ts b/web/src/utils/common.ts index bf22ca7fa..179ba3f0a 100644 --- a/web/src/utils/common.ts +++ b/web/src/utils/common.ts @@ -329,7 +329,11 @@ export const timeFormat = (dateTime: string | number | null = null, fmt = 'yyyy- dateTime = +dateTime * 1000 } - const date = new Date(Number(dateTime)) + let date = new Date(dateTime) + // 检查日期是否有效,如果无效则尝试转换为数字后再创建 + if (isNaN(date.getTime())) { + date = new Date(Number(dateTime)) + } let ret const opt: anyObj = { 'y+': date.getFullYear().toString(), // 年 -- Gitee