export const eventBus = {
    events: {},

    // 注册事件监听
    on(eventName, callback) {
        this.events[eventName] = callback;
    },

    // 触发事件
    emit(eventName, data) {
        if (typeof this.events[eventName] === 'function') {
            this.events[eventName](data);
        }
    },

    // 移除事件监听
    off(eventName, callback) {
        if (this.events[eventName] === callback) {
            delete this.events[eventName];
        }
    }
};