|
|
|
@ -3,10 +3,10 @@ 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"; |
|
|
|
|
import {VAceEditor} from "vue3-ace-editor"; |
|
|
|
|
import {ElMessage} from "element-plus"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -196,10 +196,10 @@ function handle_request_url() { |
|
|
|
|
|
|
|
|
|
// 发送api请求 |
|
|
|
|
function send_request() { |
|
|
|
|
if (UserApiData.value.api[activeTab.value].format === 'json'){ |
|
|
|
|
if (UserApiData.value.api[activeTab.value].format === 'json') { |
|
|
|
|
UserApiData.value.api[activeTab.value].response = '{"root": "root"}' |
|
|
|
|
} |
|
|
|
|
if (UserApiData.value.api[activeTab.value].format === 'html' || UserApiData.value.api[activeTab.value].format === 'xml'){ |
|
|
|
|
if (UserApiData.value.api[activeTab.value].format === 'html' || UserApiData.value.api[activeTab.value].format === 'xml') { |
|
|
|
|
UserApiData.value.api[activeTab.value].response = '<root></root>' |
|
|
|
|
} |
|
|
|
|
const data = handle_request_data() |
|
|
|
@ -208,7 +208,7 @@ function send_request() { |
|
|
|
|
UserApiData.value.api[activeTab.value].response = JSON.stringify(JSON.parse(res.data), null, 2) |
|
|
|
|
} |
|
|
|
|
if (res.format === 'xml') { |
|
|
|
|
const xmlDoc = new DOMParser().parseFromString(res.data , 'application/xml'); |
|
|
|
|
const xmlDoc = new DOMParser().parseFromString(res.data, 'application/xml'); |
|
|
|
|
const serializer = new XMLSerializer(); |
|
|
|
|
UserApiData.value.api[activeTab.value].response = serializer.serializeToString(xmlDoc); |
|
|
|
|
} |
|
|
|
@ -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() |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|