画布删除撤回、频繁撤回反撤回、图片裁剪id丢失问题修复

This commit is contained in:
X1627315083
2025-10-17 17:39:19 +08:00
parent a297bb9791
commit 0c0f4522fc
3 changed files with 29 additions and 22 deletions

View File

@@ -70,7 +70,7 @@ export class AddLayerCommand extends Command {
undo() {
// 从图层列表删除该图层
this.layers.value = this.beforeLayers;
this.layers.value = [...this.beforeLayers];
// 恢复原活动图层
this.activeLayerId.value = this.oldActiveLayerId;
@@ -563,7 +563,12 @@ export class RemoveLayerCommand extends Command {
allObjects.push(object);
}
}
layer.fabricObjects?.forEach((fabric) => {
const { object } = findObjectById(this.canvas, fabric.id);
if (object && !allObjects.includes(object)) {
allObjects.push(object);
}
});
// 递归收集子图层的对象
if (layer.children && Array.isArray(layer.children)) {
layer.children.forEach((childLayer) => {