fix: SVG 图标正确渲染
- collectSlideChildren 保留有 backgroundImages 的 RECTANGLE 节点 - 图片处理:data URL 直接使用,不查找 assets - Gitea 测试:24 个 SVG 图标成功渲染
This commit is contained in:
+10
-4
@@ -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 imgData;
|
||||
if (imgKey.startsWith('data:')) {
|
||||
imgData = imgKey; // 已经是 data URL(如 SVG 图标)
|
||||
} else {
|
||||
var asset = ctx.assets[imgKey];
|
||||
if (asset && asset.data) {
|
||||
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
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user