画布图片数据递归设置minio地址

This commit is contained in:
X1627315083
2026-01-21 16:27:59 +08:00
parent 07c261d74c
commit ef1c1c349d
5 changed files with 80 additions and 15 deletions

View File

@@ -993,7 +993,21 @@ export class CanvasManager {
throw new Error("获取画布JSON失败");
}
}
/** 修复JSON数据中的ID丢失问题 */
FixJsonIdLoss(json){
const layers = json?.layers || [];
const objects = json?.canvas?.objects || [];
layers.forEach((layer) => {
if(!layer.fabricObjects?.length && !layer.fabricObject){
const obj = objects?.find((o) => o.layerId === layer.id);
if(!obj) return;
layer.fabricObjects = [{
id: obj.id,
type: obj.type,
}]
}
})
}
loadJSON(json, calllBack) {
console.log("加载画布JSON数据:", json);
@@ -1006,6 +1020,7 @@ export class CanvasManager {
// 解析JSON字符串
try {
const parsedJson = JSON.parse(json);
this.FixJsonIdLoss(parsedJson);
this.canvasWidth.value = parsedJson.canvasWidth || this.width;
this.canvasHeight.value = parsedJson.canvasHeight || this.height;
this.canvasColor.value = parsedJson.canvasColor || this.backgroundColor;