@kkarum/framework 2.3.20 → 2.3.22
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/docs/FRAMEWORK_USAGE.md +46 -31
- package/package.json +1 -1
package/docs/FRAMEWORK_USAGE.md
CHANGED
|
@@ -45,6 +45,7 @@ export class ShopLayerController extends FW.LayerController {
|
|
|
45
45
|
- 事件绑定走 `LayerController.registerEvent()`、`cc()`、`fw()` 或 `FW.Entry.evtMgr`。
|
|
46
46
|
- 定时器走 `FW.Entry.timeMgr`。
|
|
47
47
|
- 可取消/带重试异步流程走 `FW.Entry.promiseMgr`。
|
|
48
|
+
- 所有的Layer.ts都不需要挂载到对应的节点或预制体上。
|
|
48
49
|
|
|
49
50
|
## 新增业务 Bundle
|
|
50
51
|
|
|
@@ -52,12 +53,13 @@ export class ShopLayerController extends FW.LayerController {
|
|
|
52
53
|
|
|
53
54
|
```text
|
|
54
55
|
assets/<bundle>/
|
|
55
|
-
config/<Bundle>AssetConfig.ts
|
|
56
|
-
data/<Bundle>Data.ts
|
|
57
|
-
logic/<Bundle>Logic.ts
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
script/config/<Bundle>AssetConfig.ts
|
|
57
|
+
script/data/<Bundle>Data.ts
|
|
58
|
+
script/logic/<Bundle>Logic.ts
|
|
59
|
+
script/<Bundle>Registry.ts
|
|
60
|
+
script/controller/<Feature>/<Feature>LayerController.ts
|
|
61
|
+
script/layer/<Feature>/<Feature>Layer.ts
|
|
62
|
+
res/layer/<Feature>Layer.prefab
|
|
61
63
|
```
|
|
62
64
|
|
|
63
65
|
注册类示例:
|
|
@@ -181,7 +183,9 @@ export class ShopLayerController extends FW.LayerController {
|
|
|
181
183
|
isRepeatOpen = false;
|
|
182
184
|
|
|
183
185
|
get layerAssetProperty(): FW.AssetProperty {
|
|
184
|
-
return this.getConfig<ShopAssetConfig>().preLoad.prefab[
|
|
186
|
+
return this.getConfig<ShopAssetConfig>().preLoad.prefab[
|
|
187
|
+
"ShopLayer"
|
|
188
|
+
] as FW.AssetProperty;
|
|
185
189
|
}
|
|
186
190
|
|
|
187
191
|
onInit(args?: { tab?: string }) {
|
|
@@ -238,17 +242,21 @@ this.fw("SHOP_GOODS_CHANGED", this.renderGoods);
|
|
|
238
242
|
|
|
239
243
|
```ts
|
|
240
244
|
this.registerEvent({
|
|
241
|
-
CCEvent: [
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
245
|
+
CCEvent: [
|
|
246
|
+
{
|
|
247
|
+
target: buyButton,
|
|
248
|
+
eventName: cc.Node.EventType.TOUCH_END,
|
|
249
|
+
responseInterval: 500,
|
|
250
|
+
cb: this.onBuyClick,
|
|
251
|
+
},
|
|
252
|
+
],
|
|
253
|
+
FWEvent: [
|
|
254
|
+
{
|
|
255
|
+
eventName: "SHOP_REFRESH",
|
|
256
|
+
responseInterval: 200,
|
|
257
|
+
cb: this.onRefresh,
|
|
258
|
+
},
|
|
259
|
+
],
|
|
252
260
|
});
|
|
253
261
|
```
|
|
254
262
|
|
|
@@ -257,9 +265,13 @@ this.registerEvent({
|
|
|
257
265
|
## 定时器
|
|
258
266
|
|
|
259
267
|
```ts
|
|
260
|
-
const schedule = FW.Entry.timeMgr.scheduleOnce(
|
|
261
|
-
|
|
262
|
-
|
|
268
|
+
const schedule = FW.Entry.timeMgr.scheduleOnce(
|
|
269
|
+
() => {
|
|
270
|
+
this.refreshGoods();
|
|
271
|
+
},
|
|
272
|
+
1,
|
|
273
|
+
this,
|
|
274
|
+
);
|
|
263
275
|
|
|
264
276
|
FW.Entry.timeMgr.schedule(
|
|
265
277
|
() => this.tick(),
|
|
@@ -277,16 +289,19 @@ FW.Entry.timeMgr.unSchedule(this);
|
|
|
277
289
|
## Promise
|
|
278
290
|
|
|
279
291
|
```ts
|
|
280
|
-
const proxy = FW.Entry.promiseMgr.execute<string>(
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
292
|
+
const proxy = FW.Entry.promiseMgr.execute<string>(
|
|
293
|
+
(resolve, reject, signal) => {
|
|
294
|
+
// 异步操作
|
|
295
|
+
signal.addEventListener("abort", () => {
|
|
296
|
+
// 清理
|
|
297
|
+
});
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
timeout: 10000,
|
|
301
|
+
retryCount: 3,
|
|
302
|
+
retryInterval: 2,
|
|
303
|
+
},
|
|
304
|
+
);
|
|
290
305
|
|
|
291
306
|
const result = await proxy.promise;
|
|
292
307
|
```
|