mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
feat(core): 新增store
This commit is contained in:
parent
eba6cbccde
commit
5f78bbd7b7
@ -22,6 +22,7 @@ import type { EventItemConfig, MComponent, MContainer, MPage } from '@tmagic/sch
|
||||
|
||||
import type App from './App';
|
||||
import type Page from './Page';
|
||||
import Store from './Store';
|
||||
|
||||
interface NodeOptions {
|
||||
config: MComponent | MContainer;
|
||||
@ -39,6 +40,7 @@ class Node extends EventEmitter {
|
||||
public page?: Page;
|
||||
public parent?: Node;
|
||||
public app: App;
|
||||
public store = new Store();
|
||||
|
||||
constructor(options: NodeOptions) {
|
||||
super();
|
||||
|
11
packages/core/src/Store.ts
Normal file
11
packages/core/src/Store.ts
Normal file
@ -0,0 +1,11 @@
|
||||
export default class Store {
|
||||
private data: Record<string, any> = {};
|
||||
|
||||
public set(key: string, value: any) {
|
||||
this.data[key] = value;
|
||||
}
|
||||
|
||||
public get(key: string) {
|
||||
return this.data[key];
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user