refactor: centralize API client and config caching

This commit is contained in:
hkfires
2025-11-21 09:42:16 +08:00
parent 93eb7f4717
commit a8b8bdc11c
6 changed files with 208 additions and 119 deletions

10
src/core/event-bus.js Normal file
View File

@@ -0,0 +1,10 @@
// 轻量事件总线,避免模块之间的直接耦合
export function createEventBus() {
const target = new EventTarget();
const on = (type, listener) => target.addEventListener(type, listener);
const off = (type, listener) => target.removeEventListener(type, listener);
const emit = (type, detail = {}) => target.dispatchEvent(new CustomEvent(type, { detail }));
return { on, off, emit };
}