修复多Popup窗口叠加时,点击非界面区域关闭窗口不会关闭当前窗口下层的窗口

This commit is contained in:
dgflash
2025-03-12 19:28:09 +08:00
parent 17b8ba21ba
commit a6d0d8e5f4
2 changed files with 6 additions and 5 deletions

View File

@@ -106,12 +106,12 @@ export class LayerPopUp extends LayerUI {
/** 触摸非窗口区域关闭 */
private onTouchEnd(event: EventTouch) {
this.ui_nodes.forEach(vp => {
// 关闭已显示的界面
if (this.ui_nodes.size > 0) {
let vp = this.ui_nodes.array[this.ui_nodes.size - 1];
if (vp.valid && vp.config.vacancy) {
this.remove(vp.config.prefab, vp.config.destroy);
}
});
}
}
/** 关闭触摸非窗口区域关闭 */

View File

@@ -1,4 +1,5 @@
import { instantiate, Node, Prefab, SafeArea, Widget } from "cc";
import { Collection } from "db://oops-framework/libs/collection/Collection";
import { oops } from "../../Oops";
import { UICallbacks, ViewParams } from "./Defines";
import { DelegateComponent } from "./DelegateComponent";
@@ -9,7 +10,7 @@ export class LayerUI extends Node {
/** 全局窗口打开失败 */
onOpenFailure: Function = null!;
/** 显示界面节点集合 */
protected ui_nodes = new Map<string, ViewParams>();
protected ui_nodes = new Collection<string, ViewParams>();
/** 被移除的界面缓存数据 */
protected ui_cache = new Map<string, ViewParams>();
@@ -139,7 +140,7 @@ export class LayerUI extends Node {
* @param isDestroy 移除后是否释放
*/
remove(prefabPath: string, isDestroy?: boolean): void {
let release = undefined;
let release: any = undefined;
if (isDestroy !== undefined) release = isDestroy;
// 界面移出舞台