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, + });