迁移事件中心

This commit is contained in:
zqm
2026-01-04 16:47:46 +08:00
parent ffd854bdcb
commit 4ebe993815
2 changed files with 35 additions and 45 deletions

View File

@@ -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,6 +534,33 @@ 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' }));
@@ -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' }));

View File

@@ -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处理');
}
/**