From abcdecb5e2323636fba8486f0b6551bcb49d3e80 Mon Sep 17 00:00:00 2001 From: "xinxin.wu" Date: Mon, 4 Mar 2024 19:48:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=8F=82=E6=95=B0=E5=92=8C=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/projectManagement/environmental.ts | 8 ++++++- .../modules/setting/useProjectEnvStore.ts | 8 +++++-- .../environmental/components/EnvParamBox.vue | 21 +++++++++---------- .../components/envParams/EnvParamsTab.vue | 2 +- .../components/envParams/HttpTab.vue | 19 ++++++++++------- .../environmental/index.vue | 18 +++++++++------- 6 files changed, 45 insertions(+), 31 deletions(-) diff --git a/frontend/src/models/projectManagement/environmental.ts b/frontend/src/models/projectManagement/environmental.ts index d868c89156..f0c3599338 100644 --- a/frontend/src/models/projectManagement/environmental.ts +++ b/frontend/src/models/projectManagement/environmental.ts @@ -41,8 +41,14 @@ export interface ProcessorConfig { export interface AssertionConfig { assertions: EnvConfigItem[]; } + +export interface CommonParams { + requestTimeout: number; + responseTimeout: number; + [key: string]: any; +} export interface EnvConfig { - commonParams?: EnvConfigItem; + commonParams?: CommonParams; commonVariables: EnvConfigItem[]; httpConfig: EnvConfigItem[]; dataSources: DataSourceItem[]; diff --git a/frontend/src/store/modules/setting/useProjectEnvStore.ts b/frontend/src/store/modules/setting/useProjectEnvStore.ts index 009afcff98..fc3e315953 100644 --- a/frontend/src/store/modules/setting/useProjectEnvStore.ts +++ b/frontend/src/store/modules/setting/useProjectEnvStore.ts @@ -1,4 +1,5 @@ import { defineStore } from 'pinia'; +import { number } from 'echarts'; import localforage from 'localforage'; import { getDetailEnv, getGlobalParamDetail } from '@/api/modules/project-management/envManagement'; @@ -45,6 +46,10 @@ const envParamsDefaultConfig: EnvConfig = { }, assertionConfig: { assertions: [] }, pluginConfigMap: {}, + commonParams: { + requestTimeout: 60000, + responseTimeout: 60000, + }, }; const useProjectEnvStore = defineStore( @@ -92,7 +97,6 @@ const useProjectEnvStore = defineStore( const appStore = useAppStore(); try { if (id === NEW_ENV_PARAM) { - // TODO 数据参数问题 currentEnvDetailInfo.value = { projectId: appStore.currentProjectId, name: '', @@ -107,7 +111,7 @@ const useProjectEnvStore = defineStore( allParamDetailInfo.value = await getGlobalParamDetail(appStore.currentProjectId); } else if (id !== ALL_PARAM && id) { const tmpObj = await getDetailEnv(id); - currentEnvDetailInfo.value = tmpObj; + currentEnvDetailInfo.value = { ...tmpObj }; backupEnvDetailInfo.value = tmpObj; } } catch (e) { diff --git a/frontend/src/views/project-management/environmental/components/EnvParamBox.vue b/frontend/src/views/project-management/environmental/components/EnvParamBox.vue index e889755a7c..4693879f69 100644 --- a/frontend/src/views/project-management/environmental/components/EnvParamBox.vue +++ b/frontend/src/views/project-management/environmental/components/EnvParamBox.vue @@ -60,7 +60,7 @@ @@ -93,7 +93,6 @@ const activeKey = ref('envParams'); const envForm = ref(); - const canSave = ref(false); const { t } = useI18n(); const loading = ref(false); const tabSettingVisible = ref(false); @@ -179,15 +178,14 @@ envForm.value?.resetFields(); store.initEnvDetail(); }; + const handleSave = async () => { await envForm.value?.validate(async (valid) => { if (!valid) { try { loading.value = true; store.currentEnvDetailInfo.mock = true; - // TODO 需要重新处理收集参数 - const res = await updateOrAddEnv({ fileList: [], request: store.currentEnvDetailInfo }); - store.currentEnvDetailInfo = res; + await updateOrAddEnv({ fileList: [], request: store.currentEnvDetailInfo }); Message.success(t('common.saveSuccess')); emit('ok'); } catch (error) { @@ -212,12 +210,13 @@ form.description = currentEnvDetailInfo.description as string; } }); - watchEffect(() => { - if (store.currentEnvDetailInfo) { - const { currentEnvDetailInfo, backupEnvDetailInfo } = store; - canSave.value = !isEqual(currentEnvDetailInfo, backupEnvDetailInfo); - } - }); + + // watchEffect(() => { + // if (store.currentEnvDetailInfo) { + // const { currentEnvDetailInfo, backupEnvDetailInfo } = store; + // canSave.value = !isEqual(currentEnvDetailInfo, backupEnvDetailInfo); + // } + // }); const initTab = async () => { tabSettingVisible.value = false; diff --git a/frontend/src/views/project-management/environmental/components/envParams/EnvParamsTab.vue b/frontend/src/views/project-management/environmental/components/envParams/EnvParamsTab.vue index ef7ac9c905..2e79097cd8 100644 --- a/frontend/src/views/project-management/environmental/components/envParams/EnvParamsTab.vue +++ b/frontend/src/views/project-management/environmental/components/envParams/EnvParamsTab.vue @@ -15,7 +15,7 @@ set: (value: any) => { store.currentEnvDetailInfo.config.commonVariables = value; }, - get: () => store.currentEnvDetailInfo.config.commonVariables || [], + get: () => store.currentEnvDetailInfo.config?.commonVariables || [], }); diff --git a/frontend/src/views/project-management/environmental/components/envParams/HttpTab.vue b/frontend/src/views/project-management/environmental/components/envParams/HttpTab.vue index de0ee01989..2d38b63a37 100644 --- a/frontend/src/views/project-management/environmental/components/envParams/HttpTab.vue +++ b/frontend/src/views/project-management/environmental/components/envParams/HttpTab.vue @@ -8,12 +8,12 @@
{{ t('project.environmental.addHttp') }}
- + - + @@ -58,6 +58,7 @@ import useProjectEnvStore from '@/store/modules/setting/useProjectEnvStore'; import { BugListItem } from '@/models/bug-management'; + import type { CommonParams } from '@/models/projectManagement/environmental'; import { HttpForm } from '@/models/projectManagement/environmental'; import { TableKeyEnum } from '@/enums/tableEnum'; @@ -123,12 +124,6 @@ debug: true, }); - const form = reactive({ - linkOutTime: 60000, - timeOutTime: 60000, - authType: 'Basic Auth', - }); - const moreActionList: ActionsItem[] = [ { label: t('common.delete'), @@ -175,9 +170,17 @@ const handleNoWarning = () => { store.setHttpNoWarning(false); }; + watch(store.currentEnvDetailInfo.config.httpConfig, () => { propsRes.value.data = store.currentEnvDetailInfo.config.httpConfig; }); + + const form = computed({ + set: (value: any) => { + store.currentEnvDetailInfo.config.commonParams = { ...value }; + }, + get: () => store.currentEnvDetailInfo.config.commonParams as CommonParams, + });