refactor(项目管理): 优化环境的http参数

This commit is contained in:
wxg0103 2024-03-12 16:13:18 +08:00 committed by Craftsman
parent ad2759e459
commit 37c5925241
3 changed files with 11 additions and 11 deletions

View File

@ -666,7 +666,7 @@
}, },
{ {
title: t('project.environmental.http.desc'), title: t('project.environmental.http.desc'),
dataIndex: 'desc', dataIndex: 'description',
}, },
]; ];

View File

@ -93,8 +93,8 @@
const columns: MsTableColumn = [ const columns: MsTableColumn = [
{ {
title: 'project.environmental.http.host', title: 'project.environmental.http.host',
dataIndex: 'hostname', dataIndex: 'url',
slotName: 'hostname', slotName: 'url',
showTooltip: true, showTooltip: true,
showDrag: true, showDrag: true,
showInTable: true, showInTable: true,

View File

@ -14,7 +14,7 @@
<a-form-item <a-form-item
class="mb-[16px]" class="mb-[16px]"
asterisk-position="end" asterisk-position="end"
field="url" field="hostname"
:label="t('project.environmental.http.hostName')" :label="t('project.environmental.http.hostName')"
:rules="[{ required: true, message: t('project.environmental.http.hostNameRequired') }]" :rules="[{ required: true, message: t('project.environmental.http.hostNameRequired') }]"
> >
@ -36,7 +36,7 @@
<a-option value="https">https://</a-option> <a-option value="https">https://</a-option>
</a-select> </a-select>
<a-input <a-input
v-model="form.url" v-model="form.hostname"
class="w-full" class="w-full"
:max-length="255" :max-length="255"
:placeholder=" :placeholder="
@ -245,7 +245,7 @@
const handleAddOrUpdate = () => { const handleAddOrUpdate = () => {
const index = store.currentEnvDetailInfo.config.httpConfig.findIndex((item) => item.id === form.value.id); const index = store.currentEnvDetailInfo.config.httpConfig.findIndex((item) => item.id === form.value.id);
let modules: { moduleId: string; containChildModule: boolean }[] = []; let modules: { moduleId: string; containChildModule: boolean }[] = [];
const { protocol, url, condition, path } = form.value; const { protocol, hostname, condition, path } = form.value;
if (form.value.type === 'MODULE') { if (form.value.type === 'MODULE') {
modules = form.value.moduleId.map((item) => { modules = form.value.moduleId.map((item) => {
return { return {
@ -259,7 +259,7 @@
if (index > -1 && !props.isCopy) { if (index > -1 && !props.isCopy) {
const httpItem = { const httpItem = {
...form.value, ...form.value,
hostname: `${protocol}://${url}`, url: `${protocol}://${hostname}`,
pathMatchRule: { pathMatchRule: {
path, path,
condition, condition,
@ -273,7 +273,7 @@
const insertItem = { const insertItem = {
...form.value, ...form.value,
id: getGenerateId(), id: getGenerateId(),
hostname: `${protocol}://${url}`, url: `${protocol}://${hostname}`,
order: store.currentEnvDetailInfo.config.httpConfig.length + 1, order: store.currentEnvDetailInfo.config.httpConfig.length + 1,
moduleMatchRule: { modules }, moduleMatchRule: { modules },
}; };
@ -282,7 +282,7 @@
} else { } else {
const httpItem = { const httpItem = {
...form.value, ...form.value,
hostname: `${protocol}://${url}`, url: `${protocol}://${hostname}`,
pathMatchRule: { pathMatchRule: {
path, path,
condition, condition,
@ -319,13 +319,13 @@
) as HttpForm; ) as HttpForm;
if (currentItem) { if (currentItem) {
const { path, condition } = currentItem.pathMatchRule; const { path, condition } = currentItem.pathMatchRule;
const urlPath = currentItem.hostname.match(/\/\/(.*)/); const urlPath = currentItem.url.match(/\/\/(.*)/);
form.value = { form.value = {
...currentItem, ...currentItem,
moduleId: currentItem.moduleMatchRule.modules.map((item) => item.moduleId) || [], moduleId: currentItem.moduleMatchRule.modules.map((item) => item.moduleId) || [],
path, path,
condition, condition,
url: urlPath && urlPath?.length > 1 ? `${urlPath[1]}` : '', hostname: urlPath && urlPath?.length > 1 ? `${urlPath[1]}` : '',
}; };
} }
} else { } else {