refactor(项目管理): 优化mock环境

This commit is contained in:
wxg0103 2024-03-20 11:15:13 +08:00 committed by Craftsman
parent cefae8bd31
commit 411982971a
3 changed files with 18 additions and 6 deletions

View File

@ -92,6 +92,8 @@ public class EnvironmentService extends MoveNodeService {
private static final String PASSWORD = "password";
private static final String PATH = "/project/environment/import";
private static final String MOCK_EVN_SOCKET = "/mock-server/";
private static final String HTTP = "http://";
private static final String HTTPS = "https://";
public List<OptionDTO> getDriverOptions(String organizationId) {
return jdbcDriverPluginService.getJdbcDriverOption(organizationId);
@ -205,7 +207,11 @@ public class EnvironmentService extends MoveNodeService {
String baseUrl = baseSystemConfigDTO.getUrl();
if (StringUtils.isNotEmpty(baseUrl)) {
Project project = projectMapper.selectByPrimaryKey(environment.getProjectId());
environmentInfoDTO.getConfig().getHttpConfig().getFirst().setHostname(StringUtils.join(baseUrl, MOCK_EVN_SOCKET, project.getNum()));
String domain = baseUrl.replace(HTTP, StringUtils.EMPTY).replace(HTTPS, StringUtils.EMPTY);
String protocol = baseUrl.substring(0, baseUrl.indexOf(domain) -3 );
environmentInfoDTO.getConfig().getHttpConfig().getFirst().setId(IDGenerator.nextStr());
environmentInfoDTO.getConfig().getHttpConfig().getFirst().setProtocol(protocol);
environmentInfoDTO.getConfig().getHttpConfig().getFirst().setHostname(StringUtils.join(domain, MOCK_EVN_SOCKET, project.getNum()));
environmentInfoDTO.getConfig().getHttpConfig().getFirst().setUrl(StringUtils.join(baseUrl, MOCK_EVN_SOCKET, project.getNum()));
}
}

View File

@ -46,7 +46,9 @@
</template>
<template #operation="{ record }">
<div class="flex flex-row flex-nowrap items-center">
<MsButton class="!mr-0" :disabled="isDisabled" @click="handleCopy(record)">{{ t('common.copy') }}</MsButton>
<MsButton class="!mr-0" :disabled="isDisabled || store.currentEnvDetailInfo.mock" @click="handleCopy(record)">{{
t('common.copy')
}}</MsButton>
<a-divider class="h-[16px]" direction="vertical" />
<MsButton class="!mr-0" :disabled="isDisabled" @click="handleEdit(record)">{{ t('common.edit') }}</MsButton>
<a-divider class="h-[16px]" direction="vertical" />
@ -145,9 +147,7 @@
heightUsed: 644,
debug: true,
});
const isDisabled = computed(
() => !hasAnyPermission(['PROJECT_ENVIRONMENT:READ+UPDATE']) || store.currentEnvDetailInfo.mock
);
const isDisabled = computed(() => !hasAnyPermission(['PROJECT_ENVIRONMENT:READ+UPDATE']));
const moreActionList: ActionsItem[] = [
{

View File

@ -15,6 +15,7 @@
class="mb-[16px]"
asterisk-position="end"
field="hostname"
:disabled="store.currentEnvDetailInfo.mock"
:label="t('project.environmental.http.hostName')"
:rules="[{ required: true, message: t('project.environmental.http.hostNameRequired') }]"
>
@ -31,7 +32,12 @@
</a-input> -->
<a-input-group class="w-full">
<a-select v-model="form.protocol" :style="{ width: '160px' }" default-value="http">
<a-select
v-model="form.protocol"
:style="{ width: '160px' }"
default-value="http"
:disabled="store.currentEnvDetailInfo.mock"
>
<a-option value="http">http://</a-option>
<a-option value="https">https://</a-option>
</a-select>