dzkcc-mflow 0.0.41 → 0.0.42

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.
@@ -54,7 +54,6 @@ export interface UIPreloadConfig {
54
54
  delay?: number;
55
55
  }
56
56
  interface IInternalView extends IView {
57
- __group__: string | undefined;
58
57
  __isIView__: boolean;
59
58
  }
60
59
  type ICocosView = IInternalView & Component;
@@ -77,6 +76,7 @@ declare abstract class CcocosUIManager implements IUIManager {
77
76
  export declare class UIManager extends CcocosUIManager {
78
77
  private _cache;
79
78
  private _groupStacks;
79
+ private _view2group;
80
80
  private _inputBlocker;
81
81
  private _loadingView;
82
82
  private _loadingPromises;
@@ -92,6 +92,7 @@ class UIManager extends CcocosUIManager {
92
92
  super();
93
93
  this._cache = new Map();
94
94
  this._groupStacks = new Map();
95
+ this._view2group = new Map();
95
96
  this._inputBlocker = null;
96
97
  this._loadingView = null;
97
98
  this._loadingPromises = new Map();
@@ -281,12 +282,10 @@ class UIManager extends CcocosUIManager {
281
282
  if (!view) {
282
283
  return;
283
284
  }
284
- // 区分两种情况处理:
285
- // 1. 如果视图有 __group__ 属性且不为 undefined,说明是通过 openAndPush 打开的栈式UI
286
- // 2. 否则是通过 open 打开的普通 UI
287
- if (view.__group__ && view.__group__.trim() != "") {
285
+ const group = this._view2group.get(view);
286
+ if (group && group.trim() != "") {
288
287
  // 栈式UI:调用 _internalCloseAndPop 来处理返回逻辑
289
- this._internalCloseAndPop(view.__group__, false);
288
+ this._internalCloseAndPop(group, false);
290
289
  }
291
290
  else {
292
291
  // 普通UI:直接关闭该视图
@@ -500,7 +499,7 @@ class UIManager extends CcocosUIManager {
500
499
  top.node.removeFromParent();
501
500
  }
502
501
  // 标记视图所属组并入栈
503
- view.__group__ = group;
502
+ this._view2group.set(view, group);
504
503
  stack.push(view);
505
504
  addChild(view.node);
506
505
  this._adjustMaskLayer();
@@ -531,7 +530,9 @@ class UIManager extends CcocosUIManager {
531
530
  this._blockInput(true);
532
531
  try {
533
532
  // 移除当前栈顶视图
534
- yield this._remove(stack.pop(), destroy);
533
+ const removed = stack.pop();
534
+ yield this._remove(removed, destroy);
535
+ this._view2group.delete(removed);
535
536
  // 恢复上一个视图
536
537
  const top = stack[stack.length - 1];
537
538
  if (top) {
@@ -570,9 +571,8 @@ class UIManager extends CcocosUIManager {
570
571
  yield this._remove(viewInstance, destroy);
571
572
  return;
572
573
  }
573
- // 处理视图实例
574
+ // 获取视图实例
574
575
  const viewInstance = viewKeyOrInstance;
575
- viewInstance.__group__ = undefined;
576
576
  if (!skipAnimation) {
577
577
  // * 播放关闭动画,使用async是必要的,因为:
578
578
  // * 确保动画播放完成后再执行onExit和节点移除,不然还没播放动画了,UI就已经没了
@@ -619,6 +619,9 @@ class UIManager extends CcocosUIManager {
619
619
  this._remove(view, destroy, true);
620
620
  }
621
621
  }
622
+ for (const view of this._view2group.keys()) {
623
+ this._view2group.delete(view);
624
+ }
622
625
  // 调整遮罩层级
623
626
  this._adjustMaskLayer();
624
627
  }
@@ -637,6 +640,9 @@ class UIManager extends CcocosUIManager {
637
640
  }
638
641
  }
639
642
  }
643
+ for (const view of this._view2group.keys()) {
644
+ this._view2group.delete(view);
645
+ }
640
646
  // 清空所有栈
641
647
  this._groupStacks.clear();
642
648
  // 调整遮罩
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dzkcc-mflow",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
4
4
  "description": "A modular design and process management framework developed for the cocos engine, suitable for decoupling and dependency injection.",
5
5
  "author": "duanzhk",
6
6
  "license": "MIT",