diff --git a/src/component/Canvas/CanvasEditor/commands/FillGroupLayerBackgroundCommand.js b/src/component/Canvas/CanvasEditor/commands/FillGroupLayerBackgroundCommand.js index edd061ac..26f90e2c 100644 --- a/src/component/Canvas/CanvasEditor/commands/FillGroupLayerBackgroundCommand.js +++ b/src/component/Canvas/CanvasEditor/commands/FillGroupLayerBackgroundCommand.js @@ -106,7 +106,6 @@ export class FillGroupLayerBackgroundCommand extends Command { }); } } - // 判断fabricObjects是否是组对象 const firstObj = layer.fabricObjects?.[0] || null; // 如果没有找到第一个对象,则直接添加到当前画布 @@ -173,8 +172,8 @@ export class FillGroupLayerBackgroundCommand extends Command { } const canvasObj = findObjectById(this.canvas, firstObj?.id)?.object; if ( - (canvasObj && canvasObj.type === "group") || - canvasObj._objects?.length > 0 + canvasObj && (canvasObj.type === "group" || + canvasObj._objects?.length > 0) ) { this.newFill.set({ left: 0, diff --git a/src/component/Canvas/CanvasEditor/commands/LassoCutoutCommand.js b/src/component/Canvas/CanvasEditor/commands/LassoCutoutCommand.js index a3ad1eaf..b69f2cdc 100644 --- a/src/component/Canvas/CanvasEditor/commands/LassoCutoutCommand.js +++ b/src/component/Canvas/CanvasEditor/commands/LassoCutoutCommand.js @@ -147,11 +147,11 @@ export class LassoCutoutCommand extends CompositeCommand { } // 确定源图层 - const sourceLayer = this.layerManager.getActiveLayer(); - if (!sourceLayer) { - console.error("无法执行套索抠图:源图层无效"); - return false; - } + // const sourceLayer = this.layerManager.getActiveLayer(); + // if (!sourceLayer) { + // console.error("无法执行套索抠图:源图层无效"); + // return false; + // } // 获取源图层的所有对象(包括子图层) // const sourceObjects = this._getLayerObjects(sourceLayer); @@ -225,7 +225,7 @@ export class LassoCutoutCommand extends CompositeCommand { const layers = this.layerManager.layers.value; var topLayerIndex = 0; - layers.forEach((layer, index) => { + if(this.originalLayer)layers.forEach((layer, index) => { if (layer.id === this.originalLayer.id) { topLayerIndex = index; }else if (layer.children.length > 0) { diff --git a/src/component/Canvas/CanvasEditor/commands/PartCommands.js b/src/component/Canvas/CanvasEditor/commands/PartCommands.js new file mode 100644 index 00000000..c8e1178c --- /dev/null +++ b/src/component/Canvas/CanvasEditor/commands/PartCommands.js @@ -0,0 +1,56 @@ +import { Command } from "./Command.js"; + +/** + * 部件绘制命令 + */ +export class PartDrawCommand extends Command { + constructor(options) { + super({ + name: "部件绘制命令", + saveState: false, + }); + + this.canvas = options.canvas; + this.partManager = options.partManager; + this.partCanvas = options.partCanvas; + this.oldPartCanvas = this.partManager.partCanvas; + } + execute() { + this.partManager.drawPartCanvas(this.partCanvas); + return true; + } + undo() { + this.partManager.drawPartCanvas(this.oldPartCanvas); + return true; + } +} +/** + * 部件点选绘制命令 + */ +export class PartPointDrawCommand extends Command { + constructor(options) { + super({ + name: "部件点选绘制命令", + saveState: false, + }); + + this.canvas = options.canvas; + this.partManager = options.partManager; + this.partCanvas = options.partCanvas; + this.pointList = options.pointList; + this.oldPartCanvas = this.partManager.partCanvas; + this.oldPointList = [...this.partManager.pointList]; + } + async execute() { + const list = [...this.pointList]; + const canvas = this.partCanvas; + const res = await this.partManager.pointDrawPartCanvas(list, canvas); + return res; + } + async undo() { + const list = [...this.oldPointList]; + const canvas = this.oldPartCanvas; + const res = await this.partManager.pointDrawPartCanvas(list, canvas); + return res; + } +} diff --git a/src/component/Canvas/CanvasEditor/components/PartSelectorPanel.vue b/src/component/Canvas/CanvasEditor/components/PartSelectorPanel.vue index 658d647f..1bf5d790 100644 --- a/src/component/Canvas/CanvasEditor/components/PartSelectorPanel.vue +++ b/src/component/Canvas/CanvasEditor/components/PartSelectorPanel.vue @@ -20,13 +20,13 @@ - Left Click: Add + {{ t("Canvas.LeftClickAdd") }}
- Right Click: Remove + {{ t("Canvas.RightClickRemove") }}
@@ -57,15 +57,15 @@ $t("Canvas.creation") }} -
+
- 清空当前点位 + {{ $t("Canvas.TheClearlySelectedContent") }}
@@ -76,23 +76,9 @@