diff --git a/web-to-ppt/capture.js b/web-to-ppt/capture.js index 64fb37e..5dfc357 100644 --- a/web-to-ppt/capture.js +++ b/web-to-ppt/capture.js @@ -1011,7 +1011,12 @@ 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); + // 替换 currentColor 为实际计算颜色 + const computedColor = styles.color || window.getComputedStyle(element).color || '#000000'; + const colorMatch = computedColor.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/); + const hexColor = colorMatch ? '#' + [colorMatch[1],colorMatch[2],colorMatch[3]].map(x => parseInt(x).toString(16).padStart(2,'0')).join('') : computedColor; + let svgStr = new XMLSerializer().serializeToString(svgClone); + svgStr = svgStr.replace(/currentColor/g, hexColor); node.backgroundImages = ["data:image/svg+xml;base64," + btoa(unescape(encodeURIComponent(svgStr)))]; node.type = "RECTANGLE"; } catch (e) {}