UI模块添加数据绑定装饰器

1.添加数据基类,子类自动添加代理,数据变化自动通知
 2.支持同属性多装饰器
This commit is contained in:
gongxh
2025-08-29 15:25:10 +08:00
parent b62a4af8db
commit e48011d941
45 changed files with 1354 additions and 21 deletions

View File

@@ -0,0 +1,27 @@
/**
* @Author: Gongxh
* @Date: 2025-02-17
* @Description: 准备一个数据类
*/
import { GlobalEvent } from "kunpocc-event";
import { Level } from "../Data/global/Level";
export class DataHelper {
public static level: Level = new Level();
private static _data: Map<string, any> = new Map();
public static getValue<T>(key: string, defaultValue: T): T {
if (this._data.has(key)) {
return this._data.get(key) as T;
}
return defaultValue;
}
public static setValue(key: string, value: any): void {
this._data.set(key, value);
/** 数据改变后发送事件 */
GlobalEvent.send(key);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "e786f26b-332e-4bb2-88c4-4d1c25b675a5",
"files": [],
"subMetas": {},
"userData": {}
}