调试参数解析展示
This commit is contained in:
2
zyplayer-doc-ui/swagger-ui/package-lock.json
generated
2
zyplayer-doc-ui/swagger-ui/package-lock.json
generated
@@ -1816,7 +1816,7 @@
|
|||||||
},
|
},
|
||||||
"vue-types": {
|
"vue-types": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"resolved": "https://registry.npmmirror.com/vue-types/download/vue-types-3.0.2.tgz",
|
"resolved": "https://registry.nlark.com/vue-types/download/vue-types-3.0.2.tgz",
|
||||||
"integrity": "sha1-7BbgXUEsA4Ji/B76TOuWR+f7YB0=",
|
"integrity": "sha1-7BbgXUEsA4Ji/B76TOuWR+f7YB0=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"is-plain-object": "3.0.1"
|
"is-plain-object": "3.0.1"
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
<template>
|
||||||
|
<a-table :row-selection="{ selectedRowKeys: queryParamSelectedRowKeys, onChange: queryParamRowSelectionChange }"
|
||||||
|
:dataSource="queryParamList"
|
||||||
|
:columns="queryParamListColumns" size="small"
|
||||||
|
:pagination="false"
|
||||||
|
:scroll="{ y: '300px' }">
|
||||||
|
<template #bodyCell="{ column, text, record }">
|
||||||
|
<template v-if="column.dataIndex === 'name'">
|
||||||
|
<a-input placeholder="请输入参数名" v-model:value="record.name" @change="queryParamChange(record)"></a-input>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'value'">
|
||||||
|
<a-input :placeholder="record.description || '请输入参数值'" v-model:value="record.value" @change="queryParamChange(record)"></a-input>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'action'">
|
||||||
|
<CloseOutlined v-if="!record.isLastRow" @click="queryParamRemove(record)" style="cursor: pointer;"/>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</a-table>
|
||||||
|
</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'
|
||||||
|
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: {
|
||||||
|
paramList: {
|
||||||
|
type: Array,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
CloseOutlined
|
||||||
|
},
|
||||||
|
emits: ['update:selected'],
|
||||||
|
setup(props, { attrs, slots, emit, expose }) {
|
||||||
|
let queryParamList = ref(props.paramList);
|
||||||
|
let nextIndex = 10000;
|
||||||
|
// Query参数处理
|
||||||
|
queryParamList.value.push({name: '', value: '', key: ++nextIndex, isLastRow: true});
|
||||||
|
let queryParamSelectedRowKeys = ref([]);
|
||||||
|
queryParamList.value.forEach(item => {
|
||||||
|
item.value = item.example || '';
|
||||||
|
queryParamSelectedRowKeys.value.push(item.key);
|
||||||
|
});
|
||||||
|
emit('update:selected', queryParamSelectedRowKeys.value);
|
||||||
|
const queryParamRowSelectionChange = (selectedRowKeys, selectedRows) => {
|
||||||
|
queryParamSelectedRowKeys.value = selectedRowKeys;
|
||||||
|
emit('update:selected', selectedRowKeys);
|
||||||
|
};
|
||||||
|
const queryParamChange = (record) => {
|
||||||
|
if (record.isLastRow) {
|
||||||
|
record.isLastRow = false;
|
||||||
|
queryParamList.value.push({name: '', value: '', key: ++nextIndex, isLastRow: true});
|
||||||
|
queryParamSelectedRowKeys.value.push(nextIndex);
|
||||||
|
emit('update:selected', queryParamSelectedRowKeys.value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const queryParamRemove = (record) => {
|
||||||
|
if (!record.isLastRow) {
|
||||||
|
queryParamList.value = queryParamList.value.filter(item => item !== record);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
queryParamList,
|
||||||
|
queryParamSelectedRowKeys,
|
||||||
|
queryParamRowSelectionChange,
|
||||||
|
queryParamChange,
|
||||||
|
queryParamRemove,
|
||||||
|
queryParamListColumns: [
|
||||||
|
{title: '参数名', dataIndex: 'name', width: 250},
|
||||||
|
{title: '参数值', dataIndex: 'value'},
|
||||||
|
{title: '', dataIndex: 'action', width: 40},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -8,58 +8,31 @@
|
|||||||
/>
|
/>
|
||||||
<a-tabs v-model:activeKey="activePage" closable @tab-click="" style="padding: 5px 10px 0;">
|
<a-tabs v-model:activeKey="activePage" closable @tab-click="" style="padding: 5px 10px 0;">
|
||||||
<a-tab-pane tab="URL参数" key="urlParam">
|
<a-tab-pane tab="URL参数" key="urlParam">
|
||||||
<a-table :row-selection="{ selectedRowKeys: urlParamSelectedRowKeys, onChange: urlParamRowSelectionChange }" :dataSource="urlParamList" :columns="urlParamListColumns" size="small" :pagination="false">
|
<ParamTable v-model:selected="urlParamChecked" :paramList="urlParamList"></ParamTable>
|
||||||
<template #bodyCell="{ column, text, record }">
|
|
||||||
<template v-if="column.dataIndex === 'name'">
|
|
||||||
<a-input placeholder="请输入参数名" v-model:value="record.name" @change="urlParamChange(record)"></a-input>
|
|
||||||
</template>
|
|
||||||
<template v-if="column.dataIndex === 'value'">
|
|
||||||
<a-input :placeholder="record.description || '请输入参数值'" v-model:value="record.value" @change="urlParamChange(record)"></a-input>
|
|
||||||
</template>
|
|
||||||
<template v-if="column.dataIndex === 'action'">
|
|
||||||
<CloseOutlined v-if="!record.isLastRow" @click="urlParamRemove(record)" style="cursor: pointer;"/>
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
</a-table>
|
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-tab-pane tab="请求参数" key="bodyParam">
|
<a-tab-pane tab="请求参数" key="bodyParam">
|
||||||
<a-radio-group v-model:value="bodyParamType">
|
<a-radio-group v-model:value="bodyParamType" style="margin-bottom: 5px;">
|
||||||
<a-radio value="none">none</a-radio>
|
<a-radio value="none">none</a-radio>
|
||||||
<a-radio value="form">form-data</a-radio>
|
<a-radio value="form">form-data</a-radio>
|
||||||
<a-radio value="formUrlEncode">x-www-form-urlencoded</a-radio>
|
<a-radio value="formUrlEncode">x-www-form-urlencoded</a-radio>
|
||||||
<a-radio value="row">row</a-radio>
|
<a-radio value="row">row</a-radio>
|
||||||
<a-radio value="binary">binary</a-radio>
|
<a-radio value="binary">binary</a-radio>
|
||||||
</a-radio-group>
|
</a-radio-group>
|
||||||
|
<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>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-tab-pane tab="Header参数" key="headerParam">
|
<a-tab-pane tab="Header参数" key="headerParam">
|
||||||
<a-table :row-selection="{ selectedRowKeys: headerParamSelectedRowKeys, onChange: headerParamRowSelectionChange }" :dataSource="headerParamList" :columns="headerParamListColumns" size="small" :pagination="false">
|
<ParamTable v-model:selected="headerParamChecked" :paramList="headerParamList"></ParamTable>
|
||||||
<template #bodyCell="{ column, text, record }">
|
|
||||||
<template v-if="column.dataIndex === 'name'">
|
|
||||||
<a-input placeholder="请输入参数名" v-model:value="record.name" @change="headerParamChange(record)"></a-input>
|
|
||||||
</template>
|
|
||||||
<template v-if="column.dataIndex === 'value'">
|
|
||||||
<a-input :placeholder="record.description || '请输入参数值'" v-model:value="record.value" @change="headerParamChange(record)"></a-input>
|
|
||||||
</template>
|
|
||||||
<template v-if="column.dataIndex === 'action'">
|
|
||||||
<CloseOutlined v-if="!record.isLastRow" @click="headerParamRemove(record)" style="cursor: pointer;"/>
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
</a-table>
|
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-tab-pane tab="Cookie参数" key="cookieParam">
|
<a-tab-pane tab="Cookie参数" key="cookieParam">
|
||||||
<a-table :row-selection="{ selectedRowKeys: cookieParamSelectedRowKeys, onChange: cookieParamRowSelectionChange }" :dataSource="cookieParamList" :columns="cookieParamListColumns" size="small" :pagination="false">
|
<ParamTable v-model:selected="cookieParamChecked" :paramList="cookieParamList"></ParamTable>
|
||||||
<template #bodyCell="{ column, text, record }">
|
|
||||||
<template v-if="column.dataIndex === 'name'">
|
|
||||||
<a-input placeholder="请输入参数名" v-model:value="record.name" @change="cookieParamChange(record)"></a-input>
|
|
||||||
</template>
|
|
||||||
<template v-if="column.dataIndex === 'value'">
|
|
||||||
<a-input :placeholder="record.description || '请输入参数值'" v-model:value="record.value" @change="cookieParamChange(record)"></a-input>
|
|
||||||
</template>
|
|
||||||
<template v-if="column.dataIndex === 'action'">
|
|
||||||
<CloseOutlined v-if="!record.isLastRow" @click="cookieParamRemove(record)" style="cursor: pointer;"/>
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
</a-table>
|
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
</a-tabs>
|
</a-tabs>
|
||||||
</div>
|
</div>
|
||||||
@@ -71,6 +44,7 @@
|
|||||||
import {useStore} from 'vuex';
|
import {useStore} from 'vuex';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import {markdownIt} from 'mavon-editor'
|
import {markdownIt} from 'mavon-editor'
|
||||||
|
import ParamTable from '../../../components/table/ParamTable.vue'
|
||||||
import {CloseOutlined} from '@ant-design/icons-vue';
|
import {CloseOutlined} from '@ant-design/icons-vue';
|
||||||
import 'mavon-editor/dist/markdown/github-markdown.min.css'
|
import 'mavon-editor/dist/markdown/github-markdown.min.css'
|
||||||
import 'mavon-editor/dist/css/index.css'
|
import 'mavon-editor/dist/css/index.css'
|
||||||
@@ -91,88 +65,45 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
CloseOutlined
|
CloseOutlined, ParamTable
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
let docUrl = ref(props.docInfoShow.url);
|
let docUrl = ref(props.docInfoShow.url);
|
||||||
let activePage = ref('urlParam');
|
let activePage = ref('urlParam');
|
||||||
let paramKeyIndex = 10000;
|
|
||||||
// URL参数处理
|
// URL参数处理
|
||||||
|
const urlParamChecked = ref([]);
|
||||||
let urlParamListProp = props.requestParamList.filter(item => item.in === 'query');
|
let urlParamListProp = props.requestParamList.filter(item => item.in === 'query');
|
||||||
urlParamListProp.push({name: '', value: '', key: ++paramKeyIndex, isLastRow: true});
|
|
||||||
let urlParamSelectedRowKeys = ref([]);
|
|
||||||
urlParamListProp.forEach(item => {
|
|
||||||
item.value = item.example || '';
|
|
||||||
urlParamSelectedRowKeys.value.push(item.key);
|
|
||||||
});
|
|
||||||
let urlParamList = ref(JSON.parse(JSON.stringify(urlParamListProp)));
|
let urlParamList = ref(JSON.parse(JSON.stringify(urlParamListProp)));
|
||||||
const urlParamRowSelectionChange = (selectedRowKeys, selectedRows) => {
|
|
||||||
urlParamSelectedRowKeys.value = selectedRowKeys;
|
|
||||||
};
|
|
||||||
const urlParamChange = (record) => {
|
|
||||||
if (record.isLastRow) {
|
|
||||||
record.isLastRow = false;
|
|
||||||
urlParamList.value.push({name: '', value: '', key: ++paramKeyIndex, isLastRow: true});
|
|
||||||
urlParamSelectedRowKeys.value.push(paramKeyIndex);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const urlParamRemove = (record) => {
|
|
||||||
if (!record.isLastRow) {
|
|
||||||
urlParamList.value = urlParamList.value.filter(item => item != record);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// Header参数处理
|
// Header参数处理
|
||||||
let headerParamListProp = props.requestParamList.filter(item => item.in === 'query');
|
const headerParamChecked = ref([]);
|
||||||
headerParamListProp.push({name: '', value: '', key: ++paramKeyIndex, isLastRow: true});
|
let headerParamListProp = props.requestParamList.filter(item => item.in === 'header');
|
||||||
let headerParamSelectedRowKeys = ref([]);
|
|
||||||
headerParamListProp.forEach(item => {
|
|
||||||
item.value = item.example || '';
|
|
||||||
headerParamSelectedRowKeys.value.push(item.key);
|
|
||||||
});
|
|
||||||
let headerParamList = ref(JSON.parse(JSON.stringify(headerParamListProp)));
|
let headerParamList = ref(JSON.parse(JSON.stringify(headerParamListProp)));
|
||||||
const headerParamRowSelectionChange = (selectedRowKeys, selectedRows) => {
|
|
||||||
headerParamSelectedRowKeys.value = selectedRowKeys;
|
|
||||||
};
|
|
||||||
const headerParamChange = (record) => {
|
|
||||||
if (record.isLastRow) {
|
|
||||||
record.isLastRow = false;
|
|
||||||
headerParamList.value.push({name: '', value: '', key: ++paramKeyIndex, isLastRow: true});
|
|
||||||
headerParamSelectedRowKeys.value.push(paramKeyIndex);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const headerParamRemove = (record) => {
|
|
||||||
if (!record.isLastRow) {
|
|
||||||
headerParamList.value = headerParamList.value.filter(item => item != record);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// cookie参数处理
|
// cookie参数处理
|
||||||
let cookieParamListProp = props.requestParamList.filter(item => item.in === 'query');
|
const cookieParamChecked = ref([]);
|
||||||
cookieParamListProp.push({name: '', value: '', key: ++paramKeyIndex, isLastRow: true});
|
let cookieParamListProp = props.requestParamList.filter(item => item.in === 'cookie');
|
||||||
let cookieParamSelectedRowKeys = ref([]);
|
|
||||||
cookieParamListProp.forEach(item => {
|
|
||||||
item.value = item.example || '';
|
|
||||||
cookieParamSelectedRowKeys.value.push(item.key);
|
|
||||||
});
|
|
||||||
let cookieParamList = ref(JSON.parse(JSON.stringify(cookieParamListProp)));
|
let cookieParamList = ref(JSON.parse(JSON.stringify(cookieParamListProp)));
|
||||||
const cookieParamRowSelectionChange = (selectedRowKeys, selectedRows) => {
|
// form参数处理
|
||||||
cookieParamSelectedRowKeys.value = selectedRowKeys;
|
const formParamChecked = ref([]);
|
||||||
};
|
let formParamListProp = props.requestParamList.filter(item => item.in === 'formData');
|
||||||
const cookieParamChange = (record) => {
|
let formParamList = ref([]);
|
||||||
if (record.isLastRow) {
|
// form参数处理
|
||||||
record.isLastRow = false;
|
const formEncodeParamChecked = ref([]);
|
||||||
cookieParamList.value.push({name: '', value: '', key: ++paramKeyIndex, isLastRow: true});
|
let formEncodeParamList = ref([]);
|
||||||
cookieParamSelectedRowKeys.value.push(paramKeyIndex);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const cookieParamRemove = (record) => {
|
|
||||||
if (!record.isLastRow) {
|
|
||||||
cookieParamList.value = cookieParamList.value.filter(item => item != record);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// body 参数
|
// body 参数
|
||||||
let bodyParamType = ref('form');
|
let bodyParamType = ref('form');
|
||||||
|
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)));
|
||||||
|
}
|
||||||
// 发送请求
|
// 发送请求
|
||||||
const sendRequest = () => {
|
const sendRequest = () => {
|
||||||
|
console.log('urlParamChecked', urlParamChecked.value, urlParamList.value);
|
||||||
message.info('暂未开放此功能,敬请期待');
|
message.info('暂未开放此功能,敬请期待');
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
@@ -180,40 +111,23 @@
|
|||||||
activePage,
|
activePage,
|
||||||
sendRequest,
|
sendRequest,
|
||||||
// url参数
|
// url参数
|
||||||
|
urlParamChecked,
|
||||||
urlParamList,
|
urlParamList,
|
||||||
urlParamSelectedRowKeys,
|
|
||||||
urlParamRowSelectionChange,
|
|
||||||
urlParamChange,
|
|
||||||
urlParamRemove,
|
|
||||||
urlParamListColumns: [
|
|
||||||
{title: '参数名', dataIndex: 'name', width: 250},
|
|
||||||
{title: '参数值', dataIndex: 'value'},
|
|
||||||
{title: '', dataIndex: 'action', width: 40},
|
|
||||||
],
|
|
||||||
// header参数
|
// header参数
|
||||||
|
headerParamChecked,
|
||||||
headerParamList,
|
headerParamList,
|
||||||
headerParamSelectedRowKeys,
|
|
||||||
headerParamRowSelectionChange,
|
|
||||||
headerParamChange,
|
|
||||||
headerParamRemove,
|
|
||||||
headerParamListColumns: [
|
|
||||||
{title: '参数名', dataIndex: 'name', width: 250},
|
|
||||||
{title: '参数值', dataIndex: 'value'},
|
|
||||||
{title: '', dataIndex: 'action', width: 40},
|
|
||||||
],
|
|
||||||
// cookie参数
|
// cookie参数
|
||||||
|
cookieParamChecked,
|
||||||
cookieParamList,
|
cookieParamList,
|
||||||
cookieParamSelectedRowKeys,
|
// form参数
|
||||||
cookieParamRowSelectionChange,
|
formParamChecked,
|
||||||
cookieParamChange,
|
formParamList,
|
||||||
cookieParamRemove,
|
// form-encode参数
|
||||||
cookieParamListColumns: [
|
formEncodeParamChecked,
|
||||||
{title: '参数名', dataIndex: 'name', width: 250},
|
formEncodeParamList,
|
||||||
{title: '参数值', dataIndex: 'value'},
|
|
||||||
{title: '', dataIndex: 'action', width: 40},
|
|
||||||
],
|
|
||||||
// body参数
|
// body参数
|
||||||
bodyParamType,
|
bodyParamType,
|
||||||
|
bodyRowParam,
|
||||||
responseCodeListColumns: [
|
responseCodeListColumns: [
|
||||||
{title: '状态码', dataIndex: 'code', width: 100},
|
{title: '状态码', dataIndex: 'code', width: 100},
|
||||||
{title: '类型', dataIndex: 'type', width: 250},
|
{title: '类型', dataIndex: 'type', width: 250},
|
||||||
|
|||||||
Reference in New Issue
Block a user