feat: 容器仓库配置地址,增加有效性校 (#5664)

Refs #4542
pull/5666/head
John Bro 2024-07-03 18:05:29 +08:00 committed by GitHub
parent 0872374fe4
commit 8301382770
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 1 deletions

View File

@ -717,6 +717,7 @@ const message = {
cleanBuildCache: 'Clean Build Cache',
delBuildCacheHelper:
'Cleaning the build cache will delete all cached artifacts generated during builds. This action cannot be undone. Continue?',
urlWarning: 'The URL prefix does not need to include http:// or https://. Please modify.',
network: 'Network',
createNetwork: 'Create',

View File

@ -694,6 +694,7 @@ const message = {
imageNameHelper: ' Tagnginx:latest',
cleanBuildCache: '',
delBuildCacheHelper: '',
urlWarning: ' http:// 或 https://,請修改',
network: '',
createNetwork: '',

View File

@ -695,6 +695,7 @@ const message = {
imageNameHelper: ' Tagnginx:latest',
cleanBuildCache: '',
delBuildCacheHelper: ' ',
urlWarning: ' http:// 或 https://, 请修改',
network: '',
createNetwork: '',

View File

@ -117,7 +117,7 @@ const handleClose = () => {
};
const rules = reactive({
name: [Rules.requiredInput, Rules.name],
downloadUrl: [Rules.illegal],
downloadUrl: [{ validator: validateDownloadUrl, trigger: 'blur' }, Rules.illegal],
protocol: [Rules.requiredSelect],
username: [Rules.illegal],
password: [Rules.illegal],
@ -127,6 +127,17 @@ const rules = reactive({
type FormInstance = InstanceType<typeof ElForm>;
const formRef = ref<FormInstance>();
function validateDownloadUrl(rule: any, value: any, callback: any) {
if (value === '') {
callback();
}
const pattern = /^https?/i;
if (pattern.test(value)) {
return callback(new Error(i18n.global.t('container.urlWarning')));
}
callback();
}
const onSubmit = async (formEl: FormInstance | undefined) => {
if (!formEl) return;
formEl.validate(async (valid) => {