From 9e6ad62a91c8ab197b3fda287aa721cda742b13a Mon Sep 17 00:00:00 2001 From: Julian Freeman Date: Wed, 26 Nov 2025 19:21:10 -0400 Subject: [PATCH] fix time format --- src/App.vue | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/App.vue b/src/App.vue index e5f618a..78bc2d3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -270,7 +270,7 @@ let toastTimer = null; const hasStorageDanger = computed(() => report.value?.storage?.some(d => d.is_danger) || false); const isReportValid = computed(() => report.value && (report.value.hardware || report.value.storage)); -// --- 辅助函数 (保留) --- +// --- 辅助函数 --- function calculatePercent(used, total) { return (!total || total === 0) ? 0 : Math.round((used / total) * 100); } function getProgressStyle(used, total) { const percent = calculatePercent(used, total); @@ -280,6 +280,17 @@ function getProgressStyle(used, total) { function getBatteryColor(p) { return p < 50 ? '#ff4757' : (p < 80 ? '#ffa502' : '#2ed573'); } function formatTime(t) { return !t ? "Unknown Time" : t.replace('T', ' ').substring(0, 19); } +// [新增] JS日期格式化函数:yyyy-MM-dd HH:mm:ss +function formatJsDate(date) { + const y = date.getFullYear(); + const m = String(date.getMonth() + 1).padStart(2, '0'); + const d = String(date.getDate()).padStart(2, '0'); + const h = String(date.getHours()).padStart(2, '0'); + const min = String(date.getMinutes()).padStart(2, '0'); + const s = String(date.getSeconds()).padStart(2, '0'); + return `${y}-${m}-${d} ${h}:${min}:${s}`; +} + // --- 概览:导出/导入 --- async function exportReport() { if (!isReportValid.value) return; @@ -323,7 +334,7 @@ async function loadMinidumps() { bsodLoading.value = true; try { bsodList.value async function analyzeBsod(file) { if (bsodAnalyzing.value) return; - // [新增] 提前检查文件大小,避免读取几百MB的 Kernel Dump 导致卡死 + // 提前检查文件大小,避免读取几百MB的 Kernel Dump 导致卡死 if (file.fileRef && file.fileRef.size > 5 * 1024 * 1024) { // 5MB 限制 triggerToast('文件过大', '仅支持 <5MB 的 Minidump 文件,不支持完整的 MEMORY.DMP', 'error'); return; @@ -346,7 +357,7 @@ async function analyzeBsod(file) { bsodResult.value = await invoke('analyze_minidump', { filepath: file.path }); } } catch (e) { - // [修改] 优化错误提示:拦截 "Header mismatch" 等晦涩的报错 + // 优化错误提示 let errorMsg = e; if (typeof e === 'string') { if (e.includes("Header mismatch")) { @@ -371,7 +382,6 @@ function handleBsodFileImport(event) { for (let i = files.length - 1; i >= 0; i--) { const file = files[i]; - // [新增] 简单的后缀名检查 if (!file.name.toLowerCase().endsWith('.dmp')) { continue; } @@ -380,7 +390,8 @@ function handleBsodFileImport(event) { filename: file.name, path: `imported-${file.name}-${Date.now()}-${i}`, size_kb: Math.round(file.size / 1024), - created_time: new Date(file.lastModified).toLocaleString(), + // [修改] 使用自定义格式化函数,替代 toLocaleString + created_time: formatJsDate(new Date(file.lastModified)), fileRef: file }; bsodList.value.unshift(newItem);