diff --git a/convert-w2p.js b/convert-w2p.js index 4348f75..3a0d4ff 100644 --- a/convert-w2p.js +++ b/convert-w2p.js @@ -337,8 +337,8 @@ async function convert(input) { const nr = node.rect; const rw = nr.width ?? nr.w; const rh = nr.height ?? nr.h; - // 保留所有非 raster 节点 - if (node.type !== 'RECTANGLE' && node.layerGroup !== 'comparison') { + // 保留所有非 raster 节点(RECTANGLE 有 backgroundImages 的也保留,如 SVG 图标) + if ((node.type !== 'RECTANGLE' || (node.backgroundImages && node.backgroundImages.length > 0)) && node.layerGroup !== 'comparison') { results.push({ id: node.id, type: node.type, name: node.name, tag: node.tag, rect: { x: nr.x - slideX, y: nr.y - slideY, w: rw, h: rh }, @@ -775,13 +775,19 @@ async function convert(input) { // ===== 图片节点(IMAGE 类型或有背景图的 RECTANGLE) ===== if ((n.type === 'IMAGE' || n.type === 'RECTANGLE') && n.backgroundImages && n.backgroundImages.length > 0) { var imgKey = n.backgroundImages[0]; - var asset = ctx.assets[imgKey]; - if (asset && asset.data) { + var imgData; + if (imgKey.startsWith('data:')) { + imgData = imgKey; // 已经是 data URL(如 SVG 图标) + } else { + var asset = ctx.assets[imgKey]; + if (asset) imgData = asset.data; + } + if (imgData) { objects.push({ type: 'image', options: { x: opts.x, y: opts.y, w: opts.w, h: opts.h, - data: asset.data + data: imgData } }); }