@cc-component/cc-ex-component 1.1.9 → 1.2.0
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.
|
@@ -67,6 +67,7 @@ export class ReferenceComponent extends Component {
|
|
|
67
67
|
this._refresh_bind_data_all = false;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
isComDebug = false
|
|
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
|
-
|
|
203
|
-
|
|
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
|
|
327
|
-
import {
|
|
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 {
|
|
330
|
-
import {
|
|
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 {
|
|
337
|
-
const { ccclass, property } = _decorator;
|
|
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;
|