@cc-component/cc-ex-component 1.5.3 → 1.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -112,9 +112,8 @@ export function BindViewModel<T extends new () => any>(constructor: T) {
112
112
  updateStatus(data, com, value_data, this);
113
113
  }
114
114
  // 创建实例并转为响应式
115
- const vm_data = 'viewModel'
116
115
  const instance = new constructor();
117
- this[vm_data] = this._makeReactive(instance, vm_data);
116
+ this[baseData] = this._makeReactive(instance, baseData);
118
117
  this.onLoadFinish();
119
118
  onLoad.call(this);
120
119
 
@@ -281,17 +280,12 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
281
280
  this._bindings = [];
282
281
  // 2. 替换 data 为普通对象(破坏 Proxy 响应式)
283
282
  this.viewModel = null
284
-
283
+ this.managerData()
285
284
  }
286
285
 
287
286
  protected onLoad(): void {
288
287
  super.onLoad()
289
- if (this.config) {
290
- const module = this.config.module;
291
- const name = this.config.name.replace('Window', '');
292
- const manager: any = (js.getClassByName(`${module}Manager`))
293
- manager.Ins[`${name}Data`] = this.viewModel
294
- }
288
+ this.managerData()
295
289
  }
296
290
  // 在 withDataBinding 返回的 class 中
297
291
  protected onDestroy(): void {
@@ -300,6 +294,10 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
300
294
  }
301
295
 
302
296
 
297
+ managerData() {
298
+ ExComponentModule.EmitUIWindow(this.config)
299
+ }
300
+
303
301
 
304
302
  protected onEnable(): void {
305
303
  this.onTouch()
@@ -15,6 +15,7 @@ export class ExComponentModule {
15
15
  param: { click: (comp: Button) => void }
16
16
  paramSprite: { loadSprite: (param: { bundle: string, path: string }) => Promise<SpriteFrame>, getSprite: (param: { bundle: string, path: string }) => SpriteFrame }
17
17
  paramSpine: { loadSpine: (param: { bundle: string, path: string }) => Promise<sp.SkeletonData>, getSpine: (param: { bundle: string, path: string }) => sp.SkeletonData }
18
+ paramUIWindow: { onLoad: (config: any) => void }
18
19
 
19
20
  ResetBaseWindow: string = "BaseWindow";
20
21
  static Init() {
@@ -30,6 +31,9 @@ export class ExComponentModule {
30
31
  if (!isGet) ExComponentModule.Ins.ResetBaseWindow = name
31
32
  return ExComponentModule.Ins.ResetBaseWindow
32
33
  }
34
+ static OnVMManager(param: { onLoad: (config: any) => void }) {
35
+ ExComponentModule.Ins.paramUIWindow = param
36
+ }
33
37
 
34
38
  static OnLoadSprite(param: { loadSprite: (param: { bundle: string, path: string }) => Promise<SpriteFrame>, getSprite: (param: { bundle: string, path: string }) => SpriteFrame }) {
35
39
  ExComponentModule.Ins.paramSprite = param
@@ -56,6 +60,10 @@ export class ExComponentModule {
56
60
  static EmitGetSpine(param: any): sp.SkeletonData {
57
61
  return ExComponentModule.Ins.paramSpine?.getSpine?.(param)
58
62
  }
63
+
64
+ static EmitUIWindow(this: any, param: any) {
65
+ return ExComponentModule.Ins.paramUIWindow?.onLoad?.call(this, param)
66
+ }
59
67
  }
60
68
  window.ExComponentModule = ExComponentModule;
61
69
 
@@ -13,13 +13,37 @@ declare global {
13
13
  function OnLoadSpine(param: { loadSpine: (param: { bundle: string, path: string }) => Promise<sp.SkeletonData>, getSpine: (param: { bundle: string, path: string }) => sp.SkeletonData });
14
14
  /**重置基础窗口 */
15
15
  function ResetBaseWindow(name?: string, isGet?: boolean);
16
+ /**监听UI onLoad 给模块manager 赋值 */
17
+ function OnVMManager(param: {
18
+ onLoad: (config: {
19
+ module: string,
20
+ layer: string,
21
+ path: string,
22
+ bundle: string,
23
+ name?: string,/**窗口名称 */
24
+ index?: number,
25
+ is_load_sub?: boolean,
26
+ /**是否记录-不记录可重复打开窗口 */
27
+ is_record?: boolean,
28
+ }) => void
29
+ });
16
30
  /**组件:内部使用方法 */
17
31
  function Emit(btn: Button);
18
-
19
32
  //#region 组件:内部使用方法----------------
20
33
  function EmitLoadSprite(param: any): Promise<SpriteFrame>;
21
34
  function EmitGetSprite(param: any): SpriteFrame;
22
35
  function EmitLoadSpine(param: any): Promise<sp.SkeletonData>;
23
36
  function EmitGetSpine(param: any): sp.SkeletonData;
37
+ function EmitUIWindow(this: any, param: {
38
+ module: string,
39
+ layer: string,
40
+ path: string,
41
+ bundle: string,
42
+ name?: string,/**窗口名称 */
43
+ index?: number,
44
+ is_load_sub?: boolean,
45
+ /**是否记录-不记录可重复打开窗口 */
46
+ is_record?: boolean,
47
+ });
24
48
  }
25
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cc-component/cc-ex-component",
3
- "version": "1.5.3",
3
+ "version": "1.5.5",
4
4
  "engine": ">=3.8.6",
5
5
  "description": "系统组件添加常用扩展方法",
6
6
  "main": "index.ts",