feat(form): 增强表单校验与输入组件

- 引入 InputNumber 组件用于端口输入- 添加 IP 地址格式校验规则- 添加 Docker 端口范围校验(1-65535)
- 使用正则表达式验证 IP 和端口输入
- 替换 docker 端口输入框为数字输入组件
master
钟良源 3 months ago
parent 074934df46
commit 81c687dd5b

@ -1,5 +1,5 @@
import React, { useState, forwardRef, useImperativeHandle, useEffect } from 'react';
import { Form, Grid, Input, Message, Select } from '@arco-design/web-react';
import { Form, Grid, Input, Message, Select, InputNumber } from '@arco-design/web-react';
import { submitEnvConfig } from '@/api/componentDeployEnv';
const FormItem = Form.Item;
@ -85,6 +85,10 @@ const FormEditor = forwardRef<FormEditorInstance, FormEditorProps>(({
if (!value) {
return cb('请输入环境IP');
}
const ipRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
if (!ipRegex.test(value)) {
return cb('请输入正确的IP地址范围在0.0.0.0-255.255.255.255之间');
}
return cb();
}
@ -101,11 +105,16 @@ const FormEditor = forwardRef<FormEditorInstance, FormEditorProps>(({
return cb('请输入docker端口');
}
const portRegex = /^(?:[1-9]\d{0,3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/;
if (!portRegex.test(value)) {
return cb('docker端口只能是1-65535之间');
}
return cb();
}
}
]}>
<Input style={{ width: '90%' }} allowClear placeholder="请输入docker端口" />
<InputNumber style={{ width: '90%' }} placeholder="请输入docker端口" />
</FormItem>
</Grid.Col>
</Grid.Row>

Loading…
Cancel
Save