guanghulab/modules/m-channel/module-lifecycle.js
Guanghu Domestic Migration d1e47f4565
Some checks are pending
自动更新代码和重启 / update-and-restart (push) Waiting to run
CI检查 + 自动部署 / check (push) Waiting to run
CI检查 + 自动部署 / deploy (push) Blocked by required conditions
重启聊天服务 / restart (push) Waiting to run
chore: import sanitized domestic snapshot for REPO-002
Source snapshot: ca48d3ddf926d79aa138306164169baf764bb829
2026-07-17 15:54:41 +08:00

24 lines
746 B
JavaScript

// 模块生命周期管理
window.ModuleLifecycle = {
activeModules: new Set(),
// 模块加载时
onLoad: function(moduleName) {
this.activeModules.add(moduleName);
console.log(`[生命周期] 模块加载: ${moduleName}`);
EventBus.emit('module:loaded', { module: moduleName, time: Date.now() });
},
// 模块卸载时
onUnload: function(moduleName) {
this.activeModules.delete(moduleName);
console.log(`[生命周期] 模块卸载: ${moduleName}`);
EventBus.emit('module:unloaded', { module: moduleName, time: Date.now() });
},
// 获取当前活跃模块
getActiveModules: function() {
return Array.from(this.activeModules);
}
};