优化重新获取推荐值的逻辑,优化发送按键的处理逻辑

dev
RogerWork 3 months ago
parent 73825303c9
commit aa4d107806
  1. 35
      src/components/ec_api/TabArea.vue

@ -88,6 +88,7 @@ function initApiData() {
'handled': '',
'sig': '',
'format': 'json',
'reload': true,
'params': store.state.ecApiModule.ec_api_data.api_params[item.id]
}
}
@ -135,7 +136,8 @@ function addNewParams() {
//
function loadDefault(param) {
console.log(param)
get_suggest(true)
UserApiData.value.api[activeTab.value].reload = true
get_suggest()
}
//
@ -223,40 +225,44 @@ function send_request() {
req_loading.value = false
send_btn.value = '发送'
}
)
).catch(err => {
req_loading.value = false
send_btn.value = '发送'
ElMessage.error('获取请求结果失败!')
})
}
async function get_suggest(force) {
async function get_suggest() {
if (UserApiData.value.api[activeTab.value].reload === true) {
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)
let result = true
if (res.length === 0) {
result = true
}
res.forEach((suggest) => {
UserApiData.value.api[activeTab.value].params.forEach((param) => {
if (force) {
console.log('get_suggest force')
if (param.param === suggest.param) {
param['value'] = suggest['value']
param['default'] = suggest['value']
param['is_checked'] = suggest['is_checked']
if (suggest.result === false) {
result = false
}
} else {
console.log('get_suggest else')
if (param.param === suggest.param && param['default'] === null) {
if (param.param === suggest.param) {
param['value'] = suggest['value']
param['default'] = suggest['value']
param['is_checked'] = suggest['is_checked']
}
}
})
})
UserApiData.value.api[activeTab.value].reload = !result
}
).catch((err) => {
console.log(err)
})
}
}
//
function test() {
@ -298,10 +304,11 @@ watch(() => store.state.ecApiModule.ec_api_data.api, (oldValue, newValue) => {
}
}, {deep: true})
// activeTab
watch(activeTab, () => {
markIsChecked()
get_suggest(false)
get_suggest()
handle_request_url()
})

Loading…
Cancel
Save