Files
fc/dev/project/library/imports/25/257baa51-608a-492f-aae5-4a677ff9244d.js
T

128 lines
2.8 KiB
JavaScript
Raw Normal View History

2026-05-24 10:21:26 +08:00
"use strict";
cc._RF.push(module, '257bapRYIpJL6rlSmd/+SRN', 'bridge.window');
// Scripts/zbridge/ui/bridge.window.js
"use strict";
/*******************************************************************************
*
* 老版本桥接过渡 --- BaseView过渡到组件化模式
*
*
******************************************************************************/
cc.Class({
"extends": cc.Component,
properties: {
BKEY: {
"default": "BRIDGE_WINDOW"
}
},
// 重载:参数打开
onOpenConfigs: function onOpenConfigs(_params) {},
// 重载:关闭前
onPreClosed: function onPreClosed() {},
// 不要重载
bindView: function bindView(_baseView) {
this.baseView = _baseView;
},
// 不要重载
openConfigs: function openConfigs(_params) {
if (!this.baseView) {
nx.error("缺少桥接绑定BaseView!");
}
// 统一关闭调用支持
this.cbClose = null;
if (_params) {
this.cbClose = _params.cbClose || null;
}
this.onOpenConfigs(_params);
},
// 销毁
onDestroy: function onDestroy() {
// 视图监听释放
this.vunbind();
// 事件监听释放
this.unbindGEvents();
// 关闭通告
if (this.cbClose) {
nx.dt.fnInvoke(this.cbClose);
this.cbClose = null;
}
},
// 关闭
close: function close() {
// 关闭前
this.onPreClosed();
// 视图监听释放
this.vunbind();
// 事件监听释放
this.unbindGEvents();
// 关闭view
if (this.baseView) {
this.baseView.close(true);
}
},
// 延迟关闭
delayClose: function delayClose(_delay) {
var _this = this;
if (_delay === void 0) {
_delay = 0.01;
}
this.scheduleOnce(function () {
_this.close();
}, _delay);
},
// 桥接视图监听
vbind: function vbind(_lst) {
if (nx.bridge && nx.dt.arrNEmpty(_lst)) {
nx.bridge.vbind(this, _lst);
}
},
// 桥接监听视图解除
vunbind: function vunbind() {
if (window.nx && nx.bridge) {
nx.bridge.vunbind(this);
}
},
// 全局事件监听
bindGEvent: function bindGEvent(_id, _cb) {
this.eHandlers = this.eHandlers || [];
// 重复性检查
if (CC_DEBUG) {
for (var i in this.eHandlers) {
var binder = this.eHandlers[i];
if (binder && binder.id == _id) {
nx.error("[BridgeWindow]重复监听事件:", _id);
return;
}
}
}
var tag = gcore.GlobalEvent.bind(_id, _cb);
this.eHandlers.push({
id: _id,
tag: tag
});
},
// 全局监听解除(一次性)
unbindGEvents: function unbindGEvents() {
if (window.nx) {
if (nx.dt.arrEmpty(this.eHandlers)) {
return;
}
this.eHandlers.forEach(function (_binder) {
gcore.GlobalEvent.unbind(_binder.tag);
});
this.eHandlers = [];
}
}
});
cc._RF.pop();