diff --git a/src/component/Canvas/CanvasEditor/commands/BackgroundCommands.js b/src/component/Canvas/CanvasEditor/commands/BackgroundCommands.js index 60fd70f9..35b3759b 100644 --- a/src/component/Canvas/CanvasEditor/commands/BackgroundCommands.js +++ b/src/component/Canvas/CanvasEditor/commands/BackgroundCommands.js @@ -207,7 +207,8 @@ export class BackgroundSizeCommand extends Command { this.bgLayer = this.layers.value.find((layer) => layer.isBackground); // 记录原尺寸 - this.backgroundObject = findObjectById(this.canvas, this.bgLayer.fabricObject.id).object; + this.bgId = this.bgLayer.fabricObject?.id || this.bgLayer.fabricObjects?.[0]?.id; + this.backgroundObject = findObjectById(this.canvas, this.bgId).object; this.oldWidth = this.backgroundObject.width; this.oldHeight = this.backgroundObject.height; diff --git a/src/component/Canvas/CanvasEditor/components/LayersPanel/LayersList.vue b/src/component/Canvas/CanvasEditor/components/LayersPanel/LayersList.vue index 42433748..c34ebe18 100644 --- a/src/component/Canvas/CanvasEditor/components/LayersPanel/LayersList.vue +++ b/src/component/Canvas/CanvasEditor/components/LayersPanel/LayersList.vue @@ -242,7 +242,7 @@ const canDeleteComputed = computed(() => { return parentLayer?.children?.length > 1; } // 否则直接返回根图层的可删除状态 - return props.layers.length > 3; + return true; }); diff --git a/src/component/Canvas/CanvasEditor/components/LayersPanel/LayersPanel.vue b/src/component/Canvas/CanvasEditor/components/LayersPanel/LayersPanel.vue index 1b72e5ac..0ed765d5 100644 --- a/src/component/Canvas/CanvasEditor/components/LayersPanel/LayersPanel.vue +++ b/src/component/Canvas/CanvasEditor/components/LayersPanel/LayersPanel.vue @@ -414,14 +414,14 @@ function deleteSelectedLayers() { } // 检查删除后是否还有足够的普通图层 - const remainingNormalLayers = layers.value.filter( - (layer) => !layer.isBackground && !layer.isFixed && !selectedLayerIds.value.includes(layer.id) - ).length; +// const remainingNormalLayers = layers.value.filter( +// (layer) => !layer.isBackground && !layer.isFixed && !selectedLayerIds.value.includes(layer.id) +// ).length; - if (remainingNormalLayers < 1) { - console.warn("不能删除所有普通图层"); - return; - } +// if (remainingNormalLayers < 1) { +// console.warn("不能删除所有普通图层"); +// return; +// } // 确认删除 if (selectedLayers.length > 1) { @@ -876,13 +876,15 @@ function toggleSelectedLayersVisibility() { function canDeleteLayers() { const selectedLayers = getSelectedLayers(); + console.log(selectedLayers); if (selectedLayers.length === 0) return false; - // 检查是否包含不能删除的图层 const undeletableLayers = selectedLayers.filter((layer) => layer.isBackground || layer.isFixed); if (undeletableLayers.length > 0) return false; + return true + // 检查删除后是否还有足够的普通图层 const remainingNormalLayers = layers.value.filter( (layer) => !layer.isBackground && !layer.isFixed && !selectedLayerIds.value.includes(layer.id)