From 5d64a05a91a8b758f60f1f4c3eafcd1f1245df9e Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Thu, 21 Mar 2024 11:59:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=AF=B7=E6=B1=82=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/common/customApiDrawer.vue | 61 +++++++++++-------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/frontend/src/views/api-test/scenario/components/common/customApiDrawer.vue b/frontend/src/views/api-test/scenario/components/common/customApiDrawer.vue index 4a3bf59fcc..4bc4cb6e74 100644 --- a/frontend/src/views/api-test/scenario/components/common/customApiDrawer.vue +++ b/frontend/src/views/api-test/scenario/components/common/customApiDrawer.vue @@ -633,16 +633,17 @@ // 切换是否使用环境变量 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(); - }); + if (!isHttpProtocol.value) { + 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(() => { + fApi.value?.resetFields(); + }); + } } const pluginError = ref(false); @@ -976,22 +977,32 @@ const showAddDependencyDrawer = ref(false); const addDependencyMode = ref<'pre' | 'post'>('pre'); - watch( - () => visible.value, - async (val) => { - if (val) { - await initProtocolList(); - if (props.request) { - requestVModel.value = { ...defaultDebugParams, ...props.request }; - handleActiveDebugProtocolChange(requestVModel.value.protocol); - } else { - requestVModel.value = { ...defaultDebugParams }; - } - } else { - requestVModel.value = { ...defaultDebugParams }; - } + // watch( + // () => visible.value, + // async (val) => { + // if (val) { + // await initProtocolList(); + // if (props.request) { + // requestVModel.value = { ...defaultDebugParams, ...props.request }; + // handleActiveDebugProtocolChange(requestVModel.value.protocol); + // } else { + // requestVModel.value = { ...defaultDebugParams }; + // } + // } else { + // requestVModel.value = { ...defaultDebugParams }; + // } + // } + // ); + + onBeforeMount(() => { + initProtocolList(); + if (props.request) { + requestVModel.value = { ...defaultDebugParams, ...props.request }; + handleActiveDebugProtocolChange(requestVModel.value.protocol); + } else { + requestVModel.value = { ...defaultDebugParams }; } - ); + });