Skip to content

Commit

Permalink
fix: 修复元素与图层无法对应的问题 (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
wuchenguang1998 authored May 8, 2024
1 parent d9758d1 commit c966e75
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/core/ServersPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ class ServersPlugin {
}

loadJSON(jsonFile: string, callback?: () => void) {
// 确保元素存在id
const temp = JSON.parse(jsonFile);
temp.objects.forEach((item: any) => {
!item.id && (item.id = uuid());
});
jsonFile = JSON.stringify(temp);
// 加载前钩子
this.editor.hooksEntity.hookImportBefore.callAsync(jsonFile, () => {
this.canvas.loadFromJSON(jsonFile, () => {
Expand Down

0 comments on commit c966e75

Please sign in to comment.