@cc-component/cc-ex-component 1.1.6 → 1.1.7
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.
- package/assets/core/BaseReference.ts +40 -0
- package/assets/{video/VideoComponent.ts.meta → core/BaseReference.ts.meta} +1 -1
- package/assets/core/BaseViewModelData.ts +12 -0
- package/assets/{video/Interface.ts.meta → core/BaseViewModelData.ts.meta} +1 -1
- package/assets/core/ReferenceComponent.ts +317 -0
- package/assets/core/ViewModel.ts +542 -0
- package/assets/{video/IVideo.ts.meta → core/ViewModel.ts.meta} +9 -9
- package/assets/ex/EXButton.ts +191 -0
- package/assets/ex/EXButton.ts.meta +9 -0
- package/assets/ex/ExCommon.ts +6 -4
- package/assets/ex/ExTool.ts +116 -0
- package/assets/ex/ExTool.ts.meta +9 -0
- package/assets/lib/collectView/lib-ext/custom-grid-flow-layout.ts +105 -0
- package/assets/lib/collectView/lib-ext/custom-grid-flow-layout.ts.meta +9 -0
- package/assets/lib/collectView/lib-ext/horizontal-center-layout.ts +84 -0
- package/assets/lib/collectView/lib-ext/horizontal-center-layout.ts.meta +9 -0
- package/assets/lib/collectView/lib-ext/yx-card-page-layout.ts +132 -0
- package/assets/lib/collectView/lib-ext/yx-card-page-layout.ts.meta +9 -0
- package/assets/lib/collectView/lib-ext/yx-carousel-layout.ts +156 -0
- package/assets/lib/collectView/lib-ext/yx-carousel-layout.ts.meta +9 -0
- package/assets/lib/collectView/lib-ext/yx-cover-layout.ts +405 -0
- package/assets/lib/collectView/lib-ext/yx-cover-layout.ts.meta +9 -0
- package/assets/lib/collectView/lib-ext/yx-masonry-flow-layout.ts +194 -0
- package/assets/lib/collectView/lib-ext/yx-masonry-flow-layout.ts.meta +9 -0
- package/assets/lib/collectView/lib-ext/yx-page-view.ts +232 -0
- package/assets/lib/collectView/lib-ext/yx-page-view.ts.meta +9 -0
- package/assets/lib/collectView/lib-ext/yx-table-view.ts +159 -0
- package/assets/lib/collectView/lib-ext/yx-table-view.ts.meta +9 -0
- package/assets/lib/collectView/lib-ext.meta +9 -0
- package/assets/lib/collectView/lib_collect/yx-collection-view.ts +1549 -0
- package/assets/lib/collectView/lib_collect/yx-collection-view.ts.meta +9 -0
- package/assets/lib/collectView/lib_collect/yx-compact-flow-layout.ts +364 -0
- package/assets/lib/collectView/lib_collect/yx-compact-flow-layout.ts.meta +9 -0
- package/assets/lib/collectView/lib_collect/yx-flow-layout.ts +909 -0
- package/assets/lib/collectView/lib_collect/yx-flow-layout.ts.meta +9 -0
- package/assets/lib/collectView/lib_collect/yx-table-layout.ts +352 -0
- package/assets/lib/collectView/lib_collect/yx-table-layout.ts.meta +9 -0
- package/assets/lib/collectView/lib_collect.meta +9 -0
- package/assets/{video/list.meta → lib/collectView.meta} +9 -9
- package/assets/lib/tableView/IListView.ts +17 -0
- package/assets/lib/tableView/IListView.ts.meta +9 -0
- package/assets/lib/tableView/ListView.ts +197 -0
- package/assets/lib/tableView/ListView.ts.meta +9 -0
- package/assets/lib/tableView/ListViewPage.ts +1048 -0
- package/assets/lib/tableView/ListViewPage.ts.meta +9 -0
- package/assets/lib/tableView/ListViewPageLoop.ts +922 -0
- package/assets/lib/tableView/ListViewPageLoop.ts.meta +1 -0
- package/assets/lib/tableView/TableView.ts +82 -0
- package/assets/lib/tableView/TableView.ts.meta +9 -0
- package/assets/lib/tableView.meta +9 -0
- package/assets/{video.meta → lib.meta} +1 -1
- package/assets/platform/Interface.ts +15 -10
- package/assets/platform/android/AndroidModule.ts +12 -0
- package/assets/platform/android/AndroidModule.ts.meta +9 -0
- package/assets/platform/android/AndroidSDK.ts +1 -2
- package/assets/platform/base/PlatfprmModule.ts +44 -29
- package/assets/platform/base/SDKBase.ts +2 -2
- package/assets/platform/base/TTSDK.ts +21 -10
- package/assets/platform/base/WXSDK.ts +15 -16
- package/assets/platform/wx/MiniSDK.ts +41 -3
- package/assets/platform/wx/wxmini.d.ts +2 -2
- package/index.ts +0 -1
- package/package.json +1 -1
- package/assets/core/ReferenceCollector.ts +0 -172
- package/assets/video/IVideo.ts +0 -73
- package/assets/video/Interface.ts +0 -25
- package/assets/video/VideoComponent.prefab +0 -614
- package/assets/video/VideoComponent.prefab.meta +0 -13
- package/assets/video/VideoComponent.ts +0 -33
- package/assets/video/VideoManager.ts +0 -399
- package/assets/video/VideoManager.ts.meta +0 -9
- package/assets/video/VideoModule.ts +0 -137
- package/assets/video/VideoModule.ts.meta +0 -9
- package/assets/video/VideoPlayTT.ts +0 -338
- package/assets/video/VideoPlayTT.ts.meta +0 -9
- package/assets/video/VideoPlayWX.ts +0 -274
- package/assets/video/VideoPlayWX.ts.meta +0 -9
- package/assets/video/VideoPlayWeb.ts +0 -228
- package/assets/video/VideoPlayWeb.ts.meta +0 -9
- /package/assets/core/{ReferenceCollector.ts.meta → ReferenceComponent.ts.meta} +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { _decorator, Component, Node } from 'cc';
|
|
2
|
+
import { ReferenceComponent } from './ReferenceComponent';
|
|
3
|
+
const { ccclass, property } = _decorator;
|
|
4
|
+
|
|
5
|
+
@ccclass('BaseReference')
|
|
6
|
+
export class BaseReference extends Component {
|
|
7
|
+
rc: ReferenceComponent;
|
|
8
|
+
isInit: boolean = false;
|
|
9
|
+
initReferenceCollector() {
|
|
10
|
+
this.rc = this.getComponent(ReferenceComponent);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
defineProperty(propertyKey: string) {
|
|
14
|
+
Object.defineProperty(this, propertyKey, { get: () => this.rc.get(propertyKey) });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
// // 在 test 类中添加
|
|
19
|
+
// protected _bindings: { uiProp: string; dataPath: string }[] = [];
|
|
20
|
+
|
|
21
|
+
// // 数据变化回调
|
|
22
|
+
// protected _onDataChange(changedKey: string, newValue: any) {
|
|
23
|
+
// this._bindings.forEach(({ uiProp, dataPath }) => {
|
|
24
|
+
// // 检查变化的 key 是否匹配绑定路径(简单匹配)
|
|
25
|
+
// if (dataPath.endsWith(changedKey)) {
|
|
26
|
+
// const value = this._getNestedValue(this, dataPath);
|
|
27
|
+
// if (this[uiProp]?.string !== undefined) {
|
|
28
|
+
// this[uiProp].string = value; // 更新 Label
|
|
29
|
+
// }
|
|
30
|
+
// }
|
|
31
|
+
// });
|
|
32
|
+
// }
|
|
33
|
+
|
|
34
|
+
// // 工具方法:获取嵌套属性值
|
|
35
|
+
// protected _getNestedValue(obj: any, path: string) {
|
|
36
|
+
// return path.split('.').reduce((o, k) => o?.[k], obj);
|
|
37
|
+
// }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { Sprite } from "cc";
|
|
2
|
+
import { Enum } from "cc";
|
|
3
|
+
import { _decorator, Component, js, Node } from "cc";
|
|
4
|
+
import { EDITOR_NOT_IN_PREVIEW } from "cc/env";
|
|
5
|
+
|
|
6
|
+
const { ccclass, property, executeInEditMode, executionOrder, disallowMultiple, menu } = _decorator;
|
|
7
|
+
|
|
8
|
+
@ccclass("CollectorNodeData")
|
|
9
|
+
class CollectorNodeData {
|
|
10
|
+
@property({ readonly: true })
|
|
11
|
+
public key = "";
|
|
12
|
+
@property({ readonly: false })
|
|
13
|
+
public com: Node;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@ccclass("ReferenceComponent")
|
|
17
|
+
@disallowMultiple
|
|
18
|
+
@executeInEditMode(true)
|
|
19
|
+
@executionOrder(-100)
|
|
20
|
+
@menu("自动属性引用组件/ReferenceComponent")
|
|
21
|
+
export class ReferenceComponent extends Component {
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
private _refresh = false;
|
|
25
|
+
@property({ displayName: "复制属性" })
|
|
26
|
+
private get refresh() { return this._refresh; }
|
|
27
|
+
private set refresh(val: boolean) {
|
|
28
|
+
if (EDITOR_NOT_IN_PREVIEW) {
|
|
29
|
+
this.initNodeList();
|
|
30
|
+
this.genCode();
|
|
31
|
+
}
|
|
32
|
+
this._refresh = false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
private _refresh_bind = false;
|
|
37
|
+
@property({ displayName: "快速生成vm属性" })
|
|
38
|
+
private get refresh_bind() { return this._refresh_bind; }
|
|
39
|
+
private set refresh_bind(val: boolean) {
|
|
40
|
+
if (EDITOR_NOT_IN_PREVIEW) {
|
|
41
|
+
this.initNodeList();
|
|
42
|
+
this.genCodeBind();
|
|
43
|
+
}
|
|
44
|
+
this._refresh_bind = false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
private _refresh_bind_data = false;
|
|
49
|
+
@property({ displayName: "快速生成vm Data" })
|
|
50
|
+
private get refresh_bind_data() { return this._refresh_bind_data; }
|
|
51
|
+
private set refresh_bind_data(val: boolean) {
|
|
52
|
+
if (EDITOR_NOT_IN_PREVIEW) {
|
|
53
|
+
this.initNodeList();
|
|
54
|
+
this.genCodeVmData();
|
|
55
|
+
}
|
|
56
|
+
this._refresh_bind_data = false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@property({ type: CollectorNodeData, readonly: false })
|
|
60
|
+
private _nodes: CollectorNodeData[] = [];
|
|
61
|
+
@property({ type: CollectorNodeData, tooltip: "自动引用节点(名字以$开头的)", readonly: true })
|
|
62
|
+
private get nodes() { return this._nodes; }
|
|
63
|
+
private set nodes(val: CollectorNodeData[]) { this._nodes = val; }
|
|
64
|
+
|
|
65
|
+
private _isInitNodeMap = false;
|
|
66
|
+
private _nodeMap: Map<string, Node | Sprite> = new Map();
|
|
67
|
+
|
|
68
|
+
comList = ["EditBox", "Toggle", "ToggleContainer", "Slider", "Button", "ProgressBar", "YXCollectionView", "TableView"]
|
|
69
|
+
|
|
70
|
+
protected onLoad(): void {
|
|
71
|
+
if (EDITOR_NOT_IN_PREVIEW) {//处理编辑器逻辑
|
|
72
|
+
this.initNodeList();
|
|
73
|
+
} else {//处理运行时逻辑
|
|
74
|
+
this.initNodeMap();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private initNodeMap() {
|
|
79
|
+
if (this._isInitNodeMap) return;
|
|
80
|
+
this._isInitNodeMap = true;
|
|
81
|
+
this._nodeMap.clear();
|
|
82
|
+
for (const collectorNodeData of this.nodes) {
|
|
83
|
+
let key = collectorNodeData.key.trim();
|
|
84
|
+
if (!this._nodeMap.has(key)) {
|
|
85
|
+
this._nodeMap.set(key, collectorNodeData.com);
|
|
86
|
+
} else {
|
|
87
|
+
console.error("[MLogger Error]", this.node.name, "引用的节点名字重复 Key=" + key);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public getNode(key: string) {
|
|
93
|
+
if (this._nodeMap.size == 0) this.initNodeMap();
|
|
94
|
+
return this._nodeMap.get(key);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// public get(key: string, type: typeof Node): Node;
|
|
98
|
+
// public get<T extends Component>(key: string, type: new (...args: any[]) => T): T;
|
|
99
|
+
public get(key: string): any {
|
|
100
|
+
if (this._nodeMap.size == 0) this.initNodeMap();
|
|
101
|
+
let node = this._nodeMap.get(key);
|
|
102
|
+
// if (node?.isValid) {
|
|
103
|
+
// if (type as any === Node) {
|
|
104
|
+
// return node;
|
|
105
|
+
// } else {
|
|
106
|
+
// return node.getComponent(type);
|
|
107
|
+
// }
|
|
108
|
+
// }
|
|
109
|
+
return node;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
//#region 编辑器逻辑
|
|
113
|
+
|
|
114
|
+
/** 收集名字以$开头的节点 */
|
|
115
|
+
private _tag = "$";
|
|
116
|
+
|
|
117
|
+
private initNodeList() {
|
|
118
|
+
if (!EDITOR_NOT_IN_PREVIEW) return;
|
|
119
|
+
this.nodes.length = 0;
|
|
120
|
+
let nodes = this.getValidNode(this.node);
|
|
121
|
+
for (const node of nodes) {
|
|
122
|
+
//@ts-ignore
|
|
123
|
+
const nodeType = this.getPropertyType(node)
|
|
124
|
+
|
|
125
|
+
let refData = new CollectorNodeData();
|
|
126
|
+
let name = node.name.replace(this._tag, "").trim();
|
|
127
|
+
refData.key = name;
|
|
128
|
+
refData.com = (node.getComponent(`cc.${nodeType}`) ?? (node.getComponent(`${nodeType}`) ?? node)) as any;
|
|
129
|
+
this.nodes.push(refData);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
/** 获取符合需求的节点 */
|
|
135
|
+
private getValidNode(root: Node) {
|
|
136
|
+
if (!EDITOR_NOT_IN_PREVIEW) return;
|
|
137
|
+
let arr: Node[] = [];
|
|
138
|
+
let checkArr: Node[] = [];
|
|
139
|
+
checkArr.push(root);
|
|
140
|
+
while (checkArr.length > 0) {
|
|
141
|
+
let v = checkArr.shift();
|
|
142
|
+
let rc = v.getComponent(ReferenceComponent);
|
|
143
|
+
if (rc && rc != this) continue;
|
|
144
|
+
arr.push(...v.children.filter(v => {
|
|
145
|
+
const ok = this.isNodeValid(v)
|
|
146
|
+
return ok
|
|
147
|
+
}));
|
|
148
|
+
|
|
149
|
+
checkArr.push(...v.children);
|
|
150
|
+
}
|
|
151
|
+
return arr;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
private isNodeValid(node: Node) {
|
|
155
|
+
if (!EDITOR_NOT_IN_PREVIEW) return;
|
|
156
|
+
if (node.name.startsWith(this._tag)) return true;
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** 生成引用节点的获取代码 并复制到剪切板 */
|
|
161
|
+
private genCode() {
|
|
162
|
+
if (!EDITOR_NOT_IN_PREVIEW) return;
|
|
163
|
+
let text = "";
|
|
164
|
+
//生成get属性
|
|
165
|
+
this.nodes.forEach(data => {
|
|
166
|
+
let key = data.key;
|
|
167
|
+
if (text) text += "\n";
|
|
168
|
+
let name = key[0].toLowerCase() + key.substring(1);
|
|
169
|
+
//@ts-ignore
|
|
170
|
+
let line = `@Ref ${name}: ${this.getPropertyType(data.com)};`//`private get ${name}() { return this.rc.get("${key}", ${this.getPropertyType(data.node)}); }`;
|
|
171
|
+
text += line;
|
|
172
|
+
});
|
|
173
|
+
Editor.Clipboard.write("text", text);
|
|
174
|
+
console.log("已复制到剪切板");
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** 生成引用节点的获取代码 并复制到剪切板 */
|
|
178
|
+
private genCodeBind(isVm: boolean = true) {
|
|
179
|
+
if (!EDITOR_NOT_IN_PREVIEW) return;
|
|
180
|
+
let text = "";
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
const viewModel = `
|
|
184
|
+
// ✅ 使用新装饰器(自动响应式 + 路径推导)
|
|
185
|
+
@BindViewModel(new ViewModelData())
|
|
186
|
+
viewModel: ViewModelData;`
|
|
187
|
+
text += viewModel + "\n"
|
|
188
|
+
//生成get属性
|
|
189
|
+
this.nodes.forEach(data => {
|
|
190
|
+
let key = data.key;
|
|
191
|
+
if (text) text += "\n";
|
|
192
|
+
let name = key[0].toLowerCase() + key.substring(1);
|
|
193
|
+
const type = this.getPropertyType(data.com)
|
|
194
|
+
let bind_pix = `@Bind`
|
|
195
|
+
let event = `,{ event: (self) => { } }`
|
|
196
|
+
if (type === "YXCollectionView") {
|
|
197
|
+
event = `, {
|
|
198
|
+
layout: (self) => {
|
|
199
|
+
const layout = new YXFlowLayout();
|
|
200
|
+
layout.horizontalSpacing = 10;
|
|
201
|
+
layout.verticalSpacing = 20;
|
|
202
|
+
layout.itemSize = () => math.size(100, 100);
|
|
203
|
+
return layout;
|
|
204
|
+
},
|
|
205
|
+
cellForItemAt: (self, indexPath, collectionView) => {
|
|
206
|
+
let node = collectionView.dequeueReusableCell("cell", indexPath);
|
|
207
|
+
// TODO: configure cell
|
|
208
|
+
return node;
|
|
209
|
+
},
|
|
210
|
+
}`
|
|
211
|
+
bind_pix = `@BindCollect`
|
|
212
|
+
|
|
213
|
+
} else if (type === "TableView") {
|
|
214
|
+
event = `, {
|
|
215
|
+
itemSize: () => math.size(100, 100),
|
|
216
|
+
cellForItemAt: (self, indexPath, collectionView) => {
|
|
217
|
+
let node = collectionView.dequeueReusableCell("cell", indexPath)
|
|
218
|
+
return node
|
|
219
|
+
},
|
|
220
|
+
}`
|
|
221
|
+
bind_pix = `@BindTable`
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
let bind = `${bind_pix}("${name}"${this.comList.includes(type) ? event : ""})`
|
|
225
|
+
//@ts-ignore
|
|
226
|
+
let line = ` ${bind} @Ref ${name}: ${type};`
|
|
227
|
+
text += line;
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
Editor.Clipboard.write("text", text);
|
|
232
|
+
console.log("已复制到剪切板");
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** 生成引用节点的获取代码 并复制到剪切板 */
|
|
236
|
+
private genCodeVmData() {
|
|
237
|
+
if (!EDITOR_NOT_IN_PREVIEW) return;
|
|
238
|
+
let text = ""
|
|
239
|
+
//生成get属性
|
|
240
|
+
this.nodes.forEach(data => {
|
|
241
|
+
let key = data.key;
|
|
242
|
+
let name = key[0].toLowerCase() + key.substring(1);
|
|
243
|
+
const type = this.getPropertyType(data.com)
|
|
244
|
+
//@ts-ignore
|
|
245
|
+
let line = ` ${name}: ${this.getDataTypeByComponentType(type)};`//`private get ${name}() { return this.rc.get("${key}", ${this.getPropertyType(data.node)}); }`;
|
|
246
|
+
text += line + "\n";
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
text = `
|
|
250
|
+
class ViewModelData {
|
|
251
|
+
${text}
|
|
252
|
+
|
|
253
|
+
loadData() {
|
|
254
|
+
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
`;
|
|
258
|
+
Editor.Clipboard.write("text", text);
|
|
259
|
+
console.log("已复制到剪切板");
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** 获取属性类型名字 */
|
|
263
|
+
private getPropertyType(node: Node) {
|
|
264
|
+
if (!EDITOR_NOT_IN_PREVIEW) return;
|
|
265
|
+
if (!node) { return "Node" }
|
|
266
|
+
|
|
267
|
+
//自定义脚本
|
|
268
|
+
let comp = node.getComponent('MComponent');
|
|
269
|
+
if (comp) return js.getClassName(comp);
|
|
270
|
+
//自定义组件
|
|
271
|
+
if (node.getComponent("Switch")) return "Switch";
|
|
272
|
+
if (node.getComponent("MSlider")) return "MSlider";
|
|
273
|
+
if (node.getComponent("MToggle")) return "MToggle";
|
|
274
|
+
if (node.getComponent("MButton")) return "MButton";
|
|
275
|
+
if (node.getComponent("Dropdown")) return "Dropdown";
|
|
276
|
+
//自定义新曾
|
|
277
|
+
if (node.getComponent("TableView")) return "TableView";
|
|
278
|
+
if (node.getComponent("YXCollectionView")) return "YXCollectionView";
|
|
279
|
+
//UI组件
|
|
280
|
+
if (node.getComponent("cc.EditBox")) return "EditBox";
|
|
281
|
+
if (node.getComponent("cc.Toggle")) return "Toggle";
|
|
282
|
+
if (node.getComponent("cc.ToggleContainer")) return "ToggleContainer";
|
|
283
|
+
if (node.getComponent("cc.Slider")) return "Slider";
|
|
284
|
+
if (node.getComponent("cc.Button")) return "Button";
|
|
285
|
+
if (node.getComponent("cc.ProgressBar")) return "ProgressBar";
|
|
286
|
+
if (node.getComponent("cc.ScrollView")) return "ScrollView";
|
|
287
|
+
if (node.getComponent("cc.PageView")) return "PageView";
|
|
288
|
+
if (node.getComponent("cc.Animation")) return "Animation";
|
|
289
|
+
//渲染组件
|
|
290
|
+
if (node.getComponent("cc.Sprite")) return "Sprite";
|
|
291
|
+
if (node.getComponent("cc.Label")) return "Label";
|
|
292
|
+
if (node.getComponent("cc.RichText")) return "RichText";
|
|
293
|
+
if (node.getComponent("cc.ParticleSystem2D")) return "ParticleSystem2D";
|
|
294
|
+
if (node.getComponent("sp.Skeleton")) return "sp.Skeleton";
|
|
295
|
+
|
|
296
|
+
return "Node";
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
getDataTypeByComponentType(compType: string) {
|
|
300
|
+
const typeMap: Record<string, string> = {
|
|
301
|
+
'Label': 'string',
|
|
302
|
+
'RichText': 'string',
|
|
303
|
+
'Sprite': 'SpriteFrame',
|
|
304
|
+
'Button': 'boolean', // Button 通常绑定激活状态(true/false)
|
|
305
|
+
'ProgressBar': 'number', // 进度条应为 number (0~1)
|
|
306
|
+
'Skeleton': 'sp.SkeletonData',
|
|
307
|
+
'Slider': 'number',
|
|
308
|
+
'Toggle': 'boolean',
|
|
309
|
+
'EditBox': 'string',
|
|
310
|
+
'ToggleContainer': 'number', // 通常绑定选中项索引
|
|
311
|
+
'TableView': 'any[]', // 列表数据一般为数组
|
|
312
|
+
'YXCollectionView': 'any[]'
|
|
313
|
+
};
|
|
314
|
+
return typeMap[compType] ?? 'any'; // 默认 fallback
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
}
|