Skip to content

Commit 3880c51

Browse files
committed
feat: 新增序列化方法
1 parent 7a37a49 commit 3880c51

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/core/src/app.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ export class App extends BaseService<EventArgs> {
178178
this.mainLayer.draw();
179179
}
180180

181+
public toJSON(): string {
182+
return this.mainLayer.toJSON();
183+
}
184+
185+
public fromJSON(json: string): void {
186+
const layer = Konva.Node.create(json, 'layer');
187+
this.mainLayer = layer;
188+
}
189+
181190
public use(plugin: Plugin, ...options: any[]): App {
182191
if (!this.installedPlugins.has(plugin.name)) {
183192
this.installedPlugins.set(plugin.name, plugin);

0 commit comments

Comments
 (0)