背景报错
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -242,7 +242,7 @@ const canDeleteComputed = computed(() => {
|
||||
return parentLayer?.children?.length > 1;
|
||||
}
|
||||
// 否则直接返回根图层的可删除状态
|
||||
return props.layers.length > 3;
|
||||
return true;
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user