1. 支持xml格式化显示

2. xml支持显示选择模块
dev
RogerWork 3 months ago
parent f31a304359
commit 73825303c9
  1. 2
      src/components/HelloWorld.vue
  2. 25
      src/components/ec_api/TabArea.vue

@ -5,7 +5,7 @@
<template> <template>
<div> <div>
<el-text size="large" style="font-size: xxx-large">鼎新工具箱</el-text><br> <el-text size="large" style="font-size: xxx-large">鼎新工具箱</el-text><br>
<el-image src="public/main.jpeg" style="width: 600px"></el-image> <el-image src="/main.jpeg" style="width: 600px"></el-image>
</div> </div>
</template> </template>

@ -85,6 +85,7 @@ function initApiData() {
'type': item.type, 'type': item.type,
'url': '', 'url': '',
'response': '{"root": "root"}', 'response': '{"root": "root"}',
'handled': '',
'sig': '', 'sig': '',
'format': 'json', 'format': 'json',
'params': store.state.ecApiModule.ec_api_data.api_params[item.id] 'params': store.state.ecApiModule.ec_api_data.api_params[item.id]
@ -200,8 +201,6 @@ function send_request() {
// //
req_loading.value = true req_loading.value = true
send_btn.value = '请求中' send_btn.value = '请求中'
console.log('req_loading.value', req_loading.value)
console.log('send_btn.value', send_btn.value)
// //
if (UserApiData.value.api[activeTab.value].format === 'json') { if (UserApiData.value.api[activeTab.value].format === 'json') {
UserApiData.value.api[activeTab.value].response = '{"root": "root"}' UserApiData.value.api[activeTab.value].response = '{"root": "root"}'
@ -211,6 +210,7 @@ function send_request() {
} }
const data = handle_request_data() const data = handle_request_data()
ec_api_send_request(data).then(res => { ec_api_send_request(data).then(res => {
UserApiData.value.api[activeTab.value].handled = JSON.parse(res.handled)
if (res.format === 'json') { if (res.format === 'json') {
UserApiData.value.api[activeTab.value].response = JSON.stringify(JSON.parse(res.data), null, 2) UserApiData.value.api[activeTab.value].response = JSON.stringify(JSON.parse(res.data), null, 2)
} }
@ -219,11 +219,9 @@ function send_request() {
const serializer = new XMLSerializer(); const serializer = new XMLSerializer();
UserApiData.value.api[activeTab.value].response = serializer.serializeToString(xmlDoc); UserApiData.value.api[activeTab.value].response = serializer.serializeToString(xmlDoc);
} }
// //
req_loading.value = false req_loading.value = false
send_btn.value = '发送' send_btn.value = '发送'
console.log('req_loading.value', req_loading.value)
console.log('send_btn.value', send_btn.value)
} }
) )
@ -274,7 +272,14 @@ const showList = computed(() => {
if (api.response === '{"root": "root"}') { if (api.response === '{"root": "root"}') {
return [] return []
} else { } else {
return JSON.parse(api.response)['res']['data'] return api.handled['res']['data']
}
}
if (api.format === 'xml' || api.format === 'html') {
if (api.response === '<root></root>') {
return []
} else {
return api.handled['res']['data']
} }
} }
} }
@ -411,7 +416,9 @@ const ace_options = {
<el-input type="text" v-model="UserApiData.api[api['id']].url" :style="{'font-size': '18px'}"></el-input> <el-input type="text" v-model="UserApiData.api[api['id']].url" :style="{'font-size': '18px'}"></el-input>
</el-col> </el-col>
<el-col :span="2"> <el-col :span="2">
<el-button type="primary" @click="send_request" :loading="req_loading" :disabled="req_loading">{{send_btn}}</el-button> <el-button type="primary" @click="send_request" :loading="req_loading" :disabled="req_loading">
{{ send_btn }}
</el-button>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
</el-col> </el-col>

Loading…
Cancel
Save