feat: 优化导出功能,清除选中状态以避免导出问题,调整裁剪路径以保持准确性
This commit is contained in:
@@ -776,6 +776,9 @@ export class CanvasManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// 如果当前有选中对象,先清除选中状态 否则导出有问题
|
||||||
|
this.canvas.discardActiveObject(); // 清除选中状态
|
||||||
|
this.canvas.renderAll(); // 重新渲染画布
|
||||||
// 自动设置红绿图模式相关参数
|
// 自动设置红绿图模式相关参数
|
||||||
const enhancedOptions = {
|
const enhancedOptions = {
|
||||||
...options,
|
...options,
|
||||||
|
|||||||
@@ -263,7 +263,8 @@ export class ExportManager {
|
|||||||
|
|
||||||
// 递归收集子图层的对象
|
// 递归收集子图层的对象
|
||||||
if (layer.children && layer.children.length > 0) {
|
if (layer.children && layer.children.length > 0) {
|
||||||
for (const childLayer of layer.children) {
|
for (let i = layer.children.length - 1; i >= 0; i--) {
|
||||||
|
const childLayer = layer.children[i];
|
||||||
const childObjects = this._collectObjectsFromLayer(childLayer);
|
const childObjects = this._collectObjectsFromLayer(childLayer);
|
||||||
realObjects.push(...childObjects);
|
realObjects.push(...childObjects);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -805,6 +805,17 @@ const renderContentToImage = async ({ fabricObjects, selectionBounds, qualityMul
|
|||||||
evented: false,
|
evented: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 如果有裁剪路径,也需要调整裁剪路径
|
||||||
|
if (clonedObj.clipPath) {
|
||||||
|
clonedObj.clipPath.set({
|
||||||
|
left: (clonedObj.clipPath.left - selectionBounds.left) * qualityMultiplier,
|
||||||
|
top: (clonedObj.clipPath.top - selectionBounds.top) * qualityMultiplier,
|
||||||
|
scaleX: (clonedObj.clipPath.scaleX || 1) * qualityMultiplier,
|
||||||
|
scaleY: (clonedObj.clipPath.scaleY || 1) * qualityMultiplier,
|
||||||
|
});
|
||||||
|
clonedObj.clipPath.setCoords(); // 更新裁剪路径坐标
|
||||||
|
}
|
||||||
|
|
||||||
contentCanvas.add(clonedObj);
|
contentCanvas.add(clonedObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user