From 0d18041037c762a0fbeb3cbd831001c4ea8bcbf3 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Tue, 12 May 2026 08:48:55 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BD=BF=E7=94=A8=20Intl.DateTimeF?= =?UTF-8?q?ormat=20=E7=94=9F=E6=88=90=E6=97=B6=E9=97=B4=E6=88=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue.config.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/vue.config.js b/vue.config.js index ad9dbf7..fa26f85 100644 --- a/vue.config.js +++ b/vue.config.js @@ -217,16 +217,15 @@ class VersionInjectPlugin { console.log(`[H5Zip] 输出目录名正确: ${outputDirName}`); } - // 上海时区时间戳格式: 20260511_1058 - const now = new Date(); - const shanghaiOffset = 8 * 60; - const shanghaiTime = new Date(now.getTime() + shanghaiOffset * 60 * 1000); - const y = shanghaiTime.getFullYear(); - const M = String(shanghaiTime.getMonth() + 1).padStart(2, '0'); - const d = String(shanghaiTime.getDate()).padStart(2, '0'); - const h = String(shanghaiTime.getHours()).padStart(2, '0'); - const m = String(shanghaiTime.getMinutes()).padStart(2, '0'); - const ts = `${y}${M}${d}_${h}${m}`; + // 标准时区时间戳格式: 20260511_1058 + const fmt = new Intl.DateTimeFormat('en-CA', { + timeZone: 'Asia/Shanghai', + year: 'numeric', month: '2-digit', day: '2-digit', + hour: '2-digit', minute: '2-digit', hour12: false + }); + const parts = fmt.formatToParts(new Date()); + const get = (t) => parts.find(p => p.type === t).value; + const ts = `${get('year')}${get('month')}${get('day')}_${get('hour')}${get('minute')}`; const zipFileName = `${outputDirName}-${this._cachedCommitId}-${ts}.zip`; const zipFilePath = path.join(h5Dir, zipFileName);