@cc-component/cc-ex-component 1.2.2 → 1.2.3

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.
@@ -5,21 +5,18 @@ const { ccclass, property } = _decorator;
5
5
 
6
6
  @ccclass('BaseReference')
7
7
  export class BaseReference extends Component {
8
+ refMap: Map<string, string> = new Map();
8
9
  private rc: ReferenceComponent;
9
- private isInit: boolean = false;
10
- private isLoad: boolean = false;
11
10
  private vmParams: any;
12
11
  viewModel: BaseViewModelData;
13
12
  param: any;
14
13
  initReferenceCollector() {
15
- if (this.isInit) return;
16
- this.isInit = true;
17
14
  this.rc = this.getComponent(ReferenceComponent);
15
+ this.refMap.forEach((value, key) => { this.defineProperty(key); });
16
+ console.error("1111")
18
17
  }
19
18
 
20
19
  onLoadFinish() {
21
- if (this.isLoad) return;
22
- this.isLoad = true;
23
20
  if (this.vmParams) this.viewModel?.refreshUI(this.vmParams)
24
21
  }
25
22
  //#endregion
@@ -532,12 +532,15 @@ export function BindViewModel(initialValue?: any) {
532
532
 
533
533
  // 定义装饰器
534
534
  export function Ref(target: any, propertyKey: string) {
535
- const originalOnLoad = target.constructor.prototype.onLoad;
536
- target.constructor.prototype.onLoad = function (this: any) {
537
- this.initReferenceCollector();
538
- this.defineProperty(propertyKey);
539
- originalOnLoad?.call(this);
540
- this.onLoadFinish();
541
- };
535
+ const refMap: Map<string, string> = target.constructor.prototype.refMap
536
+ refMap.set(propertyKey, propertyKey)
537
+ if (refMap.size <= 0) {
538
+ const originalOnLoad = target.constructor.prototype.onLoad;
539
+ target.constructor.prototype.onLoad = function (this: any) {
540
+ this.initReferenceCollector();
541
+ this.defineProperty(propertyKey);
542
+ originalOnLoad?.call(this);
543
+ this.onLoadFinish();
544
+ };
545
+ }
542
546
  }
543
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cc-component/cc-ex-component",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "engine": ">=3.8.6",
5
5
  "description": "系统组件添加常用扩展方法",
6
6
  "main": "index.ts",