fix time format
This commit is contained in:
21
src/App.vue
21
src/App.vue
@@ -270,7 +270,7 @@ let toastTimer = null;
|
|||||||
const hasStorageDanger = computed(() => report.value?.storage?.some(d => d.is_danger) || false);
|
const hasStorageDanger = computed(() => report.value?.storage?.some(d => d.is_danger) || false);
|
||||||
const isReportValid = computed(() => report.value && (report.value.hardware || report.value.storage));
|
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 calculatePercent(used, total) { return (!total || total === 0) ? 0 : Math.round((used / total) * 100); }
|
||||||
function getProgressStyle(used, total) {
|
function getProgressStyle(used, total) {
|
||||||
const percent = calculatePercent(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 getBatteryColor(p) { return p < 50 ? '#ff4757' : (p < 80 ? '#ffa502' : '#2ed573'); }
|
||||||
function formatTime(t) { return !t ? "Unknown Time" : t.replace('T', ' ').substring(0, 19); }
|
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() {
|
async function exportReport() {
|
||||||
if (!isReportValid.value) return;
|
if (!isReportValid.value) return;
|
||||||
@@ -323,7 +334,7 @@ async function loadMinidumps() { bsodLoading.value = true; try { bsodList.value
|
|||||||
async function analyzeBsod(file) {
|
async function analyzeBsod(file) {
|
||||||
if (bsodAnalyzing.value) return;
|
if (bsodAnalyzing.value) return;
|
||||||
|
|
||||||
// [新增] 提前检查文件大小,避免读取几百MB的 Kernel Dump 导致卡死
|
// 提前检查文件大小,避免读取几百MB的 Kernel Dump 导致卡死
|
||||||
if (file.fileRef && file.fileRef.size > 5 * 1024 * 1024) { // 5MB 限制
|
if (file.fileRef && file.fileRef.size > 5 * 1024 * 1024) { // 5MB 限制
|
||||||
triggerToast('文件过大', '仅支持 <5MB 的 Minidump 文件,不支持完整的 MEMORY.DMP', 'error');
|
triggerToast('文件过大', '仅支持 <5MB 的 Minidump 文件,不支持完整的 MEMORY.DMP', 'error');
|
||||||
return;
|
return;
|
||||||
@@ -346,7 +357,7 @@ async function analyzeBsod(file) {
|
|||||||
bsodResult.value = await invoke('analyze_minidump', { filepath: file.path });
|
bsodResult.value = await invoke('analyze_minidump', { filepath: file.path });
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// [修改] 优化错误提示:拦截 "Header mismatch" 等晦涩的报错
|
// 优化错误提示
|
||||||
let errorMsg = e;
|
let errorMsg = e;
|
||||||
if (typeof e === 'string') {
|
if (typeof e === 'string') {
|
||||||
if (e.includes("Header mismatch")) {
|
if (e.includes("Header mismatch")) {
|
||||||
@@ -371,7 +382,6 @@ function handleBsodFileImport(event) {
|
|||||||
for (let i = files.length - 1; i >= 0; i--) {
|
for (let i = files.length - 1; i >= 0; i--) {
|
||||||
const file = files[i];
|
const file = files[i];
|
||||||
|
|
||||||
// [新增] 简单的后缀名检查
|
|
||||||
if (!file.name.toLowerCase().endsWith('.dmp')) {
|
if (!file.name.toLowerCase().endsWith('.dmp')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -380,7 +390,8 @@ function handleBsodFileImport(event) {
|
|||||||
filename: file.name,
|
filename: file.name,
|
||||||
path: `imported-${file.name}-${Date.now()}-${i}`,
|
path: `imported-${file.name}-${Date.now()}-${i}`,
|
||||||
size_kb: Math.round(file.size / 1024),
|
size_kb: Math.round(file.size / 1024),
|
||||||
created_time: new Date(file.lastModified).toLocaleString(),
|
// [修改] 使用自定义格式化函数,替代 toLocaleString
|
||||||
|
created_time: formatJsDate(new Date(file.lastModified)),
|
||||||
fileRef: file
|
fileRef: file
|
||||||
};
|
};
|
||||||
bsodList.value.unshift(newItem);
|
bsodList.value.unshift(newItem);
|
||||||
|
|||||||
Reference in New Issue
Block a user