fix: 修复图层和工具管理器中的子图层访问逻辑,确保正确处理子图层
This commit is contained in:
@@ -336,7 +336,7 @@ export class LayerManager {
|
|||||||
const layerMap = {};
|
const layerMap = {};
|
||||||
layers.forEach((layer) => {
|
layers.forEach((layer) => {
|
||||||
layerMap[layer.id] = layer;
|
layerMap[layer.id] = layer;
|
||||||
layers?.children?.forEach((childLayer) => {
|
layer?.children?.forEach((childLayer) => {
|
||||||
layerMap[childLayer.id] = childLayer;
|
layerMap[childLayer.id] = childLayer;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -359,7 +359,7 @@ export class LayerManager {
|
|||||||
await this._setObjectInteractivity(obj, layer, editorMode);
|
await this._setObjectInteractivity(obj, layer, editorMode);
|
||||||
|
|
||||||
// 设置子图层对象的交互性
|
// 设置子图层对象的交互性
|
||||||
layer?.childLayer?.forEach(async (childLayer) => {
|
layer?.children?.forEach(async (childLayer) => {
|
||||||
const childObj = this.canvas
|
const childObj = this.canvas
|
||||||
.getObjects()
|
.getObjects()
|
||||||
.find((o) => o.layerId === childLayer.id);
|
.find((o) => o.layerId === childLayer.id);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { InitLiquifyToolCommand } from "../commands/LiquifyCommands";
|
|||||||
import { RasterizeLayerCommand } from "../commands/RasterizeLayerCommand";
|
import { RasterizeLayerCommand } from "../commands/RasterizeLayerCommand";
|
||||||
import { message, Modal } from "ant-design-vue";
|
import { message, Modal } from "ant-design-vue";
|
||||||
import { h } from "vue";
|
import { h } from "vue";
|
||||||
|
import { findObjectById } from "../utils/helper";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工具管理器
|
* 工具管理器
|
||||||
@@ -258,7 +259,10 @@ export class ToolManager {
|
|||||||
const shiftKey = event.shiftKey;
|
const shiftKey = event.shiftKey;
|
||||||
|
|
||||||
// 当处于输入状态时不触发快捷键
|
// 当处于输入状态时不触发快捷键
|
||||||
if (event.target.tagName === "INPUT" || event.target.tagName === "TEXTAREA") {
|
if (
|
||||||
|
event.target.tagName === "INPUT" ||
|
||||||
|
event.target.tagName === "TEXTAREA"
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +287,10 @@ export class ToolManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 在红绿图模式下检查工具可用性
|
// 在红绿图模式下检查工具可用性
|
||||||
if (this.isRedGreenMode && !this.isToolAvailableInRedGreenMode(toolId)) {
|
if (
|
||||||
|
this.isRedGreenMode &&
|
||||||
|
!this.isToolAvailableInRedGreenMode(toolId)
|
||||||
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,7 +565,9 @@ export class ToolManager {
|
|||||||
|
|
||||||
// 通知选区管理器切换到矩形套索工具
|
// 通知选区管理器切换到矩形套索工具
|
||||||
if (this.canvasManager && this.canvasManager.selectionManager) {
|
if (this.canvasManager && this.canvasManager.selectionManager) {
|
||||||
this.canvasManager.selectionManager.setCurrentTool(OperationType.LASSO_RECTANGLE);
|
this.canvasManager.selectionManager.setCurrentTool(
|
||||||
|
OperationType.LASSO_RECTANGLE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -573,7 +582,9 @@ export class ToolManager {
|
|||||||
|
|
||||||
// 通知选区管理器切换到椭圆套索工具
|
// 通知选区管理器切换到椭圆套索工具
|
||||||
if (this.canvasManager && this.canvasManager.selectionManager) {
|
if (this.canvasManager && this.canvasManager.selectionManager) {
|
||||||
this.canvasManager.selectionManager.setCurrentTool(OperationType.LASSO_ELLIPSE);
|
this.canvasManager.selectionManager.setCurrentTool(
|
||||||
|
OperationType.LASSO_ELLIPSE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,7 +599,9 @@ export class ToolManager {
|
|||||||
|
|
||||||
// 通知选区管理器切换到椭圆套索工具
|
// 通知选区管理器切换到椭圆套索工具
|
||||||
if (this.canvasManager && this.canvasManager.selectionManager) {
|
if (this.canvasManager && this.canvasManager.selectionManager) {
|
||||||
this.canvasManager.selectionManager.setCurrentTool(OperationType.AREA_CUSTOM);
|
this.canvasManager.selectionManager.setCurrentTool(
|
||||||
|
OperationType.AREA_CUSTOM
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -606,7 +619,9 @@ export class ToolManager {
|
|||||||
console.log("矩形选区工具已激活");
|
console.log("矩形选区工具已激活");
|
||||||
|
|
||||||
if (this.canvasManager && this.canvasManager.selectionManager) {
|
if (this.canvasManager && this.canvasManager.selectionManager) {
|
||||||
this.canvasManager.selectionManager.setCurrentTool(OperationType.AREA_RECTANGLE);
|
this.canvasManager.selectionManager.setCurrentTool(
|
||||||
|
OperationType.AREA_RECTANGLE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -662,9 +677,18 @@ export class ToolManager {
|
|||||||
// 设置目标对象
|
// 设置目标对象
|
||||||
if (layer) {
|
if (layer) {
|
||||||
if (layer.isBackground || layer.type === "background") {
|
if (layer.isBackground || layer.type === "background") {
|
||||||
panelDetail.targetObject = layer.fabricObject;
|
panelDetail.targetObject = findObjectById(
|
||||||
} else if (layer.fabricObjects && layer.fabricObjects.length > 0) {
|
this.canvas,
|
||||||
panelDetail.targetObject = layer.fabricObjects[0];
|
layer.fabricObject?.id
|
||||||
|
)?.object;
|
||||||
|
} else if (
|
||||||
|
layer.fabricObjects &&
|
||||||
|
layer.fabricObjects.length > 0
|
||||||
|
) {
|
||||||
|
panelDetail.targetObject = findObjectById(
|
||||||
|
this.canvas,
|
||||||
|
layer.fabricObjects?.[0]?.id
|
||||||
|
)?.object;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 准备液化环境,获取原始图像数据
|
// 准备液化环境,获取原始图像数据
|
||||||
@@ -889,7 +913,9 @@ export class ToolManager {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 准备液化操作,获取原始图像数据
|
// 准备液化操作,获取原始图像数据
|
||||||
const prepareResult = await liquifyManager.prepareForLiquify(targetObject);
|
const prepareResult = await liquifyManager.prepareForLiquify(
|
||||||
|
targetObject
|
||||||
|
);
|
||||||
|
|
||||||
// 创建和初始化命令
|
// 创建和初始化命令
|
||||||
const initCommand = new InitLiquifyToolCommand({
|
const initCommand = new InitLiquifyToolCommand({
|
||||||
@@ -1091,7 +1117,9 @@ export class ToolManager {
|
|||||||
const target = e.target;
|
const target = e.target;
|
||||||
if (
|
if (
|
||||||
target &&
|
target &&
|
||||||
(target.type === "text" || target.type === "i-text" || target.type === "textbox")
|
(target.type === "text" ||
|
||||||
|
target.type === "i-text" ||
|
||||||
|
target.type === "textbox")
|
||||||
) {
|
) {
|
||||||
// 获取对应的图层
|
// 获取对应的图层
|
||||||
const layer = this.layerManager.getLayerById(target.layerId);
|
const layer = this.layerManager.getLayerById(target.layerId);
|
||||||
@@ -1359,7 +1387,11 @@ export class ToolManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 从画布笔刷获取
|
// 从画布笔刷获取
|
||||||
if (this.canvas && this.canvas.freeDrawingBrush && this.canvas.freeDrawingBrush.width) {
|
if (
|
||||||
|
this.canvas &&
|
||||||
|
this.canvas.freeDrawingBrush &&
|
||||||
|
this.canvas.freeDrawingBrush.width
|
||||||
|
) {
|
||||||
return this.canvas.freeDrawingBrush.width;
|
return this.canvas.freeDrawingBrush.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1384,7 +1416,11 @@ export class ToolManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 从画布笔刷获取
|
// 从画布笔刷获取
|
||||||
if (this.canvas && this.canvas.freeDrawingBrush && this.canvas.freeDrawingBrush.color) {
|
if (
|
||||||
|
this.canvas &&
|
||||||
|
this.canvas.freeDrawingBrush &&
|
||||||
|
this.canvas.freeDrawingBrush.color
|
||||||
|
) {
|
||||||
return this.canvas.freeDrawingBrush.color;
|
return this.canvas.freeDrawingBrush.color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user