@@ -299,22 +299,45 @@ function onMouseDown(e: MouseEvent) {
299299 taskListBodyProposedWidth .value = window .innerWidth * 0.8 - 6 // 减去splitter宽度
300300
301301 // 获取左侧面板的最小宽度
302- taskListBodyWidthLimit .value = Math .min (taskListBodyProposedWidth .value , taskListBodyWidth .value )
302+ taskListBodyWidthLimit .value = Math .min (taskListBodyProposedWidth .value ,
303+ taskListBodyWidthLimit .value )
303304
304305 // 广播拖拽开始事件,通知其他组件暂停悬停效果
305306 window .dispatchEvent (new CustomEvent (' splitter-drag-start' ))
306307
307- // 在拖拽期间禁用页面选择
308+ // 在拖拽期间禁用页面选择和所有指针事件
308309 document .body .style .userSelect = ' none'
309310 document .body .style .webkitUserSelect = ' none'
310311 document .body .style .cursor = ' col-resize'
312+ document .body .style .pointerEvents = ' none' // 禁止所有指针事件
313+
314+ // 全局事件拦截器:在捕获阶段拦截所有事件(除了 mousemove 和 mouseup)
315+ const blockAllEvents = (ev : Event ) => {
316+ if (ev .type !== ' mousemove' && ev .type !== ' mouseup' ) {
317+ ev .preventDefault ()
318+ ev .stopPropagation ()
319+ ev .stopImmediatePropagation ()
320+ }
321+ }
322+
323+ // 在捕获阶段添加事件监听,确保最先拦截
324+ document .addEventListener (' mousedown' , blockAllEvents , { capture: true })
325+ document .addEventListener (' click' , blockAllEvents , { capture: true })
326+ document .addEventListener (' dblclick' , blockAllEvents , { capture: true })
327+ document .addEventListener (' mouseover' , blockAllEvents , { capture: true })
328+ document .addEventListener (' mouseout' , blockAllEvents , { capture: true })
329+ document .addEventListener (' mouseenter' , blockAllEvents , { capture: true })
330+ document .addEventListener (' mouseleave' , blockAllEvents , { capture: true })
331+ document .addEventListener (' wheel' , blockAllEvents , { capture: true , passive: false })
332+ document .addEventListener (' contextmenu' , blockAllEvents , { capture: true })
311333
312334 function onMouseMove(ev : MouseEvent ) {
313335 if (! dragging .value ) return
314336
315- // 阻止默认行为,防止滚动等
337+ // 强制阻止所有默认行为和事件传播
316338 ev .preventDefault ()
317339 ev .stopPropagation ()
340+ ev .stopImmediatePropagation ()
318341
319342 const delta = ev .clientX - startX
320343 const proposedWidth = startWidth + delta
@@ -327,13 +350,25 @@ function onMouseDown(e: MouseEvent) {
327350 function onMouseUp() {
328351 dragging .value = false
329352
353+ // 移除全局事件拦截器
354+ document .removeEventListener (' mousedown' , blockAllEvents , { capture: true })
355+ document .removeEventListener (' click' , blockAllEvents , { capture: true })
356+ document .removeEventListener (' dblclick' , blockAllEvents , { capture: true })
357+ document .removeEventListener (' mouseover' , blockAllEvents , { capture: true })
358+ document .removeEventListener (' mouseout' , blockAllEvents , { capture: true })
359+ document .removeEventListener (' mouseenter' , blockAllEvents , { capture: true })
360+ document .removeEventListener (' mouseleave' , blockAllEvents , { capture: true })
361+ document .removeEventListener (' wheel' , blockAllEvents , { capture: true })
362+ document .removeEventListener (' contextmenu' , blockAllEvents , { capture: true })
363+
330364 // 广播拖拽结束事件,通知其他组件恢复悬停效果
331365 window .dispatchEvent (new CustomEvent (' splitter-drag-end' ))
332366
333- // 恢复页面选择和光标
367+ // 恢复页面选择、光标和指针事件
334368 document .body .style .userSelect = ' '
335369 document .body .style .webkitUserSelect = ' '
336370 document .body .style .cursor = ' '
371+ document .body .style .pointerEvents = ' '
337372
338373 taskListBodyWidth .value = getTaskListMaxWidth () // TaskList默认宽度
339374 ganttPanelLeftMinWidth .value = getTaskListMinWidth () // 左侧面板最小宽度
0 commit comments