diff --git a/src/component/Canvas/CanvasEditor/commands/LassoCutoutCommand.js b/src/component/Canvas/CanvasEditor/commands/LassoCutoutCommand.js index b0d765c1..a3ad1eaf 100644 --- a/src/component/Canvas/CanvasEditor/commands/LassoCutoutCommand.js +++ b/src/component/Canvas/CanvasEditor/commands/LassoCutoutCommand.js @@ -223,9 +223,19 @@ export class LassoCutoutCommand extends CompositeCommand { await clearSelectionCmd.execute(); this.executedCommands.push(clearSelectionCmd); - const topLayerIndex = this.layerManager.layers.value.findIndex( - (layer) => layer.id === this.originalLayer.id - ); + const layers = this.layerManager.layers.value; + var topLayerIndex = 0; + layers.forEach((layer, index) => { + if (layer.id === this.originalLayer.id) { + topLayerIndex = index; + }else if (layer.children.length > 0) { + layer.children.forEach((childLayer) => { + if (childLayer.id === this.originalLayer.id) { + topLayerIndex = index; + } + }); + } + }); // const selectLayer = this.layerManager.layers.value[topLayerIndex]; @@ -287,6 +297,7 @@ export class LassoCutoutCommand extends CompositeCommand { this.groupLayer.children.push(selectLayer); // 插入新组图层 + console.log("新增套索添加index", topLayerIndex); this.layerManager.layers.value.splice(topLayerIndex, 0, this.groupLayer); this.layerManager.activeLayerId.value = selectLayer.id; // 设置新组图层为活动图层