mirror of
				https://github.com/Gongxh0901/kunpolibrary
				synced 2025-10-31 11:25:46 +00:00 
			
		
		
		
	UI模块添加数据绑定装饰器
1.添加数据基类,子类自动添加代理,数据变化自动通知 2.支持同属性多装饰器
This commit is contained in:
		
							
								
								
									
										62
									
								
								demo/assets/script/Data/global/Level.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								demo/assets/script/Data/global/Level.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,62 @@ | ||||
| /** | ||||
|  * @Author: Gongxh | ||||
|  * @Date: 2025-08-19 | ||||
|  * @Description:  | ||||
|  */ | ||||
|  | ||||
| import { kunpo } from "../../header"; | ||||
|  | ||||
| export class Level extends kunpo.DataBase { | ||||
|  | ||||
|     private _levelid: number = 1; | ||||
|     private _storey: number = 0; | ||||
|     private _ispassed: boolean = false; | ||||
|     private _data: { min: number, max: number } = { min: 1, max: 100 }; | ||||
|  | ||||
|     constructor() { | ||||
|         super(); | ||||
|     } | ||||
|  | ||||
|     public get levelid() { return this._levelid; } | ||||
|     public set levelid(lv: number) { this._levelid = lv; } | ||||
|  | ||||
|     public get storey() { return this._storey; } | ||||
|     public set storey(storey: number) { this._storey = storey; } | ||||
|  | ||||
|     public get ispassed() { return this._ispassed; } | ||||
|     public set ispassed(bool: boolean) { this._ispassed = bool; } | ||||
|  | ||||
|     public get data(): { min: number, max: number } { return this._data; } | ||||
|     public set data(data: { min: number, max: number }) { this._data = data; } | ||||
|  | ||||
|     public init(data: any) { | ||||
|         this.data = { min: data.min, max: data.max }; | ||||
|  | ||||
|         this.refreshMin(data.min); | ||||
|         this.refreshMax(data.max); | ||||
|  | ||||
|         this.ispassed = data.ispassed; | ||||
|         this.levelid = data.levelid; | ||||
|         this.storey = data.storey; | ||||
|     } | ||||
|  | ||||
|     public refreshLevel(lv: number) { | ||||
|         this.levelid = lv; | ||||
|     } | ||||
|  | ||||
|     public refreshStorey(storey: number) { | ||||
|         this.storey = storey; | ||||
|     } | ||||
|  | ||||
|     public refreshBool(bool: boolean) { | ||||
|         this.ispassed = bool; | ||||
|     } | ||||
|  | ||||
|     public refreshMin(min: number) { | ||||
|         this.data.min = min; | ||||
|     } | ||||
|  | ||||
|     public refreshMax(max: number) { | ||||
|         this.data.max = max; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										9
									
								
								demo/assets/script/Data/global/Level.ts.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								demo/assets/script/Data/global/Level.ts.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| { | ||||
|   "ver": "4.0.24", | ||||
|   "importer": "typescript", | ||||
|   "imported": true, | ||||
|   "uuid": "632daee7-7c2c-4baf-a4dd-d1a12ad91169", | ||||
|   "files": [], | ||||
|   "subMetas": {}, | ||||
|   "userData": {} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user