feat(接口测试): 自定义请求根据是否引用环境渲染插件脚本
This commit is contained in:
parent
9c868f8097
commit
352eead6ea
|
@ -39,7 +39,6 @@
|
||||||
v-model:model-value="requestVModel.useEnv"
|
v-model:model-value="requestVModel.useEnv"
|
||||||
:style="{ width: '150px', float: 'right' }"
|
:style="{ width: '150px', float: 'right' }"
|
||||||
:allow-search="false"
|
:allow-search="false"
|
||||||
allow-clear
|
|
||||||
:options="[
|
:options="[
|
||||||
{ label: t('common.quote'), value: 'true' },
|
{ label: t('common.quote'), value: 'true' },
|
||||||
{ label: t('common.notQuote'), value: 'false' },
|
{ label: t('common.notQuote'), value: 'false' },
|
||||||
|
@ -48,6 +47,7 @@
|
||||||
value-key="value"
|
value-key="value"
|
||||||
label-key="label"
|
label-key="label"
|
||||||
:prefix="t('project.environmental.env')"
|
:prefix="t('project.environmental.env')"
|
||||||
|
@change="handleUseEnvChange"
|
||||||
>
|
>
|
||||||
</MsSelect>
|
</MsSelect>
|
||||||
</div>
|
</div>
|
||||||
|
@ -74,10 +74,10 @@
|
||||||
class="flex items-center"
|
class="flex items-center"
|
||||||
/>
|
/>
|
||||||
<a-tooltip v-if="!isHttpProtocol" content="requestVModel.label" :mouse-enter-delay="500">
|
<a-tooltip v-if="!isHttpProtocol" content="requestVModel.label" :mouse-enter-delay="500">
|
||||||
<div class="one-line-text max-w-[350px]"> requestVModel.label </div>
|
<div class="one-line-text max-w-[350px]"> requestVModel.label</div>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip :content="requestVModel.label" :mouse-enter-delay="500">
|
<a-tooltip :content="requestVModel.label" :mouse-enter-delay="500">
|
||||||
<div class="one-line-text max-w-[350px]"> {{ requestVModel.label }} </div>
|
<div class="one-line-text max-w-[350px]"> {{ requestVModel.label }}</div>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</div>
|
</div>
|
||||||
<a-input-group v-if="isHttpProtocol" class="flex-1">
|
<a-input-group v-if="isHttpProtocol" class="flex-1">
|
||||||
|
@ -546,6 +546,7 @@
|
||||||
|
|
||||||
const protocolLoading = ref(false);
|
const protocolLoading = ref(false);
|
||||||
const protocolOptions = ref<SelectOptionData[]>([]);
|
const protocolOptions = ref<SelectOptionData[]>([]);
|
||||||
|
|
||||||
async function initProtocolList() {
|
async function initProtocolList() {
|
||||||
try {
|
try {
|
||||||
protocolLoading.value = true;
|
protocolLoading.value = true;
|
||||||
|
@ -591,7 +592,11 @@
|
||||||
function controlPluginFormFields() {
|
function controlPluginFormFields() {
|
||||||
const allFields = fApi.value?.fields();
|
const allFields = fApi.value?.fields();
|
||||||
let fields: string[] = [];
|
let fields: string[] = [];
|
||||||
|
if (requestVModel.value.useEnv === 'true') {
|
||||||
|
fields = pluginScriptMap.value[requestVModel.value.protocol].apiDefinitionFields || [];
|
||||||
|
} else {
|
||||||
fields = pluginScriptMap.value[requestVModel.value.protocol].apiDebugFields || [];
|
fields = pluginScriptMap.value[requestVModel.value.protocol].apiDebugFields || [];
|
||||||
|
}
|
||||||
fApi.value?.hidden(true, allFields?.filter((e) => !fields.includes(e)) || []);
|
fApi.value?.hidden(true, allFields?.filter((e) => !fields.includes(e)) || []);
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
@ -628,6 +633,20 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 切换是否使用环境变量
|
||||||
|
async function handleUseEnvChange() {
|
||||||
|
const pluginId = protocolOptions.value.find((e) => e.value === requestVModel.value.protocol)?.pluginId;
|
||||||
|
const res = await getPluginScript(pluginId);
|
||||||
|
pluginScriptMap.value[requestVModel.value.protocol] = res;
|
||||||
|
fApi.value?.nextTick(() => {
|
||||||
|
controlPluginFormFields();
|
||||||
|
});
|
||||||
|
nextTick(() => {
|
||||||
|
// 如果是没有缓存也不是编辑,则需要重置表单,因为 form-create 只有一个实例,已经被其他有数据的 tab 污染了,需要重置
|
||||||
|
fApi.value?.resetFields();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const pluginError = ref(false);
|
const pluginError = ref(false);
|
||||||
|
|
||||||
async function initPluginScript() {
|
async function initPluginScript() {
|
||||||
|
@ -722,9 +741,11 @@
|
||||||
|
|
||||||
const verticalSplitBoxRef = ref<InstanceType<typeof MsSplitBox>>();
|
const verticalSplitBoxRef = ref<InstanceType<typeof MsSplitBox>>();
|
||||||
const isVerticalExpanded = ref(true);
|
const isVerticalExpanded = ref(true);
|
||||||
|
|
||||||
function handleVerticalExpandChange(val: boolean) {
|
function handleVerticalExpandChange(val: boolean) {
|
||||||
isVerticalExpanded.value = val;
|
isVerticalExpanded.value = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeVerticalExpand(val: boolean) {
|
function changeVerticalExpand(val: boolean) {
|
||||||
isVerticalExpanded.value = val;
|
isVerticalExpanded.value = val;
|
||||||
if (val) {
|
if (val) {
|
||||||
|
@ -769,6 +790,7 @@
|
||||||
|
|
||||||
const reportId = ref('');
|
const reportId = ref('');
|
||||||
const websocket = ref<WebSocket>();
|
const websocket = ref<WebSocket>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开启websocket监听,接收执行结果
|
* 开启websocket监听,接收执行结果
|
||||||
*/
|
*/
|
||||||
|
@ -941,6 +963,7 @@
|
||||||
websocket.value?.close();
|
websocket.value?.close();
|
||||||
requestVModel.value.executeLoading = false;
|
requestVModel.value.executeLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const step = ref<CustomApiStep>();
|
const step = ref<CustomApiStep>();
|
||||||
|
|
||||||
function handleContinue() {
|
function handleContinue() {
|
||||||
|
@ -948,6 +971,7 @@
|
||||||
emit('addStep', step.value);
|
emit('addStep', step.value);
|
||||||
requestVModel.value = { ...defaultDebugParams };
|
requestVModel.value = { ...defaultDebugParams };
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSave() {
|
function handleSave() {
|
||||||
handleContinue();
|
handleContinue();
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
|
@ -979,6 +1003,7 @@
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.exec-btn {
|
.exec-btn {
|
||||||
margin-right: 12px;
|
margin-right: 12px;
|
||||||
|
|
||||||
:deep(.arco-btn) {
|
:deep(.arco-btn) {
|
||||||
color: white !important;
|
color: white !important;
|
||||||
background-color: rgb(var(--primary-5)) !important;
|
background-color: rgb(var(--primary-5)) !important;
|
||||||
|
@ -987,26 +1012,32 @@
|
||||||
.btn-base-primary-disabled();
|
.btn-base-primary-disabled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-pane-container {
|
.tab-pane-container {
|
||||||
@apply flex-1 overflow-y-auto;
|
@apply flex-1 overflow-y-auto;
|
||||||
.ms-scroll-bar();
|
.ms-scroll-bar();
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.no-content) {
|
:deep(.no-content) {
|
||||||
.arco-tabs-content {
|
.arco-tabs-content {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.arco-tabs-tab:first-child) {
|
:deep(.arco-tabs-tab:first-child) {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.arco-tabs-tab) {
|
:deep(.arco-tabs-tab) {
|
||||||
@apply leading-none;
|
@apply leading-none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hidden-second {
|
.hidden-second {
|
||||||
:deep(.arco-split-trigger) {
|
:deep(.arco-split-trigger) {
|
||||||
@apply hidden;
|
@apply hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.show-second {
|
.show-second {
|
||||||
:deep(.arco-split-trigger) {
|
:deep(.arco-split-trigger) {
|
||||||
@apply block;
|
@apply block;
|
||||||
|
|
Loading…
Reference in New Issue