From c7fd6ffb0e6f4092cd69189450767fca7fcb4f2f Mon Sep 17 00:00:00 2001 From: boisduval Date: Thu, 23 Apr 2026 17:25:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E5=87=BD=E6=95=B0=E7=9A=84=E7=A9=BA?= =?UTF-8?q?=E5=80=BC=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 当传入的时间参数为 undefined、null 或空字符串时,直接返回空字符串而不是继续执行格式化逻辑,避免无效的时间值导致程序错误。 --- packages/@core/base/shared/src/utils/date.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/@core/base/shared/src/utils/date.ts b/packages/@core/base/shared/src/utils/date.ts index c68c33850..784b9778e 100644 --- a/packages/@core/base/shared/src/utils/date.ts +++ b/packages/@core/base/shared/src/utils/date.ts @@ -20,6 +20,9 @@ type Format = | (string & {}); export function formatDate(time?: FormatDate, format: Format = 'YYYY-MM-DD') { + if (time === undefined || time === null || time === '') { + return ''; + } try { const date = dayjs.isDayjs(time) ? time : dayjs(time); if (!date.isValid()) {