feat(web): separate build sources and localize time
ci/woodpecker/push/web-build Pipeline was successful
ci/woodpecker/push/ci Pipeline was successful

This commit is contained in:
justme committed 2026-10-12 16:50:15 +08:00
1 parent 89cd92f7ee
commit 10aa0304e4
9 files changed
+60 -17

No files matched your search

+37 -1
View File
@@ -1 +1,37 @@
export const buildInfo = __WEBDROP_BUILD_INFO__;
const shanghaiTime = new Intl.DateTimeFormat('en-CA', {
timeZone: 'Asia/Shanghai',
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
hourCycle: 'h23',
});
function shortCommit(commit: string): string {
return commit === 'unknown' ? commit : commit.slice(0, 7);
}
function knownTag(tag: string): string {
return tag === 'unknown' ? '' : tag;
}
function formatShanghai(iso: string): string {
const date = new Date(iso);
if (Number.isNaN(date.getTime())) return '未知';
const parts = Object.fromEntries(shanghaiTime.formatToParts(date).map(({ type, value }) => [type, value]));
return `${parts.year}-${parts.month}-${parts.day} ${parts.hour}:${parts.minute}`;
}
const source = __WEBDROP_BUILD_INFO__;
export const buildInfo = {
frontendVersion: source.frontendVersion,
frontendCommit: shortCommit(source.frontendCommit),
frontendTag: knownTag(source.frontendTag),
backendCommit: shortCommit(source.backendCommit),
backendTag: knownTag(source.backendTag),
builtAt: source.builtAt,
builtAtShanghai: formatShanghai(source.builtAt),
};