Skip to content

Commit

Permalink
优化 json 加载 (#379)
Browse files Browse the repository at this point in the history
解决重复 json 序列化

Co-authored-by: 秦少卫 <[email protected]>
  • Loading branch information
ylx252 and nihaojob authored May 11, 2024
1 parent bc2cc82 commit 71cff85
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/ServersPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ class ServersPlugin {
});
}

loadJSON(jsonFile: string, callback?: () => void) {
loadJSON(jsonFile: string | object, callback?: () => void) {
// 确保元素存在id
const temp = JSON.parse(jsonFile);
const temp = typeof jsonFile === 'string' ? JSON.parse(jsonFile) : jsonFile;
temp.objects.forEach((item: any) => {
!item.id && (item.id = uuid());
});
Expand Down
1 change: 1 addition & 0 deletions src/components/importTmpl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ const getTempData = (json) => {
});
router.replace('/');
canvasEditor.loadJSON(JSON.stringify(json), Spin.hide);
};
</script>
Expand Down

0 comments on commit 71cff85

Please sign in to comment.