Compare commits
6
Commits
v1.1
...
82d384bd1f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
82d384bd1f | ||
|
|
33fc8b06d6 | ||
|
|
5127df5e96 | ||
|
|
ecc1a0d77e | ||
|
|
5ef970337d | ||
|
|
197642b410 |
@@ -146,6 +146,17 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||
assertCaptureableTab(tab);
|
||||
const data = await captureCurrentTab(tab, settings);
|
||||
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 };
|
||||
})()
|
||||
.then(sendResponse)
|
||||
|
||||
@@ -984,6 +984,20 @@
|
||||
const afterNode = pseudoElementToCaptureNode(element, "::after", clientRect, assetUrls, ownClip, childContext);
|
||||
pushCaptureChild(children, afterNode);
|
||||
|
||||
// SVG → 序列化为 data URL 图片
|
||||
if ((element.tagName === "SVG" || element.tagName === "svg") && !backgroundUrls.length) {
|
||||
try {
|
||||
const svgClone = element.cloneNode(true);
|
||||
if (!svgClone.getAttribute('xmlns')) svgClone.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
|
||||
const svgStr = new XMLSerializer().serializeToString(svgClone);
|
||||
const svgDataUrl = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(svgStr)));
|
||||
backgroundUrls = [svgDataUrl];
|
||||
console.log('[WebToPPT] SVG captured:', (element.className || element.id || '').slice(0, 30), 'size:', svgStr.length);
|
||||
} catch (e) {
|
||||
console.warn('[WebToPPT] SVG capture failed:', e.message, element.tagName, (element.className || '').slice(0, 30));
|
||||
}
|
||||
}
|
||||
|
||||
const type = element.tagName === "IMG" || backgroundUrls.length ? "RECTANGLE" : "FRAME";
|
||||
return {
|
||||
id: `node-${++nodeCounter}`,
|
||||
|
||||
Reference in New Issue
Block a user