@cc-component/cc-ex-component 1.1.9 → 1.2.1

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,11 +5,12 @@ const { ccclass, property } = _decorator;
5
5
 
6
6
  @ccclass('BaseReference')
7
7
  export class BaseReference extends Component {
8
- rc: ReferenceComponent;
9
- isInit: boolean = false;
10
- isLoad: boolean = false;
11
- vmParams: any;
8
+ private rc: ReferenceComponent;
9
+ private isInit: boolean = false;
10
+ private isLoad: boolean = false;
11
+ private vmParams: any;
12
12
  viewModel: BaseViewModelData;
13
+ param: any;
13
14
  initReferenceCollector() {
14
15
  if (this.isInit) return;
15
16
  this.isInit = true;
@@ -67,6 +67,7 @@ export class ReferenceComponent extends Component {
67
67
  this._refresh_bind_data_all = false;
68
68
  }
69
69
 
70
+ isComDebug = true
70
71
 
71
72
  @property({ type: CollectorNodeData, readonly: false })
72
73
  private _nodes: CollectorNodeData[] = [];
@@ -198,9 +199,13 @@ export class ReferenceComponent extends Component {
198
199
  // const match = com.name.match(/<([^>]+)>/);
199
200
  // const className = match && match[1] ? match[1] : "any"
200
201
  const className = this.node.name
201
-
202
- console.error("[MLogger Error]", className)
203
- const viewModel = `
202
+ let data = `${className}Data`
203
+ let iinterface = `I${className}Data`
204
+ //console.error("[MLogger Error]", className)
205
+ const viewModel = `
206
+ // ✅ 外部界面调用,刷新UI
207
+ public refreshUI(data: ${iinterface}) { super.refreshUI(data); }
208
+
204
209
  //#region ✅ 使用新装饰器(自动响应式 + 路径推导)
205
210
  @BindViewModel(new ${className}Data())
206
211
  viewModel: ${className}Data;`
@@ -320,21 +325,28 @@ ${sx_this}
320
325
 
321
326
 
322
327
 
328
+
323
329
  /** 生成引用节点的获取代码 并复制到剪切板 */
324
330
  private genCodeVmDataAll() {
325
331
  if (!EDITOR_NOT_IN_PREVIEW) return;
326
- let text = `
327
- import { _decorator, Component, Node } from 'cc';
332
+ let importStr = `
333
+ import { Label, RichText, ProgressBar, Sprite, EditBox, Toggle, Slider, ToggleContainer, Button, math, SpriteFrame, _decorator } from 'cc';
334
+ import { ViewModel, BindViewModel, BindTable, BindCollect, Bind, Ref, BaseViewModelData, YXCollectionView, YXFlowLayout, TableView, BaseReference } from 'db://assets/pkg-export/@cc-component/cc-ex-component';
335
+ const { ccclass, property } = _decorator;`
336
+
337
+ if (this.isComDebug) {
338
+ importStr = `
339
+ import { _decorator, SpriteFrame, Label, RichText, ProgressBar, Sprite, EditBox, Toggle, Slider, ToggleContainer, Button, math } from 'cc';
328
340
  import { BaseReference } from '../assets/core/BaseReference';
329
- import { Bind, BindCollect, BindTable, BindViewModel, Ref, ViewModel } from '../assets/core/ViewModel';
330
- import { SpriteFrame } from 'cc';
331
- import { Label, RichText, ProgressBar, Sprite, EditBox, Toggle, Slider, ToggleContainer, Button } from 'cc';
341
+ import { BaseViewModelData } from '../assets/core/BaseViewModelData';
342
+ import { ViewModel, BindViewModel, Bind, Ref, BindTable, BindCollect } from '../assets/core/ViewModel';
332
343
  import { YXCollectionView } from '../assets/lib/collectView/lib_collect/yx-collection-view';
333
- import { TableView } from '../assets/lib/tableView/TableView';
334
- import { math } from 'cc';
335
344
  import { YXFlowLayout } from '../assets/lib/collectView/lib_collect/yx-flow-layout';
336
- import { BaseViewModelData } from '../assets/core/BaseViewModelData';
337
- const { ccclass, property } = _decorator; \n`
345
+ import { TableView } from '../assets/lib/tableView/TableView';
346
+ const { ccclass, property } = _decorator;
347
+ `
348
+ }
349
+ let text = `${importStr}\n`
338
350
  text += this.genCodeVmData(false)
339
351
  const sx = this.genCodeBind(false, true)
340
352
  const className = this.node.name
@@ -348,10 +360,7 @@ const { ccclass, property } = _decorator; \n`
348
360
 
349
361
  start() {
350
362
  this.viewModel.loadData()
351
- }
352
-
353
- // ✅ 外部界面调用,刷新UI
354
- public refreshUI(data: ${iinterface}) { super.refreshUI(data); }`
363
+ }`
355
364
  const classView = `
356
365
  @ccclass('${className}')
357
366
  export class ${className} extends ViewModel(BaseReference) {${sx.text}\n${onload}\n\n${sx.event}\n}`
@@ -363,6 +372,7 @@ export class ${className} extends ViewModel(BaseReference) {${sx.text}\n${onload
363
372
  console.log("已复制到剪切板");
364
373
  }
365
374
 
375
+
366
376
  /** 获取属性类型名字 */
367
377
  private getPropertyType(node: Node) {
368
378
  if (!EDITOR_NOT_IN_PREVIEW) return;
@@ -9,7 +9,6 @@ import { EditBox, Toggle, Slider, Button, ProgressBar, Node } from 'cc';
9
9
  import { RichText } from 'cc';
10
10
  import { Component } from 'cc';
11
11
  import { js } from 'cc';
12
- import { escape } from 'querystring';
13
12
  import { IIndexPath } from '../lib/tableView/IListView';
14
13
  import { ListView } from '../lib/tableView/ListView';
15
14
  import { TableView } from '../lib/tableView/TableView';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cc-component/cc-ex-component",
3
- "version": "1.1.9",
3
+ "version": "1.2.1",
4
4
  "engine": ">=3.8.6",
5
5
  "description": "系统组件添加常用扩展方法",
6
6
  "main": "index.ts",