@cc-component/cc-ex-component 1.5.2 → 1.5.4

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.
@@ -225,17 +225,17 @@ export class ReferenceComponent extends Component {
225
225
  let name = key[0].toLowerCase() + key.substring(1);
226
226
  const type = this.getPropertyType(data.com)
227
227
  let bind_pix = `@Bind`
228
- let event = `,{ event(this:${className}) { } }`
228
+ let event = `,{ event(this:${className}Window) { } }`
229
229
  if (type === "YXCollectionView") {
230
230
  event = `, {
231
- layout(this:${className}) {
231
+ layout(this:${className}Window) {
232
232
  const layout = new YXFlowLayout();
233
233
  layout.horizontalSpacing = 10;
234
234
  layout.verticalSpacing = 20;
235
235
  layout.itemSize = () => math.size(100, 100);
236
236
  return layout;
237
237
  },
238
- cellForItemAt(this:${className}, indexPath, collectionView) {
238
+ cellForItemAt(this:${className}Window, indexPath, collectionView) {
239
239
  const node = collectionView.dequeueReusableCell("cell", indexPath);
240
240
  //node.getComponent(TableVIewItem).refreshUI(this.viewModel.${name}[indexPath.row])
241
241
  return node;
@@ -246,7 +246,7 @@ export class ReferenceComponent extends Component {
246
246
  } else if (type === "TableView") {
247
247
  event = `, {
248
248
  itemSize: () => math.size(100, 100),
249
- cellForItemAt(this:${className}, indexPath, collectionView) {
249
+ cellForItemAt(this:${className}Window, indexPath, collectionView) {
250
250
  const node = collectionView.dequeueReusableCell("cell", indexPath)
251
251
  //node.getComponent(TableVIewItem).refreshUI(this.viewModel.${name}[indexPath.row])
252
252
  return node
@@ -323,11 +323,6 @@ ${sx}
323
323
  //#region ⚠️ ------------数据对象
324
324
  class ${data} extends BaseViewModelData implements ${iinterface} {
325
325
  ${sx}
326
-
327
- // ✅ 本界面内部调用
328
- loadData() {
329
- ${sx_this}
330
- }
331
326
  }
332
327
  //#endregion END`;
333
328
  if (isCopy) {
@@ -376,7 +371,7 @@ const { ccclass, property } = _decorator;
376
371
  }
377
372
 
378
373
  start() {
379
- this.viewModel.loadData()
374
+
380
375
  }`
381
376
  const classView = `
382
377
  @BindViewModel(${className}Data)
@@ -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,15 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
300
294
  }
301
295
 
302
296
 
297
+ managerData() {
298
+ if (this.config) {
299
+ const module = this.config.module;
300
+ const name = this.config.name.replace('Window', '');
301
+ const manager: any = (js.getClassByName(`${module}Manager`))
302
+ manager.Ins[`${name}Data`] = this.viewModel
303
+ }
304
+ }
305
+
303
306
 
304
307
  protected onEnable(): void {
305
308
  this.onTouch()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cc-component/cc-ex-component",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
4
4
  "engine": ">=3.8.6",
5
5
  "description": "系统组件添加常用扩展方法",
6
6
  "main": "index.ts",