From e5027789ad7f6cb97efb0c931313a3ea5618755f Mon Sep 17 00:00:00 2001 From: zqm Date: Fri, 16 Jan 2026 16:31:18 +0800 Subject: [PATCH] =?UTF-8?q?Area=E6=A0=87=E9=A2=98=E6=A0=8F=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=8B=96=E6=8B=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Windows/Robot/Web/src/DockLayout/Area.vue | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/AutoRobot/Windows/Robot/Web/src/DockLayout/Area.vue b/AutoRobot/Windows/Robot/Web/src/DockLayout/Area.vue index 4176d35..32a3b0a 100644 --- a/AutoRobot/Windows/Robot/Web/src/DockLayout/Area.vue +++ b/AutoRobot/Windows/Robot/Web/src/DockLayout/Area.vue @@ -444,8 +444,55 @@ const onDragStart = (e) => { source: { component: 'Area', areaId: props.id, dragId: currentDragId.value } }) + // 添加鼠标移动和释放事件监听器 + const handleMouseMove = (moveEvent) => { + // 计算移动距离 + const deltaX = moveEvent.clientX - dragStartPos.value.x + const deltaY = moveEvent.clientY - dragStartPos.value.y + + // 更新位置 + const newLeft = areaStartPos.value.x + deltaX + const newTop = areaStartPos.value.y + deltaY + + // 更新原始位置 + originalPosition.value.left = newLeft + originalPosition.value.top = newTop + + // 发送拖拽移动事件 + emitEvent(EVENT_TYPES.AREA_DRAG_MOVE, { + dragId: currentDragId.value, + areaId: props.id, + position: { x: moveEvent.clientX, y: moveEvent.clientY }, + left: newLeft, + top: newTop, + timestamp: Date.now() + }, { + source: { component: 'Area', areaId: props.id, dragId: currentDragId.value } + }) + } + + const handleMouseUp = () => { + // 调用拖拽结束方法 + onDragEnd({ + dragId: currentDragId.value, + finalPosition: { + x: originalPosition.value.left || 0, + y: originalPosition.value.top || 0 + }, + areaId: props.id + }) + + // 清理事件监听器 + document.removeEventListener('mousemove', handleMouseMove) + document.removeEventListener('mouseup', handleMouseUp) + } + + document.addEventListener('mousemove', handleMouseMove) + document.addEventListener('mouseup', handleMouseUp) + // 防止文本选择 e.preventDefault() + e.stopPropagation() } // 拖拽移动 - 处理事件总线的area.drag.move事件