修复画布删除最后一个活动图层bug
This commit is contained in:
@@ -678,12 +678,20 @@ function deleteFun(){
|
|||||||
|
|
||||||
function removeLayer(layerId) {
|
function removeLayer(layerId) {
|
||||||
// Check if this is the last layer - prevent deletion
|
// Check if this is the last layer - prevent deletion
|
||||||
if (layers.value.length <= 2) {
|
var isChild = false;
|
||||||
console.warn(
|
var parentLength = 0;
|
||||||
|
layers.value.forEach((layer) => {
|
||||||
|
if(layer.children.some(v => v.id == layerId)){
|
||||||
|
isChild = true;
|
||||||
|
parentLength = layer.children.length;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(isChild && parentLength == 1 || layers.value.length <= 3){
|
||||||
|
console.warn(
|
||||||
"Cannot delete the last layer. At least one layer must remain."
|
"Cannot delete the last layer. At least one layer must remain."
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canvasManager && canvasManager.canvas) {
|
if (canvasManager && canvasManager.canvas) {
|
||||||
const layerToRemove = layers.value.find((l) => l.id === layerId);
|
const layerToRemove = layers.value.find((l) => l.id === layerId);
|
||||||
|
|||||||
Reference in New Issue
Block a user