import minidump analyze
This commit is contained in:
37
src/App.vue
37
src/App.vue
@@ -322,6 +322,13 @@ async function loadMinidumps() { bsodLoading.value = true; try { bsodList.value
|
||||
|
||||
async function analyzeBsod(file) {
|
||||
if (bsodAnalyzing.value) return;
|
||||
|
||||
// [新增] 提前检查文件大小,避免读取几百MB的 Kernel Dump 导致卡死
|
||||
if (file.fileRef && file.fileRef.size > 5 * 1024 * 1024) { // 5MB 限制
|
||||
triggerToast('文件过大', '仅支持 <5MB 的 Minidump 文件,不支持完整的 MEMORY.DMP', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
selectedBsod.value = file;
|
||||
bsodResult.value = null;
|
||||
bsodAnalyzing.value = true;
|
||||
@@ -339,7 +346,16 @@ async function analyzeBsod(file) {
|
||||
bsodResult.value = await invoke('analyze_minidump', { filepath: file.path });
|
||||
}
|
||||
} catch (e) {
|
||||
triggerToast('分析失败', e, 'error');
|
||||
// [修改] 优化错误提示:拦截 "Header mismatch" 等晦涩的报错
|
||||
let errorMsg = e;
|
||||
if (typeof e === 'string') {
|
||||
if (e.includes("Header mismatch")) {
|
||||
errorMsg = "格式错误:这不是有效的 Minidump。请勿上传 MEMORY.DMP (完整转储)。";
|
||||
} else if (e.includes("No Exception Stream")) {
|
||||
errorMsg = "无法提取错误:该文件可能已损坏或不包含异常流。";
|
||||
}
|
||||
}
|
||||
triggerToast('分析失败', errorMsg, 'error');
|
||||
} finally {
|
||||
bsodAnalyzing.value = false;
|
||||
}
|
||||
@@ -352,26 +368,31 @@ function handleBsodFileImport(event) {
|
||||
if (!files || files.length === 0) return;
|
||||
|
||||
let importedCount = 0;
|
||||
// 倒序遍历,这样添加到数组头部后顺序是正确的
|
||||
for (let i = files.length - 1; i >= 0; i--) {
|
||||
const file = files[i];
|
||||
// 构造一个符合列表格式的虚拟对象
|
||||
|
||||
// [新增] 简单的后缀名检查
|
||||
if (!file.name.toLowerCase().endsWith('.dmp')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const newItem = {
|
||||
filename: file.name,
|
||||
// 使用一个特殊的 path 标识,防止 key 冲突
|
||||
path: `imported-${file.name}-${Date.now()}-${i}`,
|
||||
size_kb: Math.round(file.size / 1024),
|
||||
// 使用浏览器读取到的修改时间
|
||||
created_time: new Date(file.lastModified).toLocaleString(),
|
||||
// 关键:保存文件引用,以便点击时读取
|
||||
fileRef: file
|
||||
};
|
||||
bsodList.value.unshift(newItem);
|
||||
importedCount++;
|
||||
}
|
||||
|
||||
triggerToast('导入成功', `已添加 ${importedCount} 个文件到列表`, 'success');
|
||||
event.target.value = ''; // 重置,允许再次导入同名文件
|
||||
if (importedCount > 0) {
|
||||
triggerToast('导入成功', `已添加 ${importedCount} 个文件到列表`, 'success');
|
||||
} else {
|
||||
triggerToast('导入忽略', '未选择有效的 .dmp 文件', 'error');
|
||||
}
|
||||
event.target.value = '';
|
||||
}
|
||||
|
||||
watch(currentTab, (newVal) => { if (newVal === 'bsod' && bsodList.value.length === 0) loadMinidumps(); });
|
||||
|
||||
Reference in New Issue
Block a user