mirror of
https://gitee.com/ssssssss-team/magic-api.git
synced 2026-06-09 18:32:16 +08:00
地址传递接口id,快速定位接口,并打开编辑。issues:#I40UN6
This commit is contained in:
@@ -42,7 +42,7 @@ import contants from '@/scripts/contants.js'
|
||||
import MagicWebSocket from '@/scripts/websocket.js'
|
||||
import store from '@/scripts/store.js'
|
||||
import Key from '@/scripts/hotkey.js'
|
||||
import {replaceURL} from '@/scripts/utils.js'
|
||||
import {replaceURL,getQueryVariable} from '@/scripts/utils.js'
|
||||
import {defineTheme} from '@/scripts/editor/theme.js'
|
||||
import defaultTheme from '@/scripts/editor/default-theme.js'
|
||||
import darkTheme from '@/scripts/editor/dark-theme.js'
|
||||
@@ -193,6 +193,7 @@ export default {
|
||||
}
|
||||
})
|
||||
bus.$on('logout', () => this.showLogin = true)
|
||||
this.open()
|
||||
},
|
||||
destroyed() {
|
||||
bus.$off();
|
||||
@@ -299,6 +300,21 @@ export default {
|
||||
.catch(ignore => {
|
||||
bus.$emit('status', '版本检测失败')
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 传入id来打开对应api或者function
|
||||
*/
|
||||
open(openIds) {
|
||||
openIds = openIds || getQueryVariable('openIds')
|
||||
if (openIds) {
|
||||
if (typeof openIds === 'string') {
|
||||
openIds = openIds.split(',')
|
||||
}
|
||||
openIds.forEach(id => {
|
||||
this.$refs.apiList.openItemById(id)
|
||||
this.$refs.functionList.openItemById(id)
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
@@ -136,7 +136,9 @@ export default {
|
||||
draggableItem: {},
|
||||
draggableTargetItem: {},
|
||||
// 是否展示tree-loading
|
||||
showLoading: true
|
||||
showLoading: true,
|
||||
// 缓存一个openId
|
||||
tmpOpenId: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -166,6 +168,7 @@ export default {
|
||||
request.send('list').success(data => {
|
||||
this.listChildrenData = data
|
||||
this.initTreeData()
|
||||
this.openItemById()
|
||||
this.showLoading = false
|
||||
})
|
||||
})
|
||||
@@ -780,6 +783,26 @@ export default {
|
||||
item = this.getItemById(item.parentId)
|
||||
}
|
||||
return items
|
||||
},
|
||||
// 根据id打开对应item
|
||||
openItemById(openId) {
|
||||
// 证明当前请求还没有请求到数据
|
||||
if (this.listChildrenData.length === 0) {
|
||||
this.tmpOpenId.push(openId)
|
||||
} else {
|
||||
if (!this.tmpOpenId.includes(openId)) {
|
||||
this.tmpOpenId.push(openId)
|
||||
}
|
||||
this.tmpOpenId.forEach(id => {
|
||||
const cache = this.getItemById(id)
|
||||
if (cache) {
|
||||
this.$nextTick(() => {
|
||||
this.open(cache)
|
||||
})
|
||||
}
|
||||
})
|
||||
this.tmpOpenId = []
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
@@ -135,7 +135,9 @@ export default {
|
||||
draggableItem: {},
|
||||
draggableTargetItem: {},
|
||||
// 是否展示tree-loading
|
||||
showLoading: true
|
||||
showLoading: true,
|
||||
// 缓存一个openId
|
||||
tmpOpenId: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -169,6 +171,7 @@ export default {
|
||||
request.send('function/list').success(data => {
|
||||
this.listChildrenData = data
|
||||
this.initTreeData()
|
||||
this.openItemById()
|
||||
this.showLoading = false
|
||||
})
|
||||
})
|
||||
@@ -718,6 +721,26 @@ export default {
|
||||
}
|
||||
return handle(this.tree)
|
||||
},
|
||||
// 根据id打开对应item
|
||||
openItemById(openId) {
|
||||
// 证明当前请求还没有请求到数据
|
||||
if (this.listChildrenData.length === 0) {
|
||||
this.tmpOpenId.push(openId)
|
||||
} else {
|
||||
if (!this.tmpOpenId.includes(openId)) {
|
||||
this.tmpOpenId.push(openId)
|
||||
}
|
||||
this.tmpOpenId.forEach(id => {
|
||||
const cache = this.getItemById(id)
|
||||
if (cache) {
|
||||
this.$nextTick(() => {
|
||||
this.open(cache)
|
||||
})
|
||||
}
|
||||
})
|
||||
this.tmpOpenId = []
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
JavaClass.setupOnlineFunction(this.doFindFunction);
|
||||
|
||||
@@ -94,4 +94,22 @@ const goToAnchor = (dom) => {
|
||||
dom.scrollIntoView(true)
|
||||
}
|
||||
}
|
||||
export {replaceURL, isVisible, formatJson, formatDate, paddingZero, download, requestGroup, deepClone, goToAnchor}
|
||||
|
||||
/**
|
||||
* 获取url中的参数
|
||||
* @param {String} variable
|
||||
* @returns
|
||||
*/
|
||||
const getQueryVariable = (variable) => {
|
||||
var query = window.location.search.substring(1)
|
||||
var vars = query.split('&')
|
||||
for (var i = 0; i < vars.length; i++) {
|
||||
var pair = vars[i].split('=')
|
||||
if (pair[0] == variable) {
|
||||
return pair[1]
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
export {replaceURL, isVisible, formatJson, formatDate, paddingZero, download, requestGroup, deepClone, goToAnchor, getQueryVariable}
|
||||
|
||||
Reference in New Issue
Block a user