2021-10-31 23:48:55 +08:00
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<a-input-search
|
|
|
|
|
:addon-before="docInfoShow.method.toUpperCase()"
|
|
|
|
|
v-model:value="docUrl"
|
|
|
|
|
enter-button="发送请求"
|
|
|
|
|
@search="sendRequest"
|
|
|
|
|
/>
|
|
|
|
|
<a-tabs v-model:activeKey="activePage" closable @tab-click="" style="padding: 5px 10px 0;">
|
|
|
|
|
<a-tab-pane tab="URL参数" key="urlParam">
|
2021-11-01 22:51:03 +08:00
|
|
|
<ParamTable v-model:selected="urlParamChecked" :paramList="urlParamList"></ParamTable>
|
2021-10-31 23:48:55 +08:00
|
|
|
</a-tab-pane>
|
|
|
|
|
<a-tab-pane tab="请求参数" key="bodyParam">
|
2021-11-01 22:51:03 +08:00
|
|
|
<a-radio-group v-model:value="bodyParamType" style="margin-bottom: 5px;">
|
2021-10-31 23:48:55 +08:00
|
|
|
<a-radio value="none">none</a-radio>
|
|
|
|
|
<a-radio value="form">form-data</a-radio>
|
|
|
|
|
<a-radio value="formUrlEncode">x-www-form-urlencoded</a-radio>
|
|
|
|
|
<a-radio value="row">row</a-radio>
|
|
|
|
|
<a-radio value="binary">binary</a-radio>
|
|
|
|
|
</a-radio-group>
|
2021-11-01 22:51:03 +08:00
|
|
|
<div v-show="bodyParamType === 'form'">
|
|
|
|
|
<ParamTable v-model:selected="formParamChecked" :paramList="formParamList"></ParamTable>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-show="bodyParamType === 'formUrlEncode'">
|
|
|
|
|
<ParamTable v-model:selected="formEncodeParamChecked" :paramList="formEncodeParamList"></ParamTable>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-show="bodyParamType === 'row'">
|
|
|
|
|
<a-textarea placeholder="" v-model:value="bodyRowParam" :auto-size="{ minRows: 15, maxRows: 15 }"></a-textarea>
|
|
|
|
|
</div>
|
2021-10-31 23:48:55 +08:00
|
|
|
</a-tab-pane>
|
|
|
|
|
<a-tab-pane tab="Header参数" key="headerParam">
|
2021-11-01 22:51:03 +08:00
|
|
|
<ParamTable v-model:selected="headerParamChecked" :paramList="headerParamList"></ParamTable>
|
2021-10-31 23:48:55 +08:00
|
|
|
</a-tab-pane>
|
|
|
|
|
<a-tab-pane tab="Cookie参数" key="cookieParam">
|
2021-11-01 22:51:03 +08:00
|
|
|
<ParamTable v-model:selected="cookieParamChecked" :paramList="cookieParamList"></ParamTable>
|
2021-10-31 23:48:55 +08:00
|
|
|
</a-tab-pane>
|
|
|
|
|
</a-tabs>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import {toRefs, ref, reactive, onMounted, watch} from 'vue';
|
|
|
|
|
import { useRouter, useRoute } from "vue-router";
|
|
|
|
|
import {useStore} from 'vuex';
|
|
|
|
|
import { message } from 'ant-design-vue';
|
|
|
|
|
import {markdownIt} from 'mavon-editor'
|
2021-11-01 22:51:03 +08:00
|
|
|
import ParamTable from '../../../components/table/ParamTable.vue'
|
2021-10-31 23:48:55 +08:00
|
|
|
import {CloseOutlined} from '@ant-design/icons-vue';
|
|
|
|
|
import 'mavon-editor/dist/markdown/github-markdown.min.css'
|
|
|
|
|
import 'mavon-editor/dist/css/index.css'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
props: {
|
|
|
|
|
docInfoShow: {
|
|
|
|
|
type: Object,
|
|
|
|
|
required: true
|
|
|
|
|
},
|
|
|
|
|
requestParamList: {
|
|
|
|
|
type: Array,
|
|
|
|
|
required: true
|
|
|
|
|
},
|
|
|
|
|
responseParamList: {
|
|
|
|
|
type: Array,
|
|
|
|
|
required: true
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
components: {
|
2021-11-01 22:51:03 +08:00
|
|
|
CloseOutlined, ParamTable
|
2021-10-31 23:48:55 +08:00
|
|
|
},
|
|
|
|
|
setup(props) {
|
|
|
|
|
let docUrl = ref(props.docInfoShow.url);
|
|
|
|
|
let activePage = ref('urlParam');
|
|
|
|
|
// URL参数处理
|
2021-11-01 22:51:03 +08:00
|
|
|
const urlParamChecked = ref([]);
|
2021-10-31 23:48:55 +08:00
|
|
|
let urlParamListProp = props.requestParamList.filter(item => item.in === 'query');
|
|
|
|
|
let urlParamList = ref(JSON.parse(JSON.stringify(urlParamListProp)));
|
|
|
|
|
// Header参数处理
|
2021-11-01 22:51:03 +08:00
|
|
|
const headerParamChecked = ref([]);
|
|
|
|
|
let headerParamListProp = props.requestParamList.filter(item => item.in === 'header');
|
2021-10-31 23:48:55 +08:00
|
|
|
let headerParamList = ref(JSON.parse(JSON.stringify(headerParamListProp)));
|
|
|
|
|
// cookie参数处理
|
2021-11-01 22:51:03 +08:00
|
|
|
const cookieParamChecked = ref([]);
|
|
|
|
|
let cookieParamListProp = props.requestParamList.filter(item => item.in === 'cookie');
|
2021-10-31 23:48:55 +08:00
|
|
|
let cookieParamList = ref(JSON.parse(JSON.stringify(cookieParamListProp)));
|
2021-11-01 22:51:03 +08:00
|
|
|
// form参数处理
|
|
|
|
|
const formParamChecked = ref([]);
|
|
|
|
|
let formParamListProp = props.requestParamList.filter(item => item.in === 'formData');
|
|
|
|
|
let formParamList = ref([]);
|
|
|
|
|
// form参数处理
|
|
|
|
|
const formEncodeParamChecked = ref([]);
|
|
|
|
|
let formEncodeParamList = ref([]);
|
2021-10-31 23:48:55 +08:00
|
|
|
// body 参数
|
|
|
|
|
let bodyParamType = ref('form');
|
2021-11-01 22:51:03 +08:00
|
|
|
let bodyRowParam = ref('');
|
|
|
|
|
// x-www-form-urlencoded
|
|
|
|
|
if (props.docInfoShow.consumes.indexOf('x-www-form-urlencoded') >= 0) {
|
|
|
|
|
bodyParamType.value = 'formUrlEncode';
|
|
|
|
|
formEncodeParamList = ref(JSON.parse(JSON.stringify(formParamListProp)));
|
|
|
|
|
} else if (props.docInfoShow.consumes.indexOf('application/json') >= 0) {
|
|
|
|
|
bodyParamType.value = 'row';
|
|
|
|
|
} else {
|
|
|
|
|
formParamList = ref(JSON.parse(JSON.stringify(formParamListProp)));
|
|
|
|
|
}
|
2021-10-31 23:48:55 +08:00
|
|
|
// 发送请求
|
|
|
|
|
const sendRequest = () => {
|
2021-11-01 22:51:03 +08:00
|
|
|
console.log('urlParamChecked', urlParamChecked.value, urlParamList.value);
|
2021-10-31 23:48:55 +08:00
|
|
|
message.info('暂未开放此功能,敬请期待');
|
|
|
|
|
};
|
|
|
|
|
return {
|
|
|
|
|
docUrl,
|
|
|
|
|
activePage,
|
|
|
|
|
sendRequest,
|
|
|
|
|
// url参数
|
2021-11-01 22:51:03 +08:00
|
|
|
urlParamChecked,
|
2021-10-31 23:48:55 +08:00
|
|
|
urlParamList,
|
|
|
|
|
// header参数
|
2021-11-01 22:51:03 +08:00
|
|
|
headerParamChecked,
|
2021-10-31 23:48:55 +08:00
|
|
|
headerParamList,
|
|
|
|
|
// cookie参数
|
2021-11-01 22:51:03 +08:00
|
|
|
cookieParamChecked,
|
2021-10-31 23:48:55 +08:00
|
|
|
cookieParamList,
|
2021-11-01 22:51:03 +08:00
|
|
|
// form参数
|
|
|
|
|
formParamChecked,
|
|
|
|
|
formParamList,
|
|
|
|
|
// form-encode参数
|
|
|
|
|
formEncodeParamChecked,
|
|
|
|
|
formEncodeParamList,
|
2021-10-31 23:48:55 +08:00
|
|
|
// body参数
|
|
|
|
|
bodyParamType,
|
2021-11-01 22:51:03 +08:00
|
|
|
bodyRowParam,
|
2021-10-31 23:48:55 +08:00
|
|
|
responseCodeListColumns: [
|
|
|
|
|
{title: '状态码', dataIndex: 'code', width: 100},
|
|
|
|
|
{title: '类型', dataIndex: 'type', width: 250},
|
|
|
|
|
{title: '说明', dataIndex: 'desc'},
|
|
|
|
|
],
|
|
|
|
|
responseParamListColumns: [
|
|
|
|
|
{title: '参数名', dataIndex: 'name', width: 250},
|
|
|
|
|
{title: '类型', dataIndex: 'type', width: 250},
|
|
|
|
|
{title: '说明', dataIndex: 'description'},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|