ソースを参照

编辑器:bugfix: v-title在元素被remove时有可能不会消失

任一存 3 年 前
コミット
3f116e9003

+ 2 - 2
packages/code/src/components/insertPositionTipInEditor.vue

@@ -186,7 +186,7 @@ export default {
               }
             }
           }
-          
+
           break;
         case 'topologyGroupLevel2': // 被拖拽的是拓扑结构中二级分组
           if (this.topologyLevel === 1) {
@@ -200,7 +200,7 @@ export default {
               children: [this.dragInfo.node.id],
             }
             this.info.catalogRoot.splice(this.index, 0, newGroupLevel1)
-            
+
             /**
              * 被拖拽的二级分组名称改为“默认二级分组”;
              */

+ 14 - 14
packages/code/src/directives/vTitleInEditor.js

@@ -1,13 +1,14 @@
 import Vue from 'vue'
 
+let timerId = null
+let isShowTitle = false
+let titleNode = null
+
 Vue.directive('title', {
   bind: function (el, binding) {
     if (!binding.value) {
       return
     }
-    let timerId = null
-    let isShowTitle = false
-    let titleNode = null
     el.addEventListener('mousemove', function(e) {
       if (!isShowTitle) {
         clearTimeout(timerId)
@@ -42,9 +43,7 @@ Vue.directive('title', {
       passive: false,
     })
     el.addEventListener('mouseleave', function () {
-      console.log('mouseleave');
       if (!isShowTitle) {
-        console.log('还没显示');
         clearTimeout(timerId)
       } else {
         isShowTitle = false
@@ -52,12 +51,9 @@ Vue.directive('title', {
       }
     })
     el.addEventListener('mousedown', function () {
-      console.log('mousedown');
       if (!isShowTitle) {
-        console.log('还没显示!');
         clearTimeout(timerId)
       } else {
-        console.log('已经显示!');
         isShowTitle = false
         document.body.removeChild(titleNode)
       }
@@ -78,16 +74,20 @@ Vue.directive('title', {
         document.body.removeChild(titleNode)
       }
     })
+    el.addEventListener('dragover', function () {
+      if (!isShowTitle) {
+        clearTimeout(timerId)
+      } else {
+        isShowTitle = false
+        document.body.removeChild(titleNode)
+      }
+    })
     el.addEventListener('dragleave', function () {
-      console.log('dragleave');
       if (!isShowTitle) {
-        console.log('还没显示');
         clearTimeout(timerId)
       } else {
-        setTimeout(() => {
-          isShowTitle = false
-          document.body.removeChild(titleNode)
-        }, 1000);
+        isShowTitle = false
+        document.body.removeChild(titleNode)
       }
     })
   },