Area拖拽指示器优化计划

This commit is contained in:
zqm
2026-01-20 09:27:36 +08:00
parent 28ab62bc03
commit e879a24afe
4 changed files with 637 additions and 85 deletions

View File

@@ -147,6 +147,9 @@ const props = defineProps({
}
})
// 组件卸载标记
const isUnmounted = ref(false)
// 使用全局事件总线和拖拽管理器
// 本地状态
@@ -446,6 +449,14 @@ const onDragStart = (e) => {
// 添加鼠标移动和释放事件监听器
const handleMouseMove = (moveEvent) => {
// 检查组件是否已卸载
if (isUnmounted.value) {
// 组件已卸载,清理事件监听器
document.removeEventListener('mousemove', handleMouseMove)
document.removeEventListener('mouseup', handleMouseUp)
return
}
// 计算移动距离
const deltaX = moveEvent.clientX - dragStartPos.value.x
const deltaY = moveEvent.clientY - dragStartPos.value.y
@@ -901,6 +912,9 @@ onMounted(() => {
// 组件卸载时清理状态
onUnmounted(() => {
// 设置组件卸载标记
isUnmounted.value = true
// 清理拖拽和调整大小状态
isDragging.value = false
currentDragId.value = null