From 59d85541b549ff636111c3620bcc519fc24766b6 Mon Sep 17 00:00:00 2001 From: John Bro <42930107+john1298308460@users.noreply.github.com> Date: Wed, 3 Jul 2024 18:05:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=B9=E5=99=A8=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=9C=B0=E5=9D=80=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=9C=89=E6=95=88=E6=80=A7=E6=A0=A1=20(#5664)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #4542 --- frontend/src/lang/modules/en.ts | 1 + frontend/src/lang/modules/tw.ts | 1 + frontend/src/lang/modules/zh.ts | 1 + .../src/views/container/repo/operator/index.vue | 13 ++++++++++++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 1e74fd4735f8..96adfc7ae0c8 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -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', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 46cc0cc9d749..5c8f21f6603f 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -694,6 +694,7 @@ const message = { imageNameHelper: '鏡像名稱及 Tag,例:nginx:latest', cleanBuildCache: '清理建置快取', delBuildCacheHelper: '清理建置快取將刪除所有建置所產生的快取,此操作無法回復。是否繼續?', + urlWarning: '路徑前綴不需要添加 http:// 或 https://,請修改', network: '網絡', createNetwork: '創建網絡', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index ce3bc1eac660..f8b4dcdabe8c 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -695,6 +695,7 @@ const message = { imageNameHelper: '镜像名称及 Tag,例:nginx:latest', cleanBuildCache: '清理构建缓存', delBuildCacheHelper: '清理构建缓存 将删除所有构建产生的缓存,该操作无法回滚,是否继续?', + urlWarning: '路径前缀不需要添加 http:// 或 https://, 请修改', network: '网络', createNetwork: '创建网络', diff --git a/frontend/src/views/container/repo/operator/index.vue b/frontend/src/views/container/repo/operator/index.vue index 1de63e252b40..611e5aa221d1 100644 --- a/frontend/src/views/container/repo/operator/index.vue +++ b/frontend/src/views/container/repo/operator/index.vue @@ -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; const formRef = ref(); +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) => {