diff --git a/frontend/src/api/modules/project-management/envManagement.ts b/frontend/src/api/modules/project-management/envManagement.ts new file mode 100644 index 0000000000..4a36da3eb1 --- /dev/null +++ b/frontend/src/api/modules/project-management/envManagement.ts @@ -0,0 +1,69 @@ +import MSR from '@/api/http/index'; +import * as envURL from '@/api/requrls/project-management/envManagement'; + +import type { + EnvDetailItem, + EnvGroupListItem, + EnvGroupProjectListItem, + EnvListItem, +} from '@/models/projectManagement/environmental'; +import { OptionsItem } from '@/models/setting/log'; + +export function updateEnv(data: EnvListItem) { + return MSR.post({ url: envURL.updateEnvUrl, data }); +} +export function listEnv(data: { projectId: string; keyword: string }) { + return MSR.post({ url: envURL.listEnvUrl, data }); +} +export function importEnv(data: { request: EnvListItem; fileList: File[] }) { + return MSR.uploadFile({ url: envURL.importEnvUrl }, data, '', true); +} +export function getEntryEnv(data: EnvListItem) { + return MSR.post({ url: envURL.getEntryEnvUrl, data }); +} +export function exportEnv(data: EnvListItem) { + return MSR.post({ url: envURL.exportEnvUrl, data }); +} +export function editPosEnv(data: EnvListItem) { + return MSR.post({ url: envURL.editPosEnvUrl, data }); +} + +/** 测试数据库连接 */ +export function validateDatabaseEnv(data: object) { + return MSR.post({ url: envURL.validateDatabaseEnvUrl, data }); +} +/** 获取数据库驱动option */ +export function driverOptionFun(organizationId: string) { + return MSR.get({ url: envURL.driverOptionUrl + organizationId }); +} + +export function addEnv(data: EnvListItem) { + return MSR.post({ url: envURL.addEnvUrl, data }); +} +export function getDetailEnv(id: string) { + return MSR.get({ url: envURL.detailEnvUrl + id }); +} +export function deleteEnv(data: EnvListItem) { + return MSR.post({ url: envURL.deleteEnvUrl, data }); +} +export function groupUpdateEnv(data: EnvListItem) { + return MSR.post({ url: envURL.groupUpdateEnvUrl, data }); +} +export function groupListEnv(data: EnvGroupListItem) { + return MSR.post({ url: envURL.groupListEnvUrl, data }); +} +export function groupEditPosEnv(data: EnvGroupListItem) { + return MSR.post({ url: envURL.groupEditPosEnvUrl, data }); +} +export function groupAddEnv(data: EnvGroupListItem) { + return MSR.post({ url: envURL.groupAddEnvUrl, data }); +} +export function groupDetailEnv(data: EnvListItem) { + return MSR.post({ url: envURL.groupDetailEnvUrl, data }); +} +export function groupDeleteEnv(data: EnvListItem) { + return MSR.post({ url: envURL.groupDeleteEnvUrl, data }); +} +export function groupProjectEnv(data: EnvGroupProjectListItem) { + return MSR.post({ url: envURL.groupProjectEnvUrl, data }); +} diff --git a/frontend/src/api/requrls/project-management/envManagement.ts b/frontend/src/api/requrls/project-management/envManagement.ts new file mode 100644 index 0000000000..a1150945ff --- /dev/null +++ b/frontend/src/api/requrls/project-management/envManagement.ts @@ -0,0 +1,18 @@ +export const updateEnvUrl = '/project/environment/update'; +export const listEnvUrl = '/project/environment/list'; +export const importEnvUrl = '/project/environment/import'; +export const getEntryEnvUrl = '/project/environment/get/entry'; +export const exportEnvUrl = '/project/environment/export'; +export const editPosEnvUrl = '/project/environment/edit/pos'; +export const validateDatabaseEnvUrl = '/project/environment/database/validate'; +export const addEnvUrl = '/project/environment/add'; +export const detailEnvUrl = '/project/environment/get/'; +export const deleteEnvUrl = '/project/environment/delete/'; +export const driverOptionUrl = '/project/environment/database/driver-options/'; +export const groupUpdateEnvUrl = '/project/environment/group/update'; +export const groupListEnvUrl = '/project/environment/group/list'; +export const groupEditPosEnvUrl = '/project/environment/group/edit/pos'; +export const groupAddEnvUrl = '/project/environment/group/add'; +export const groupDetailEnvUrl = '/project/environment/group/get/'; +export const groupDeleteEnvUrl = '/project/environment/group/delete/'; +export const groupProjectEnvUrl = '/project/environment/group/get-project'; diff --git a/frontend/src/components/business/ms-assertion/comp/ResponseTimeTab.vue b/frontend/src/components/business/ms-assertion/comp/ResponseTimeTab.vue new file mode 100644 index 0000000000..e694abfec2 --- /dev/null +++ b/frontend/src/components/business/ms-assertion/comp/ResponseTimeTab.vue @@ -0,0 +1,22 @@ + + + + + diff --git a/frontend/src/components/business/ms-assertion/comp/VariableTab.vue b/frontend/src/components/business/ms-assertion/comp/VariableTab.vue new file mode 100644 index 0000000000..2b5e3c3c4d --- /dev/null +++ b/frontend/src/components/business/ms-assertion/comp/VariableTab.vue @@ -0,0 +1,89 @@ + + + diff --git a/frontend/src/components/business/ms-assertion/index.vue b/frontend/src/components/business/ms-assertion/index.vue index 1d3e0151da..c8a68ea951 100644 --- a/frontend/src/components/business/ms-assertion/index.vue +++ b/frontend/src/components/business/ms-assertion/index.vue @@ -8,15 +8,19 @@
-
+
@@ -24,38 +28,92 @@ {{ item.label }}
+
+ + + + + + +
+
-
+
- - + + +
@@ -153,12 +227,23 @@ line-height: 16px; } &-title { - font-size: 12px; + font-size: 14px; font-weight: 400; color: var(--color-text-1); line-height: 22px; } } + &-switch { + display: flex; + flex-direction: row; + align-items: center; + gap: 4px; + &-action { + display: flex; + align-items: center; + gap: 4px; + } + } } } &-right { @@ -171,4 +256,35 @@ } } } + .action-btn-move, + .action-btn-more { + opacity: 0; + transition: opacity 0.2s; + } + .ms-assertion-body-left-item-active { + background-color: rgb(var(--primary-1)) !important; + .ms-assertion-body-left-item-row { + &-num { + color: rgb(var(--primary-5)) !important; + background-color: var(--color-text-fff) !important; + } + &-title { + color: rgb(var(--primary-5)); + } + } + } + .ms-assertion-body-left-item:hover { + background-color: rgb(var(--primary-1)); + .action-btn-move, + .action-btn-more { + opacity: 1; + } + } + .ms-assertion-body-left-item-active-focus { + background-color: rgb(var(--primary-1)); + .action-btn-move, + .action-btn-more { + opacity: 1; + } + } diff --git a/frontend/src/components/business/ms-assertion/locale/zh-CN.ts b/frontend/src/components/business/ms-assertion/locale/zh-CN.ts index ba79dd0c20..89023fda53 100644 --- a/frontend/src/components/business/ms-assertion/locale/zh-CN.ts +++ b/frontend/src/components/business/ms-assertion/locale/zh-CN.ts @@ -9,4 +9,5 @@ export default { 'ms.assertion.noValidation': '不校验', 'ms.assertion.matchCondition': '匹配条件', 'ms.assertion.matchValue': '匹配值', + 'ms.assertion.variableName': '变量名', }; diff --git a/frontend/src/components/business/ms-assertion/type.ts b/frontend/src/components/business/ms-assertion/type.ts new file mode 100644 index 0000000000..ea9c6fec94 --- /dev/null +++ b/frontend/src/components/business/ms-assertion/type.ts @@ -0,0 +1,5 @@ +export interface MsAssertionItem { + id: string; + label: string; + value: string; +} diff --git a/frontend/src/models/projectManagement/environmental.ts b/frontend/src/models/projectManagement/environmental.ts index 0f38b4b941..e6e9b0f68a 100644 --- a/frontend/src/models/projectManagement/environmental.ts +++ b/frontend/src/models/projectManagement/environmental.ts @@ -1,3 +1,5 @@ +import { key } from 'localforage'; + export interface EnvListItem { name: string; id: string; @@ -14,3 +16,37 @@ export interface EnvGroupListItem { id: string; projectList: EnvGroupProjectListItem[]; } +export interface DataSourceItem { + id?: string; + name: string; + driverId?: string; + dbUrl: string; + username: string; + password?: string; + poolMax?: number; + timeout?: number; + enable?: boolean; +} + +export interface EnvConfigItem { + [key: string]: any; +} +export interface EnvConfig { + commonParams?: EnvConfigItem; + commmonVariables?: EnvConfigItem[]; + httpConfig?: EnvConfigItem[]; + dataSource?: DataSourceItem[]; + hostConfig?: EnvConfigItem; + authConfig?: EnvConfigItem; + preScript?: EnvConfigItem; + postScript?: EnvConfigItem; + assertions?: EnvConfigItem; +} +export interface EnvDetailItem { + id?: string; + projectId: string; + name: string; + config: EnvConfig; + mock?: string; + description?: string; +} diff --git a/frontend/src/store/modules/setting/useProjectEnvStore.ts b/frontend/src/store/modules/setting/useProjectEnvStore.ts index 8b03f1840e..5407380cb1 100644 --- a/frontend/src/store/modules/setting/useProjectEnvStore.ts +++ b/frontend/src/store/modules/setting/useProjectEnvStore.ts @@ -1,13 +1,17 @@ import { defineStore } from 'pinia'; -import { EnvGroupListItem } from '@/models/projectManagement/environmental'; +import { getDetailEnv } from '@/api/modules/project-management/envManagement'; + +import { EnvDetailItem, EnvGroupListItem } from '@/models/projectManagement/environmental'; export const ALL_PARAM = 'allParam'; +export const NEW_ENV_PARAM = 'newEnvParam'; const useProjectEnvStore = defineStore( 'projectEnv', () => { - const currentId = ref(1); + const currentId = ref(''); + const currentEnvDetailInfo = ref(); const httpNoWarning = ref(true); const envGroupList = ref([]); @@ -16,22 +20,41 @@ const useProjectEnvStore = defineStore( const getGroupLength = computed(() => 1); const getDatabaseList = computed(() => [{ id: 1, name: 'test' }]); - function setCurrentId(id: string | number) { + function setCurrentId(id: string) { currentId.value = id; } function setHttpNoWarning(noWarning: boolean) { httpNoWarning.value = noWarning; } + function setEnvDetailInfo(item: EnvDetailItem) { + currentEnvDetailInfo.value = item; + } + async function initEnvDetail() { + const id = currentId.value; + try { + if (id === NEW_ENV_PARAM) { + currentEnvDetailInfo.value = undefined; + } else if (id !== ALL_PARAM && id) { + currentEnvDetailInfo.value = await getDetailEnv(id); + } + } catch (e) { + // eslint-disable-next-line no-console + console.log(e); + } + } + return { getCurrentId, currentId, httpNoWarning, setCurrentId, setHttpNoWarning, + setEnvDetailInfo, getHttpNoWarning, getDatabaseList, envGroupList, getGroupLength, + initEnvDetail, }; }, { diff --git a/frontend/src/views/api-test/components/paramTable.vue b/frontend/src/views/api-test/components/paramTable.vue index 875fb22552..42ad079706 100644 --- a/frontend/src/views/api-test/components/paramTable.vue +++ b/frontend/src/views/api-test/components/paramTable.vue @@ -183,17 +183,17 @@ /> { + await store.initEnvDetail(); + }; + watchEffect(() => { + if (store.currentId === NEW_ENV_PARAM) { + store.setEnvDetailInfo({ + name: '', + projectId: appStore.currentProjectId, + config: {}, + }); + } else { + initData(); + } + });