From 9e00af1905a869b1c62622c549c23d2d0284c4b3 Mon Sep 17 00:00:00 2001 From: "DESKTOP-JKIE562\\PC" <1013397054@qq.com> Date: Wed, 25 Nov 2026 16:10:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9F=B9=E8=AE=AD=E7=AD=BE=E5=88=B0):?= =?UTF-8?q?=E7=AD=BE=E5=88=B0=E6=98=8E=E7=BB=86=E5=88=97=E5=8F=A3=E5=BE=84?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E2=80=94=E2=80=94=E5=AD=A6=E5=91=98=E5=88=97?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E3=80=8C=E5=A7=93=E5=90=8D=20=E5=B7=A5?= =?UTF-8?q?=E5=8F=B7=E3=80=8D=E3=80=81=E7=AD=BE=E5=88=B0=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=8C=97=E4=BA=AC=E6=97=B6=E9=97=B4=E6=97=B6?= =?UTF-8?q?=E5=88=86=E7=A7=92(=E6=96=B0=E5=A2=9E=20fmtBeijingTimeSec)?= =?UTF-8?q?=E3=80=81=E6=96=B9=E5=BC=8F=E5=88=97=E6=98=BE=E7=A4=BA=E4=B8=AD?= =?UTF-8?q?=E6=96=87(=E4=BC=81=E5=BE=AE=E6=89=AB=E7=A0=81/=E4=BB=A3?= =?UTF-8?q?=E6=89=AB=E7=A0=81=E8=A1=A5=E5=BD=95);=E4=BB=A3=E6=89=AB?= =?UTF-8?q?=E7=A0=81=E8=A1=A5=E5=BD=95=E5=AD=A6=E5=91=98=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=98=BE=E7=A4=BA=E5=A7=93=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/utils/datetime.ts | 19 +++++++++++++++ .../views/training/components/SignPanel.vue | 24 ++++++++++++------- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/frontend/src/utils/datetime.ts b/frontend/src/utils/datetime.ts index 8719a1d..a041797 100644 --- a/frontend/src/utils/datetime.ts +++ b/frontend/src/utils/datetime.ts @@ -17,6 +17,17 @@ const BEIJING_CLOCK = new Intl.DateTimeFormat('zh-CN', { hour12: false, }) +const BEIJING_DATETIME_SEC = new Intl.DateTimeFormat('zh-CN', { + timeZone: 'Asia/Shanghai', + year: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + hour12: false, +}) + /** fmtBeijingTime 任意时间戳 → 北京时间「YYYY/MM/DD HH:mm」(无秒);空/非法输入返回空串。 */ export function fmtBeijingTime(raw: string | number | Date | null | undefined): string { if (raw === null || raw === undefined || raw === '') return '' @@ -32,3 +43,11 @@ export function fmtBeijingClock(raw: string | number | Date | null | undefined): if (Number.isNaN(date.getTime())) return '' return BEIJING_CLOCK.format(date) } + +/** fmtBeijingTimeSec 北京时间「YYYY/MM/DD HH:mm:ss」(带秒;签到明细等需秒级精度的场景)。 */ +export function fmtBeijingTimeSec(raw: string | number | Date | null | undefined): string { + if (raw === null || raw === undefined || raw === '') return '' + const date = raw instanceof Date ? raw : new Date(raw) + if (Number.isNaN(date.getTime())) return '' + return BEIJING_DATETIME_SEC.format(date) +} diff --git a/frontend/src/views/training/components/SignPanel.vue b/frontend/src/views/training/components/SignPanel.vue index d67de14..e6cb7bb 100644 --- a/frontend/src/views/training/components/SignPanel.vue +++ b/frontend/src/views/training/components/SignPanel.vue @@ -114,6 +114,8 @@ + +