|
|
@@ -48,6 +48,12 @@ type ServiceVersionCache = ServiceVersionData & { |
|
|
lastPage: CreateServiceVersionFrom; |
|
|
lastPage: CreateServiceVersionFrom; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 参数表单数据 |
|
|
|
|
|
export type FormEnvVariable = { |
|
|
|
|
|
key: string; // 参数名 |
|
|
|
|
|
value: string; // 参数值 |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
function CreateServiceVersion() { |
|
|
function CreateServiceVersion() { |
|
|
const navigate = useNavigate(); |
|
|
const navigate = useNavigate(); |
|
|
const [form] = Form.useForm(); |
|
|
const [form] = Form.useForm(); |
|
|
@@ -430,11 +436,32 @@ function CreateServiceVersion() { |
|
|
name={[name, 'key']} |
|
|
name={[name, 'key']} |
|
|
style={{ flex: 1 }} |
|
|
style={{ flex: 1 }} |
|
|
rules={[ |
|
|
rules={[ |
|
|
{ required: true, message: '请输入变量名' }, |
|
|
|
|
|
{ |
|
|
{ |
|
|
pattern: /^[a-zA-Z_][a-zA-Z0-9_-]*$/, |
|
|
|
|
|
message: |
|
|
|
|
|
'变量名只支持字母、数字、下划线、中横线且开头必须是字母或下划线', |
|
|
|
|
|
|
|
|
validator: (_, value) => { |
|
|
|
|
|
if (!value) { |
|
|
|
|
|
return Promise.reject(new Error('请输入变量名')); |
|
|
|
|
|
} |
|
|
|
|
|
if (!/^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(value)) { |
|
|
|
|
|
return Promise.reject( |
|
|
|
|
|
new Error( |
|
|
|
|
|
'变量名只支持字母、数字、下划线、中横线并且必须以字母或下划线开头', |
|
|
|
|
|
), |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
// 判断不能重名 |
|
|
|
|
|
const list = form |
|
|
|
|
|
.getFieldValue('env_variables') |
|
|
|
|
|
.filter( |
|
|
|
|
|
(item: FormEnvVariable | undefined) => |
|
|
|
|
|
item !== undefined && item !== null, |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const names = list.map((item: FormEnvVariable) => item.key); |
|
|
|
|
|
if (new Set(names).size !== names.length) { |
|
|
|
|
|
return Promise.reject(new Error('名称不能重复')); |
|
|
|
|
|
} |
|
|
|
|
|
return Promise.resolve(); |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
]} |
|
|
]} |
|
|
> |
|
|
> |
|
|
|