Skip to content

Commit 8301382

Browse files
feat: 容器仓库配置地址,增加有效性校 (#5664)
Refs #4542
1 parent 0872374 commit 8301382

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

frontend/src/lang/modules/en.ts

+1
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ const message = {
717717
cleanBuildCache: 'Clean Build Cache',
718718
delBuildCacheHelper:
719719
'Cleaning the build cache will delete all cached artifacts generated during builds. This action cannot be undone. Continue?',
720+
urlWarning: 'The URL prefix does not need to include http:// or https://. Please modify.',
720721

721722
network: 'Network',
722723
createNetwork: 'Create',

frontend/src/lang/modules/tw.ts

+1
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ const message = {
694694
imageNameHelper: '鏡像名稱及 Tag,例:nginx:latest',
695695
cleanBuildCache: '清理建置快取',
696696
delBuildCacheHelper: '清理建置快取將刪除所有建置所產生的快取,此操作無法回復。是否繼續?',
697+
urlWarning: '路徑前綴不需要添加 http:// 或 https://,請修改',
697698

698699
network: '網絡',
699700
createNetwork: '創建網絡',

frontend/src/lang/modules/zh.ts

+1
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ const message = {
695695
imageNameHelper: '镜像名称及 Tag,例:nginx:latest',
696696
cleanBuildCache: '清理构建缓存',
697697
delBuildCacheHelper: '清理构建缓存 将删除所有构建产生的缓存,该操作无法回滚,是否继续?',
698+
urlWarning: '路径前缀不需要添加 http:// 或 https://, 请修改',
698699

699700
network: '网络',
700701
createNetwork: '创建网络',

frontend/src/views/container/repo/operator/index.vue

+12-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ const handleClose = () => {
117117
};
118118
const rules = reactive({
119119
name: [Rules.requiredInput, Rules.name],
120-
downloadUrl: [Rules.illegal],
120+
downloadUrl: [{ validator: validateDownloadUrl, trigger: 'blur' }, Rules.illegal],
121121
protocol: [Rules.requiredSelect],
122122
username: [Rules.illegal],
123123
password: [Rules.illegal],
@@ -127,6 +127,17 @@ const rules = reactive({
127127
type FormInstance = InstanceType<typeof ElForm>;
128128
const formRef = ref<FormInstance>();
129129
130+
function validateDownloadUrl(rule: any, value: any, callback: any) {
131+
if (value === '') {
132+
callback();
133+
}
134+
const pattern = /^https?/i;
135+
if (pattern.test(value)) {
136+
return callback(new Error(i18n.global.t('container.urlWarning')));
137+
}
138+
callback();
139+
}
140+
130141
const onSubmit = async (formEl: FormInstance | undefined) => {
131142
if (!formEl) return;
132143
formEl.validate(async (valid) => {

0 commit comments

Comments
 (0)