fix: complete first version issue remediation

This commit is contained in:
hectorzhao
2026-07-11 10:14:37 +08:00
parent 709ac97764
commit 208a6c23f8
73 changed files with 1549 additions and 245 deletions
+7
View File
@@ -0,0 +1,7 @@
export function formatDateTime(value?: string | Date | null) {
if (!value) return '-';
const date = new Date(value);
if (Number.isNaN(date.getTime())) return '-';
const pad = (part: number) => String(part).padStart(2, '0');
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
}
+13
View File
@@ -0,0 +1,13 @@
export function displayFileName(value: string) {
if (!value || ![...value].some((character) => character.charCodeAt(0) > 0x7f) || [...value].some((character) => character.charCodeAt(0) > 0xff)) {
return value;
}
try {
const bytes = Uint8Array.from(value, (character) => character.charCodeAt(0));
const decoded = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
return decoded === value ? value : decoded;
} catch {
return value;
}
}