t-comm
Version:
专业、稳定、纯粹的工具库
37 lines (32 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var eBus_eBus = require('./e-bus.js');
var globalEBus = new eBus_eBus.EventBus();
/**
* 挂载统一的eBus,所有实例共用一个
* @param app Vue3 应用实例
*/
var initGlobalVue3EBus = function initGlobalVue3EBus(app) {
var _a;
if (!((_a = app === null || app === void 0 ? void 0 : app.config) === null || _a === void 0 ? void 0 : _a.globalProperties)) {
return app;
}
app.config.globalProperties.$ebus = globalEBus;
return [app, globalEBus];
};
/**
* 挂载唯一的eBus,不同实例用不同的
* @param app Vue3 应用实例
*/
var initDiffVue3EBus = function initDiffVue3EBus(app) {
var _a;
if (!((_a = app === null || app === void 0 ? void 0 : app.config) === null || _a === void 0 ? void 0 : _a.globalProperties)) {
return app;
}
var eBus = new eBus_eBus.EventBus();
app.config.globalProperties.$ebus = eBus;
return [app, eBus];
};
exports.globalEBus = globalEBus;
exports.initDiffVue3EBus = initDiffVue3EBus;
exports.initGlobalVue3EBus = initGlobalVue3EBus;