111
This commit is contained in:
@@ -993,21 +993,6 @@ 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);
|
||||
|
||||
@@ -1019,7 +1004,7 @@ FixJsonIdLoss(json){
|
||||
}
|
||||
// 解析JSON字符串
|
||||
try {
|
||||
const parsedJson = JSON.parse(json);
|
||||
const parsedJson = window.testCanvasJson || JSON.parse(json);
|
||||
this.FixJsonIdLoss(parsedJson);
|
||||
this.canvasWidth.value = parsedJson.canvasWidth || this.width;
|
||||
this.canvasHeight.value = parsedJson.canvasHeight || this.height;
|
||||
|
||||
Reference in New Issue
Block a user