From 124ef6e60eec770489c59b242b066feea2b3db82 Mon Sep 17 00:00:00 2001 From: qiuchengw Date: Wed, 3 Dec 2025 09:28:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86ESC=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Timeline.vue | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/components/Timeline.vue b/src/components/Timeline.vue index c05b59d..8f7f921 100644 --- a/src/components/Timeline.vue +++ b/src/components/Timeline.vue @@ -688,9 +688,6 @@ const handleLinkDragStart = (event: { task: Task; type: 'predecessor' | 'success // 启动自动滚动检测 startLinkAutoScroll() - // 添加 ESC 键监听,允许取消拖拽 - document.addEventListener('keydown', handleLinkDragEscape) - // 在 Timeline 层级添加全局鼠标监听器(防止 LinkAnchor 因虚拟滚动卸载导致拖拽中断) document.addEventListener('mousemove', handleGlobalMouseMove) document.addEventListener('mouseup', handleGlobalMouseUp) @@ -795,14 +792,6 @@ const handleGlobalMouseUp = () => { } } -// 处理 ESC 键取消拖拽 -const handleLinkDragEscape = (e: KeyboardEvent) => { - if (e.key === 'Escape' && dragLinkMode.value) { - cleanupLinkDrag() - document.removeEventListener('keydown', handleLinkDragEscape) - } -} - // 缓存 bodyContent 的位置信息(避免频繁调用 getBoundingClientRect) let cachedBodyRect: DOMRect | null = null let bodyRectCacheTime = 0 @@ -854,8 +843,7 @@ const handleLinkDragEnd = (event: { task: Task; type: 'predecessor' | 'successor // 清除缓存的 rect cachedBodyRect = null - // 移除 ESC 键监听 - document.removeEventListener('keydown', handleLinkDragEscape) // 移除全局鼠标监听器 + // 移除全局鼠标监听器 document.removeEventListener('mousemove', handleGlobalMouseMove) document.removeEventListener('mouseup', handleGlobalMouseUp) @@ -1176,7 +1164,6 @@ const cleanupLinkDrag = () => { linkDragGuideRef.value?.clear() // 移除全局监听器 - document.removeEventListener('keydown', handleLinkDragEscape) document.removeEventListener('mousemove', handleGlobalMouseMove) document.removeEventListener('mouseup', handleGlobalMouseUp)