From a9283a350ab378228c086760f4629c101174c646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BF=97=E9=B9=8F?= <2916022834@qq.com> Date: Mon, 13 Oct 2025 15:08:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A5=97=E7=B4=A2=E5=88=9B=E5=BB=BA=E6=B6=88?= =?UTF-8?q?=E5=A4=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CanvasEditor/commands/LassoCutoutCommand.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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; // 设置新组图层为活动图层