Kaynağa Gözat

优化移动接口后定位混乱的问题

mxd 3 yıl önce
ebeveyn
işleme
bffdaa9391

+ 10 - 0
magic-editor/src/console/src/components/resources/magic-api-list.vue

@@ -51,6 +51,7 @@
             v-if="item._searchShow !== false"
             :class="{ 'ma-tree-select': item.selectRightItem || item.tmp_id === currentFileItem.tmp_id }"
             :draggable="true"
+            :id="'magic-api-list-' + (item.id || item.tmp_id)"
             :style="{ 'padding-left': 17 * item.level + 'px' }"
             class="ma-tree-hover"
             :title="item.method + ':' + (item.name || '') + '(' + (item.path || '') + ')'"
@@ -579,6 +580,9 @@ export default {
             this.tempGroupObj.name = this.createGroupObj.name
             this.tempGroupObj.path = this.createGroupObj.path
             this.rebuildTree()
+            this.$nextTick(() => {
+              goToAnchor('#magic-api-list-' + this.createGroupObj.id)
+            })
             this.initCreateGroupObj()
             this.tempGroupObj = {}
           })
@@ -795,6 +799,9 @@ export default {
                   this.rebuildTree()
                   this.initCreateGroupObj()
                   this.changeForceUpdate()
+                  this.$nextTick(() => {
+                    goToAnchor('#magic-api-list-' + this.draggableItem.id)
+                  })
                   bus.$emit('status', `接口分组「${params.name}」移动成功`)
                 })
               } else {
@@ -817,6 +824,9 @@ export default {
                   this.rebuildTree()
                   this.initCreateGroupObj()
                   this.changeForceUpdate()
+                  this.$nextTick(() => {
+                    goToAnchor('#magic-api-list-' + this.draggableItem.id)
+                  })
                   bus.$emit('status', `接口「${this.draggableItem.name}」移动成功`)
                 })
               }

+ 12 - 1
magic-editor/src/console/src/components/resources/magic-function-list.vue

@@ -26,6 +26,7 @@
       <template #folder="{ item }">
         <div
             v-if="item._searchShow !== false"
+            :id="'magic-function-list-' + item.id"
             :class="{ 'ma-tree-select': item.selectRightItem }"
             :draggable="true"
             :style="{ 'padding-left': 17 * item.level + 'px' }"
@@ -49,6 +50,7 @@
             v-if="item._searchShow !== false"
             :class="{ 'ma-tree-select': item.selectRightItem || item.tmp_id === currentFileItem.tmp_id }"
             :draggable="true"
+            :id="'magic-function-list-' + (item.id || item.tmp_id)"
             :style="{ 'padding-left': 17 * item.level + 'px' }"
             class="ma-tree-hover"
             :title="(item.name || '') + '(' + (item.path || '') + ')'"
@@ -551,6 +553,9 @@ export default {
             this.tempGroupObj.name = this.createGroupObj.name
             this.tempGroupObj.path = this.createGroupObj.path
             this.rebuildTree()
+            this.$nextTick(() => {
+              goToAnchor('#magic-function-list-' + this.createGroupObj.id)
+            })
             this.initCreateGroupObj()
             this.tempGroupObj = {}
           })
@@ -564,7 +569,7 @@ export default {
             this.rebuildTree()
             const id = this.createGroupObj.id
             this.$nextTick(() => {
-              goToAnchor('#magic-api-list-' + id)
+              goToAnchor('#magic-function-list-' + id)
             })
             this.initCreateGroupObj()
           })
@@ -762,6 +767,9 @@ export default {
                   this.rebuildTree()
                   this.initCreateGroupObj()
                   this.changeForceUpdate()
+                  this.$nextTick(() => {
+                    goToAnchor('#magic-function-list-' + this.draggableItem.id)
+                  })
                 })
               } else {
                 this.$magicAlert({content: `不能移到${this.draggableTargetItem.name}`})
@@ -782,6 +790,9 @@ export default {
                   this.rebuildTree()
                   this.initCreateGroupObj()
                   this.changeForceUpdate()
+                  this.$nextTick(() => {
+                    goToAnchor('#magic-function-list-' + this.draggableItem.id)
+                  })
                 })
               }
             }