mirror of
https://gitee.com/dgflash/oops-plugin-framework.git
synced 2026-05-22 17:06:53 +08:00
DelegateComponent添加onCloseWindowBefore窗口关闭之前事件
This commit is contained in:
@@ -19,6 +19,8 @@ const EventOnRemoved: string = "onRemoved";
|
||||
export class DelegateComponent extends Component {
|
||||
/** 视图参数 */
|
||||
vp: ViewParams = null!;
|
||||
/** 关闭窗口之前 */
|
||||
onCloseWindowBefore: Function = null!;
|
||||
/** 界面关闭回调 - 包括关闭动画播放完(辅助框架内存业务流程使用) */
|
||||
onCloseWindow: Function = null!;
|
||||
|
||||
@@ -69,6 +71,10 @@ export class DelegateComponent extends Component {
|
||||
|
||||
/** 窗口关闭前动画处理完后的回调方法,主要用于释放资源 */
|
||||
private onBeforeRemoveNext(isDestroy?: boolean) {
|
||||
if (this.onCloseWindowBefore) {
|
||||
this.onCloseWindowBefore();
|
||||
this.onCloseWindowBefore = null!;
|
||||
}
|
||||
this.removed(this.vp, isDestroy);
|
||||
}
|
||||
|
||||
|
||||
@@ -86,26 +86,27 @@ export class ModuleUtil {
|
||||
* @param ctor 界面逻辑组件
|
||||
* @param uiId 界面资源编号
|
||||
* @param isDestroy 是否释放界面缓存(默认为释放界面缓存)
|
||||
* @param onCloseWindow 窗口动画关闭完成事件
|
||||
* @param onRemoved 窗口关闭完成事件
|
||||
*/
|
||||
static removeViewUi(ent: ecs.Entity, ctor: CompType<ecs.IComp>, uiId: number, isDestroy: boolean = true, onCloseWindow?: Function) {
|
||||
static removeViewUi(ent: ecs.Entity, ctor: CompType<ecs.IComp>, uiId: number, isDestroy: boolean = true, onRemoved?: Function) {
|
||||
const node = oops.gui.get(uiId);
|
||||
if (!node) {
|
||||
if (onCloseWindow) onCloseWindow();
|
||||
if (onRemoved) onRemoved();
|
||||
return;
|
||||
}
|
||||
|
||||
const comp = node.getComponent(DelegateComponent);
|
||||
if (comp) {
|
||||
comp.onCloseWindow = () => {
|
||||
comp.onCloseWindowBefore = () => {
|
||||
ent.remove(ctor, isDestroy);
|
||||
if (onCloseWindow) onCloseWindow();
|
||||
if (onRemoved) onRemoved();
|
||||
};
|
||||
}
|
||||
else {
|
||||
ent.remove(ctor, isDestroy);
|
||||
if (onCloseWindow) onCloseWindow();
|
||||
if (onRemoved) onRemoved();
|
||||
}
|
||||
|
||||
oops.gui.remove(uiId, isDestroy);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user