fix: 优化栅格化命令,支持父图层及其子图层的栅格化,并改进加载提示的管理
This commit is contained in:
@@ -45,6 +45,13 @@ export class RasterizeLayerCommand extends Command {
|
||||
);
|
||||
this.layer = layer;
|
||||
this.parentLayer = parent;
|
||||
|
||||
// 新增:如果有父图层,则栅格化父图层及其所有子图层
|
||||
if (this.parentLayer) {
|
||||
this.layer = this.parentLayer;
|
||||
this.layerId = this.parentLayer.id;
|
||||
}
|
||||
|
||||
this.isGroupLayer = this.layer?.children && this.layer.children.length > 0;
|
||||
|
||||
if (!this.layer) {
|
||||
|
||||
@@ -795,18 +795,17 @@ export class ToolManager {
|
||||
*/
|
||||
async _rasterizeLayerForLiquify(layerId) {
|
||||
if (!this.commandManager || !this.layerManager) return;
|
||||
// 显示加载Modal
|
||||
const loadingModal = Modal.info({
|
||||
title: "正在栅格化",
|
||||
content: "正在栅格化图层,请稍候...",
|
||||
okButtonProps: { style: { display: "none" } },
|
||||
centered: true,
|
||||
closable: false,
|
||||
maskClosable: false,
|
||||
});
|
||||
|
||||
try {
|
||||
// 显示加载Modal
|
||||
const loadingModal = Modal.info({
|
||||
title: "正在栅格化",
|
||||
content: "正在栅格化图层,请稍候...",
|
||||
okButtonProps: { style: { display: "none" } },
|
||||
centered: true,
|
||||
closable: false,
|
||||
maskClosable: false,
|
||||
});
|
||||
|
||||
// 创建栅格化命令
|
||||
const rasterizeCommand = new RasterizeLayerCommand({
|
||||
canvas: this.canvas,
|
||||
@@ -819,9 +818,6 @@ export class ToolManager {
|
||||
// 执行命令
|
||||
const result = await this.commandManager.execute(rasterizeCommand);
|
||||
|
||||
// 关闭加载Modal
|
||||
loadingModal.destroy();
|
||||
|
||||
if (result) {
|
||||
// 栅格化成功,启动液化
|
||||
message.success("图层已成功栅格化,可以进行液化操作");
|
||||
@@ -837,12 +833,16 @@ export class ToolManager {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("栅格化图层失败:", error);
|
||||
|
||||
Modal.error({
|
||||
title: "栅格化错误",
|
||||
content: `栅格化失败:${error.message}`,
|
||||
okText: "确定",
|
||||
centered: true,
|
||||
});
|
||||
} finally {
|
||||
// 关闭加载Modal
|
||||
loadingModal.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user