debug: 采集后保存 JSON 供调试

This commit is contained in:
李进
2026-07-27 15:28:47 +08:00
parent 00b3150d1c
commit 197642b410
+11
View File
@@ -146,6 +146,17 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
assertCaptureableTab(tab); assertCaptureableTab(tab);
const data = await captureCurrentTab(tab, settings); const data = await captureCurrentTab(tab, settings);
lastCaptureData = data; lastCaptureData = data;
// 调试:保存 JSON 到 Downloads
try {
const json = JSON.stringify(data, null, 2);
const encoded = btoa(unescape(encodeURIComponent(json)));
const title = data.source?.title || 'debug';
const safe = title.replace(/[\\/:*?"<>|]+/g, '-').slice(0, 32);
await chrome.downloads.download({
url: 'data:application/json;base64,' + encoded,
filename: 'web-to-ppt/' + safe + '-' + Date.now() + '.json'
});
} catch(e) {}
return { ok: true, actualViewportWidth: data.source?.actualViewportWidth }; return { ok: true, actualViewportWidth: data.source?.actualViewportWidth };
})() })()
.then(sendResponse) .then(sendResponse)