增加参数推荐逻辑

dev
RogerWork 3 months ago
parent a928823497
commit 3ad2bc10a3
  1. 10
      src/apis/ec_api.js
  2. 24
      src/components/ec_api/TabArea.vue

@ -89,3 +89,13 @@ export const ec_api_send_request = (req_data) => {
})
}
export const ec_api_get_suggest = (api_type, api) => {
return request({
url: 'ec/get_suggest_params',
method: 'get',
params: {
member_type: api_type,
api: api
}
})
}

@ -3,7 +3,7 @@ import {ref, reactive, onBeforeMount, onMounted, onUnmounted, watch, watchEffect
import Sortable from "sortablejs";
import {useStore, mapState} from "vuex";
import JsonEditorVue from "json-editor-vue3";
import {ec_api_send_request, get_ec_api_request_url} from "@/apis/ec_api.js";
import {ec_api_send_request, get_ec_api_request_url, ec_api_get_suggest} from "@/apis/ec_api.js";
import {Refresh} from "@element-plus/icons-vue";
import "@/VueAceEditor/aceConfig"
import {VAceEditor} from "vue3-ace-editor";
@ -216,6 +216,27 @@ function send_request() {
)
}
async function get_suggest() {
const api_type = UserApiData.value.api[activeTab.value].type
const api = UserApiData.value.api[activeTab.value].path
await ec_api_get_suggest(api_type, api).then(
(res) => {
console.log('get_suggest', api, res)
res.forEach((suggest) => {
UserApiData.value.api[activeTab.value].params.forEach((param) => {
if (param.param === suggest.param) {
param['value'] = suggest['value']
param['default'] = suggest['value']
param['is_checked'] = suggest['is_checked']
}
})
})
}
).catch((err) => {
console.log(err)
})
}
//
function test() {
console.log('store.state.ecApiModule.ec_api_data', store.state.ecApiModule.ec_api_data)
@ -238,6 +259,7 @@ watch(() => store.state.ecApiModule.ec_api_data.api, (oldValue, newValue) => {
// activeTab
watch(activeTab, () => {
markIsChecked()
get_suggest()
handle_request_url()
})

Loading…
Cancel
Save