From 74aee959c641bef043cbd780431cfd6c32d47ce9 Mon Sep 17 00:00:00 2001 From: RubyLiu Date: Fri, 19 Jan 2024 18:53:31 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E7=AE=A1=E7=90=86=E5=85=A8=E5=B1=80=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project-management/envManagement.ts | 22 +++- .../project-management/envManagement.ts | 6 ++ .../src/components/pure/ms-upload/iconMap.ts | 4 + frontend/src/enums/tableEnum.ts | 2 + frontend/src/enums/uploadEnum.ts | 1 + frontend/src/locale/zh-CN/common.ts | 2 + .../models/projectManagement/environmental.ts | 9 ++ .../modules/setting/useProjectEnvStore.ts | 37 ++++--- .../views/api-test/components/paramTable.vue | 31 ++++-- .../environmental/components/AllParamBox.vue | 96 +++++++++++++++-- .../environmental/components/EnvGroupBox.vue | 2 +- .../components/allParams/index.vue | 68 ++++++------ .../components/common/CommonImportPop.vue | 102 ++++++++++++++++++ .../components/envParams/DatabaseTab.vue | 5 +- .../components/requestHeader/index.vue | 35 ++++-- .../environmental/index.vue | 55 +++++++++- .../environmental/locale/zh-CN.ts | 6 ++ 17 files changed, 394 insertions(+), 89 deletions(-) create mode 100644 frontend/src/views/project-management/environmental/components/common/CommonImportPop.vue diff --git a/frontend/src/api/modules/project-management/envManagement.ts b/frontend/src/api/modules/project-management/envManagement.ts index 4a36da3eb1..9d273d7794 100644 --- a/frontend/src/api/modules/project-management/envManagement.ts +++ b/frontend/src/api/modules/project-management/envManagement.ts @@ -1,3 +1,5 @@ +import { FileItem } from '@arco-design/web-vue'; + import MSR from '@/api/http/index'; import * as envURL from '@/api/requrls/project-management/envManagement'; @@ -6,6 +8,7 @@ import type { EnvGroupListItem, EnvGroupProjectListItem, EnvListItem, + GlobalParams, } from '@/models/projectManagement/environmental'; import { OptionsItem } from '@/models/setting/log'; @@ -15,7 +18,7 @@ export function updateEnv(data: EnvListItem) { export function listEnv(data: { projectId: string; keyword: string }) { return MSR.post({ url: envURL.listEnvUrl, data }); } -export function importEnv(data: { request: EnvListItem; fileList: File[] }) { +export function importEnv(data: { request: EnvListItem; fileList: FileItem[] }) { return MSR.uploadFile({ url: envURL.importEnvUrl }, data, '', true); } export function getEntryEnv(data: EnvListItem) { @@ -67,3 +70,20 @@ export function groupDeleteEnv(data: EnvListItem) { export function groupProjectEnv(data: EnvGroupProjectListItem) { return MSR.post({ url: envURL.groupProjectEnvUrl, data }); } + +/** 项目管理-环境-全局参数-更新or新增 */ +export function updateOrAddGlobalParam(data: GlobalParams) { + return MSR.post({ url: data.id ? envURL.updateGlobalParamUrl : envURL.addGlobalParamUrl, data }); +} +/** 项目管理-环境-全局参数-导入 */ +export function importGlobalParam(data: { request: any; fileList: FileItem[] }) { + return MSR.uploadFile({ url: envURL.importGlobalParamUrl }, data, '', false); +} +/** 项目管理-环境-全局参数-详情 */ +export function getGlobalParamDetail(id: string) { + return MSR.get({ url: envURL.detailGlobalParamUrl + id }); +} +/** 项目管理-环境-全局参数-导出 */ +export function exportGlobalParam(id: string) { + return MSR.get({ url: envURL.exportGlobalParamUrl + id }); +} diff --git a/frontend/src/api/requrls/project-management/envManagement.ts b/frontend/src/api/requrls/project-management/envManagement.ts index a1150945ff..595e1e3ce4 100644 --- a/frontend/src/api/requrls/project-management/envManagement.ts +++ b/frontend/src/api/requrls/project-management/envManagement.ts @@ -16,3 +16,9 @@ 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'; +// 全局参数 +export const updateGlobalParamUrl = '/project/global/params/update'; +export const addGlobalParamUrl = '/project/global/params/add'; +export const importGlobalParamUrl = '/project/global/params/import'; +export const detailGlobalParamUrl = '/project/global/params/get/'; +export const exportGlobalParamUrl = '/project/global/params/export/'; diff --git a/frontend/src/components/pure/ms-upload/iconMap.ts b/frontend/src/components/pure/ms-upload/iconMap.ts index 985b3fdb3d..18c2a15aca 100644 --- a/frontend/src/components/pure/ms-upload/iconMap.ts +++ b/frontend/src/components/pure/ms-upload/iconMap.ts @@ -72,6 +72,10 @@ export const FileIconMap: FileIconMapping = { [UploadStatus.init]: 'icon-icon_file-unknow_colorful1', [UploadStatus.done]: 'icon-icon_file-unknow_colorful1', }, + json: { + [UploadStatus.init]: 'icon-icon_file-json_colorful_ash', + [UploadStatus.done]: 'icon-icon_file-json_colorful1', + }, }; /** diff --git a/frontend/src/enums/tableEnum.ts b/frontend/src/enums/tableEnum.ts index 2dff74707f..f796a9e115 100644 --- a/frontend/src/enums/tableEnum.ts +++ b/frontend/src/enums/tableEnum.ts @@ -50,6 +50,8 @@ export enum TableKeyEnum { PROJECT_MANAGEMENT_ENV_ALL_PARAM = 'projectManagementEnvAllParam', PROJECT_MANAGEMENT_ENV_ENV_PARAM = 'projectManagementEnvEnvParam', PROJECT_MANAGEMENT_ENV_ENV_HTTP = 'projectManagementEnvEnvHttp', + PROJECT_MANAGEMENT_ENV_ALL_PARAM_HEADER = 'projectManagementEnvAllParamHeader', + PROJECT_MANAGEMENT_ENV_ALL_PARAM_VARIABLE = 'projectManagementEnvAllParamVariable', } // 具有特殊功能的列 diff --git a/frontend/src/enums/uploadEnum.ts b/frontend/src/enums/uploadEnum.ts index de0b6a0a01..4d7f1220c7 100644 --- a/frontend/src/enums/uploadEnum.ts +++ b/frontend/src/enums/uploadEnum.ts @@ -15,6 +15,7 @@ export enum UploadAcceptEnum { sketch = '.sketch', none = 'none', unknown = 'unknown', + json = '.json', } export enum UploadStatus { diff --git a/frontend/src/locale/zh-CN/common.ts b/frontend/src/locale/zh-CN/common.ts index e2ce707e35..6606d80a77 100644 --- a/frontend/src/locale/zh-CN/common.ts +++ b/frontend/src/locale/zh-CN/common.ts @@ -88,6 +88,8 @@ export default { 'common.number': '数字', 'common.boolean': '布尔', 'common.array': '数组', + 'common.list': '列表', + 'common.constant': '常量', 'common.json': '对象', 'common.integer': '整数', 'common.file': '文件', diff --git a/frontend/src/models/projectManagement/environmental.ts b/frontend/src/models/projectManagement/environmental.ts index e6e9b0f68a..bb98b1b26a 100644 --- a/frontend/src/models/projectManagement/environmental.ts +++ b/frontend/src/models/projectManagement/environmental.ts @@ -50,3 +50,12 @@ export interface EnvDetailItem { mock?: string; description?: string; } +export interface GlobalParamsItem { + headers: EnvConfigItem[]; + commonVariables: EnvConfigItem[]; +} +export interface GlobalParams { + id?: string; + projectId: string; + globalParams: GlobalParamsItem; +} diff --git a/frontend/src/store/modules/setting/useProjectEnvStore.ts b/frontend/src/store/modules/setting/useProjectEnvStore.ts index 5407380cb1..5456dd7bd9 100644 --- a/frontend/src/store/modules/setting/useProjectEnvStore.ts +++ b/frontend/src/store/modules/setting/useProjectEnvStore.ts @@ -1,8 +1,9 @@ import { defineStore } from 'pinia'; -import { getDetailEnv } from '@/api/modules/project-management/envManagement'; +import { getDetailEnv, getGlobalParamDetail } from '@/api/modules/project-management/envManagement'; +import { useAppStore } from '@/store'; -import { EnvDetailItem, EnvGroupListItem } from '@/models/projectManagement/environmental'; +import { EnvDetailItem, GlobalParams } from '@/models/projectManagement/environmental'; export const ALL_PARAM = 'allParam'; export const NEW_ENV_PARAM = 'newEnvParam'; @@ -10,30 +11,37 @@ export const NEW_ENV_PARAM = 'newEnvParam'; const useProjectEnvStore = defineStore( 'projectEnv', () => { - const currentId = ref(''); - const currentEnvDetailInfo = ref(); + const currentId = ref(ALL_PARAM); // 当前选中的key值 + const currentEnvDetailInfo = ref(); // 当前选中的环境详情 + const allParamDetailInfo = ref(); // 全局参数详情 const httpNoWarning = ref(true); - const envGroupList = ref([]); - - const getCurrentId = computed(() => currentId.value); const getHttpNoWarning = computed(() => httpNoWarning.value); - const getGroupLength = computed(() => 1); - - const getDatabaseList = computed(() => [{ id: 1, name: 'test' }]); + const groupLength = ref(0); // 环境分组数据 + // 设置选中项 function setCurrentId(id: string) { currentId.value = id; } + // 设置http提醒 function setHttpNoWarning(noWarning: boolean) { httpNoWarning.value = noWarning; } + // 设置环境详情 function setEnvDetailInfo(item: EnvDetailItem) { currentEnvDetailInfo.value = item; } + // 设置全局参数 + function setAllParamDetailInfo(item: GlobalParams) { + allParamDetailInfo.value = item; + } + // 初始化环境详情 async function initEnvDetail() { const id = currentId.value; + const appStore = useAppStore(); try { if (id === NEW_ENV_PARAM) { currentEnvDetailInfo.value = undefined; + } else if (id === ALL_PARAM) { + allParamDetailInfo.value = await getGlobalParamDetail(appStore.currentProjectId); } else if (id !== ALL_PARAM && id) { currentEnvDetailInfo.value = await getDetailEnv(id); } @@ -44,16 +52,15 @@ const useProjectEnvStore = defineStore( } return { - getCurrentId, currentId, + getHttpNoWarning, httpNoWarning, + allParamDetailInfo, + groupLength, setCurrentId, setHttpNoWarning, setEnvDetailInfo, - getHttpNoWarning, - getDatabaseList, - envGroupList, - getGroupLength, + setAllParamDetailInfo, initEnvDetail, }; }, diff --git a/frontend/src/views/api-test/components/paramTable.vue b/frontend/src/views/api-test/components/paramTable.vue index 42ad079706..6196ff4e8a 100644 --- a/frontend/src/views/api-test/components/paramTable.vue +++ b/frontend/src/views/api-test/components/paramTable.vue @@ -28,18 +28,18 @@ -