董国庆
2026-06-29 df96b371752686c57e8729360538baa9becdfeca
优化tooptip的显示hover 1秒就显示
2个文件已修改
24 ■■■■■ 已修改文件
src/views/businessOperations/operationWorkbench/map.vue 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/testDemo/operationWorkbench/map.vue 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/businessOperations/operationWorkbench/map.vue
@@ -169,6 +169,7 @@
const cityOptions = ref<OptionItem[]>([...DEFAULT_CITY_OPTIONS])
const SERVER_REFRESH_DELAY_MS = 1000
const VERTEX_HOVER_DELAY_MS = 1000 // 顶点悬浮提示延迟时间
function waitForServerRefreshDelay() {
  return new Promise<void>((resolve) => {
@@ -462,7 +463,7 @@
  if (fenceEditGuideHoverVertexIndex.value === hoveredVertexIndex)
    return
  clearFenceEditGuidePendingHover()
  // 切到新顶点时保留当前提示,等新的 3 秒 hover 倒计时成功后再切换,
  // 切到新顶点时保留当前提示,等新的 hover 倒计时成功后再切换,
  // 避免出现“旧提示先消失,但新顶点计时没接上”的偶发现象。
  fenceEditGuideHoverVertexIndex.value = hoveredVertexIndex
  fenceEditGuideHoverTimer = window.setTimeout(() => {
@@ -471,7 +472,7 @@
    fenceEditGuideDisplayMode.value = 'hover'
    fenceEditGuideHoverTimer = null
    renderFenceEditGuide()
  }, 3000)
  }, VERTEX_HOVER_DELAY_MS)
}
function renderFenceEditGuide() {
@@ -790,7 +791,7 @@
  if (restrictedEditGuideHoverVertexIndex.value === hoveredVertexIndex)
    return
  clearRestrictedEditGuidePendingHover()
  // 切到新顶点时保留当前提示,等新的 3 秒 hover 倒计时成功后再切换,
  // 切到新顶点时保留当前提示,等新的 hover 倒计时成功后再切换,
  // 避免出现“旧提示先消失,但新顶点计时没接上”的偶发现象。
  restrictedEditGuideHoverVertexIndex.value = hoveredVertexIndex
  restrictedEditGuideHoverTimer = window.setTimeout(() => {
@@ -799,7 +800,7 @@
    restrictedEditGuideDisplayMode.value = 'hover'
    restrictedEditGuideHoverTimer = null
    renderRestrictedEditGuide()
  }, 3000)
  }, VERTEX_HOVER_DELAY_MS)
}
function renderRestrictedEditGuide() {
@@ -1170,15 +1171,15 @@
// hover 提示需要兼顾“顶点命中准确”和“轻微手抖 / 地图动画时不丢 hover 候选”:
// - 首次命中用较小半径,避免误判到邻近顶点;
// - 已经锁定候选顶点后,临时放宽半径,减少 3 秒倒计时被偶发抖动打断。
const EDIT_GUIDE_HOVER_MATCH_DISTANCE_PX = 14
const EDIT_GUIDE_HOVER_MATCH_DISTANCE_PX = 28
const EDIT_GUIDE_HOVER_STICKY_DISTANCE_PX = 36
// 地图使用了自定义 cursor 图片,CSS hotspot 当前配置是 `6 2`;
// 视觉上的“指针中心/尖端”和 event.pixel 指向的真实热点不完全重合,
// 所以 hover 命中时同时兼容原始像素点与补偿后的像素点,减少白色顶点中心难命中的问题。
const EDIT_GUIDE_CURSOR_HOTSPOT_X = 6
const EDIT_GUIDE_CURSOR_HOTSPOT_Y = 2
const EDIT_GUIDE_CURSOR_VISUAL_ANCHOR_X = 14
const EDIT_GUIDE_CURSOR_VISUAL_ANCHOR_Y = 14
const EDIT_GUIDE_CURSOR_VISUAL_ANCHOR_X = 6
const EDIT_GUIDE_CURSOR_VISUAL_ANCHOR_Y = 2
// 区分“首次进入编辑立即显示”与“hover 3 秒后显示”,
// 这样可以既保留旧引导,又不影响新的 hover 提示交互。
const fenceEditGuideDisplayMode = ref<'idle' | 'entry' | 'hover'>('idle')
src/views/testDemo/operationWorkbench/map.vue
@@ -163,6 +163,7 @@
const cityOptions = ref<OptionItem[]>([...DEFAULT_CITY_OPTIONS])
const SERVER_REFRESH_DELAY_MS = 1000
const VERTEX_HOVER_DELAY_MS = 1000 // 顶点悬浮提示延迟时间
function waitForServerRefreshDelay() {
  return new Promise<void>((resolve) => {
@@ -449,7 +450,7 @@
  if (fenceEditGuideHoverVertexIndex.value === hoveredVertexIndex)
    return
  clearFenceEditGuidePendingHover()
  // 切到新顶点时保留当前提示,等新的 3 秒 hover 倒计时成功后再切换,
  // 切到新顶点时保留当前提示,等新的 hover 倒计时成功后再切换,
  // 避免出现“旧提示先消失,但新顶点计时没接上”的偶发现象。
  fenceEditGuideHoverVertexIndex.value = hoveredVertexIndex
  fenceEditGuideHoverTimer = window.setTimeout(() => {
@@ -458,7 +459,7 @@
    fenceEditGuideDisplayMode.value = 'hover'
    fenceEditGuideHoverTimer = null
    renderFenceEditGuide()
  }, 3000)
  }, VERTEX_HOVER_DELAY_MS)
}
function renderFenceEditGuide() {
@@ -777,7 +778,7 @@
  if (restrictedEditGuideHoverVertexIndex.value === hoveredVertexIndex)
    return
  clearRestrictedEditGuidePendingHover()
  // 切到新顶点时保留当前提示,等新的 3 秒 hover 倒计时成功后再切换,
  // 切到新顶点时保留当前提示,等新的 hover 倒计时成功后再切换,
  // 避免出现“旧提示先消失,但新顶点计时没接上”的偶发现象。
  restrictedEditGuideHoverVertexIndex.value = hoveredVertexIndex
  restrictedEditGuideHoverTimer = window.setTimeout(() => {
@@ -786,7 +787,7 @@
    restrictedEditGuideDisplayMode.value = 'hover'
    restrictedEditGuideHoverTimer = null
    renderRestrictedEditGuide()
  }, 3000)
  }, VERTEX_HOVER_DELAY_MS)
}
function renderRestrictedEditGuide() {