From d3bb1fe95213dfa0018d67093bdf67145f9bb8f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=BF=9B?= Date: Mon, 27 Jul 2026 16:58:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20SVG=20currentColor=20=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E4=B8=BA=E5=AE=9E=E9=99=85=E8=AE=A1=E7=AE=97=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web-to-ppt/capture.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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) {}