fix(项目管理): 环境添加http补充认证方式

This commit is contained in:
xinxin.wu 2024-04-09 13:59:03 +08:00 committed by 刘瑞斌
parent e2f5192b16
commit b1eabb9490
4 changed files with 83 additions and 14 deletions

View File

@ -1,4 +1,5 @@
import { EnableKeyValueParam, ExecuteConditionProcessor } from '@/models/apiTest/common';
import { RequestAuthType } from '@/enums/apiEnum';
export interface EnvListItem {
mock?: boolean;
@ -134,6 +135,12 @@ export interface DragParam {
moveId: string;
}
export interface AuthForm {
userName: string;
password: string;
valid: boolean;
}
export interface HttpForm {
id?: string;
protocol: string;
@ -156,6 +163,11 @@ export interface HttpForm {
path: '';
condition: '';
};
authConfig: {
authType: keyof typeof RequestAuthType;
basicAuth: AuthForm;
digestAuth: AuthForm;
};
}
// 环境列表项
export interface EnvironmentItem {

View File

@ -222,7 +222,6 @@
try {
loading.value = true;
store.currentEnvDetailInfo.mock = true;
getParameters();
await updateOrAddEnv({ fileList: [], request: getParameters() });
setState(true);

View File

@ -170,7 +170,6 @@
/>
</a-input-group>
</a-form-item>
</a-form>
<httpHeader
v-model:params="form.headers"
:layout="activeLayout"
@ -179,6 +178,50 @@
:second-box-height="secondBoxHeight"
:type-title="t('project.environmental.requestHeader')"
/>
<a-form-item class="mt-4" asterisk-position="end" field="path" :label="t('project.environmental.http.authType')">
<a-radio-group v-model:model-value="form.authConfig.authType" class="mb-[16px]">
<a-radio :value="RequestAuthType.NONE">No Auth</a-radio>
<a-radio :value="RequestAuthType.BASIC">Basic Auth</a-radio>
<a-radio :value="RequestAuthType.DIGEST">Digest Auth</a-radio>
</a-radio-group>
<a-form v-if="form.authConfig.authType === 'BASIC'" ref="authFormRef" :model="form" layout="vertical">
<a-form-item :label="t('apiTestDebug.username')">
<a-input
v-model:model-value="form.authConfig.basicAuth.userName"
:placeholder="t('apiTestDebug.commonPlaceholder')"
class="w-[450px]"
:max-length="255"
/>
</a-form-item>
<a-form-item :label="t('apiTestDebug.password')">
<a-input-password
v-model:model-value="form.authConfig.basicAuth.password"
autocomplete="new-password"
:placeholder="t('apiTestDebug.commonPlaceholder')"
class="w-[450px]"
/>
</a-form-item>
</a-form>
<a-form v-else-if="form.authConfig.authType == 'DIGEST'" ref="authFormRef" :model="form" layout="vertical">
<a-form-item :label="t('apiTestDebug.username')">
<a-input
v-model:model-value="form.authConfig.digestAuth.userName"
:placeholder="t('apiTestDebug.commonPlaceholder')"
class="w-[450px]"
:max-length="255"
/>
</a-form-item>
<a-form-item :label="t('apiTestDebug.password')">
<a-input-password
v-model:model-value="form.authConfig.digestAuth.password"
autocomplete="new-password"
:placeholder="t('apiTestDebug.commonPlaceholder')"
class="w-[450px]"
/>
</a-form-item>
</a-form>
</a-form-item>
</a-form>
</MsDrawer>
</template>
@ -198,6 +241,7 @@
import type { ModuleTreeNode } from '@/models/common';
import { HttpForm } from '@/models/projectManagement/environmental';
import { RequestAuthType } from '@/enums/apiEnum';
const httpHeader = defineAsyncComponent(() => import('@/views/api-test/components/requestComposition/header.vue'));
@ -242,6 +286,19 @@
path: '',
condition: '',
},
authConfig: {
authType: 'NONE',
basicAuth: {
userName: '',
password: '',
valid: true,
},
digestAuth: {
userName: '',
password: '',
valid: true,
},
},
};
const form = ref<HttpForm>({ ...initForm });

View File

@ -3,7 +3,8 @@
<MsSplitBox>
<template #first>
<div class="p-[24px]">
<div
<!-- TODO:这个版本环境不展示默认项目环境 -->
<!-- <div
><a-radio-group
v-model:model-value="showType"
type="button"
@ -13,11 +14,11 @@
<a-radio v-permission="['PROJECT_ENVIRONMENT:READ']" value="PROJECT">{{
t('project.environmental.env')
}}</a-radio>
<!-- <a-radio v-permission="['PROJECT_ENVIRONMENT:READ']" value="PROJECT_GROUP">{{
<a-radio v-permission="['PROJECT_ENVIRONMENT:READ']" value="PROJECT_GROUP">{{
t('project.environmental.envGroup')
}}</a-radio> -->
}}</a-radio>
</a-radio-group></div
>
> -->
<template v-if="showType === 'PROJECT'">
<a-input-search
v-model="keyword"