mirror of
				https://github.com/Gongxh0901/kunpolibrary
				synced 2025-10-31 03:15:45 +00:00 
			
		
		
		
	仓库中添加内置的demo
This commit is contained in:
		
							
								
								
									
										24
									
								
								demo/assets/script/Data/DataHelper.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								demo/assets/script/Data/DataHelper.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| /** | ||||
|  * @Author: Gongxh | ||||
|  * @Date: 2025-02-17 | ||||
|  * @Description: 准备一个数据类 | ||||
|  */ | ||||
|  | ||||
| import { GlobalEvent } from "kunpocc-event"; | ||||
|  | ||||
| export class DataHelper { | ||||
|     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); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										9
									
								
								demo/assets/script/Data/DataHelper.ts.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								demo/assets/script/Data/DataHelper.ts.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| { | ||||
|   "ver": "4.0.24", | ||||
|   "importer": "typescript", | ||||
|   "imported": true, | ||||
|   "uuid": "7340bacc-d167-47e8-a83b-2224c46b7fd0", | ||||
|   "files": [], | ||||
|   "subMetas": {}, | ||||
|   "userData": {} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user