迁移事件中心
This commit is contained in:
@@ -99,6 +99,9 @@ const dockLayoutRef = ref(null)
|
||||
// 主区域引用
|
||||
const mainAreaRef = ref(null)
|
||||
|
||||
// 调试模式开关
|
||||
const debugMode = ref(false)
|
||||
|
||||
// 停靠指示器相关状态
|
||||
const showDockIndicator = ref(false)
|
||||
const currentMousePosition = ref({ x: 0, y: 0 })
|
||||
@@ -531,13 +534,40 @@ const setupEventListeners = () => {
|
||||
// 创建一个数组来保存所有的取消订阅函数
|
||||
const unsubscribeFunctions = [];
|
||||
|
||||
// 上升事件处理 - 统一由handleRisingEvent处理所有上升事件
|
||||
const risingEvents = [
|
||||
// 面板拖拽事件
|
||||
EVENT_TYPES.PANEL_DRAG_START,
|
||||
EVENT_TYPES.PANEL_DRAG_MOVE,
|
||||
EVENT_TYPES.PANEL_DRAG_END,
|
||||
EVENT_TYPES.PANEL_DRAG_CANCEL,
|
||||
// 面板调整大小事件
|
||||
EVENT_TYPES.PANEL_RESIZE_START,
|
||||
EVENT_TYPES.PANEL_RESIZE_MOVE,
|
||||
EVENT_TYPES.PANEL_RESIZE_END,
|
||||
// 区域拖拽事件
|
||||
EVENT_TYPES.AREA_DRAG_START,
|
||||
EVENT_TYPES.AREA_DRAG_MOVE,
|
||||
EVENT_TYPES.AREA_DRAG_END,
|
||||
EVENT_TYPES.AREA_DRAG_CANCEL,
|
||||
// 区域调整大小事件
|
||||
EVENT_TYPES.AREA_RESIZE_START,
|
||||
EVENT_TYPES.AREA_RESIZE_MOVE,
|
||||
EVENT_TYPES.AREA_RESIZE_END
|
||||
];
|
||||
|
||||
// 订阅所有上升事件,统一由handleRisingEvent处理
|
||||
risingEvents.forEach(eventType => {
|
||||
unsubscribeFunctions.push(eventBus.on(eventType, handleRisingEvent, { componentId: 'dock-layout' }));
|
||||
});
|
||||
|
||||
// Area相关事件
|
||||
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.AREA_DRAG_OVER, handleAreaDragOver, { componentId: 'dock-layout' }));
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.AREA_DRAG_LEAVE, handleAreaDragLeave, { componentId: 'dock-layout' }));
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.AREA_MERGE_REQUEST, handleAreaMergeRequest, { componentId: 'dock-layout' }));
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.AREA_UPDATED, onAreaUpdated, { componentId: 'dock-layout' }));
|
||||
|
||||
|
||||
|
||||
|
||||
// Tab相关事件
|
||||
@@ -552,15 +582,8 @@ const setupEventListeners = () => {
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.PANEL_CLOSE, onPanelClose, { componentId: 'dock-layout' }));
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.PANEL_TOGGLE_TOOLBAR, () => emit('toggleToolbar'), { componentId: 'dock-layout' }));
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.PANEL_MAXIMIZE_SYNC, onPanelMaximizeSync, { componentId: 'dock-layout' }));
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.PANEL_DRAG_START, onPanelDragStart, { componentId: 'dock-layout' }));
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.PANEL_DRAG_MOVE, onPanelDragMove, { componentId: 'dock-layout' }));
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.PANEL_DRAG_END, onPanelDragEnd, { componentId: 'dock-layout' }));
|
||||
// 单面板检测事件
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.PANEL_CHECK_SINGLE_PANEL, onCheckSinglePanel, { componentId: 'dock-layout' }));
|
||||
// Area resize事件
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.AREA_RESIZE_START, onAreaResizeStart, { componentId: 'dock-layout' }));
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.AREA_RESIZE_MOVE, onAreaResizeMove, { componentId: 'dock-layout' }));
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.AREA_RESIZE_END, onAreaResizeEnd, { componentId: 'dock-layout' }));
|
||||
// Area位置更新事件
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.AREA_POSITION_UPDATE, onAreaPositionUpdate, { componentId: 'dock-layout' }));
|
||||
|
||||
|
||||
@@ -364,46 +364,13 @@ class GlobalEventManager {
|
||||
return;
|
||||
}
|
||||
|
||||
// 注册所有上升事件监听器
|
||||
// 使用EVENT_TYPES常量确保事件类型匹配
|
||||
const risingEvents = [
|
||||
// 面板拖拽上升事件
|
||||
EVENT_TYPES.PANEL_DRAG_START,
|
||||
EVENT_TYPES.PANEL_DRAG_MOVE,
|
||||
EVENT_TYPES.PANEL_DRAG_END,
|
||||
EVENT_TYPES.PANEL_DRAG_CANCEL,
|
||||
// 面板resize上升事件
|
||||
EVENT_TYPES.PANEL_RESIZE_START,
|
||||
EVENT_TYPES.PANEL_RESIZE_MOVE,
|
||||
EVENT_TYPES.PANEL_RESIZE_END,
|
||||
// 区域拖拽上升事件
|
||||
EVENT_TYPES.AREA_DRAG_START,
|
||||
EVENT_TYPES.AREA_DRAG_MOVE,
|
||||
EVENT_TYPES.AREA_DRAG_END,
|
||||
EVENT_TYPES.AREA_DRAG_CANCEL,
|
||||
// 区域resize上升事件
|
||||
EVENT_TYPES.AREA_RESIZE_START,
|
||||
EVENT_TYPES.AREA_RESIZE_MOVE,
|
||||
EVENT_TYPES.AREA_RESIZE_END,
|
||||
// TabPage拖拽上升事件
|
||||
EVENT_TYPES.TABPAGE_DRAG_START,
|
||||
EVENT_TYPES.TABPAGE_DRAG_MOVE,
|
||||
EVENT_TYPES.TABPAGE_DRAG_END,
|
||||
EVENT_TYPES.TABPAGE_DRAG_CANCEL
|
||||
];
|
||||
|
||||
// 注册上升事件监听器,统一由_handleRisingEvent处理
|
||||
risingEvents.forEach(eventType => {
|
||||
const unsubscribe = eventBus.on(eventType, this._handleRisingEvent.bind(this), {
|
||||
priority: 0, // 最高优先级
|
||||
componentId: 'global-event-manager'
|
||||
});
|
||||
this.eventListenerUnsubscribers.push(unsubscribe);
|
||||
});
|
||||
// 注意:所有上升事件现在由DockLayout统一处理,不再由GlobalEventManager处理
|
||||
// 这里不再注册上升事件监听器,避免事件被重复处理
|
||||
// 上升事件包括:面板拖拽、面板调整大小、区域拖拽、区域调整大小等
|
||||
|
||||
this.componentListenersRegistered = true;
|
||||
|
||||
console.log('✅ 组件事件监听器注册完成(Handler自行订阅事件)');
|
||||
console.log('✅ GlobalEventManager组件事件监听器注册完成,上升事件已迁移到DockLayout处理');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user