From 168ff2ded3c936c8d20afd7fc1c6a748e5582641 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Tue, 20 Dec 2022 23:18:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E5=90=8D=E7=A7=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/global/form-rules.ts | 19 +++++++++++++++++++ frontend/src/lang/modules/zh.ts | 1 + .../views/app-store/detail/params/index.vue | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/frontend/src/global/form-rules.ts b/frontend/src/global/form-rules.ts index 1480d02b8..b99514909 100644 --- a/frontend/src/global/form-rules.ts +++ b/frontend/src/global/form-rules.ts @@ -80,6 +80,19 @@ const checkDomain = (rule: any, value: any, callback: any) => { } }; +const checkDatabaseName = (rule: any, value: any, callback: any) => { + if (value === '' || typeof value === 'undefined' || value == null) { + callback(new Error(i18n.global.t('commons.rule.databaseName'))); + } else { + const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9_]{0,30}$/; + if (!reg.test(value) && value !== '') { + callback(new Error(i18n.global.t('commons.rule.databaseName'))); + } else { + callback(); + } + } +}; + interface CommonRule { requiredInput: FormItemRule; requiredSelect: FormItemRule; @@ -93,6 +106,7 @@ interface CommonRule { ip: FormItemRule; port: FormItemRule; domain: FormItemRule; + databaseName: FormItemRule; } export const Rules: CommonRule = { @@ -129,6 +143,11 @@ export const Rules: CommonRule = { validator: checkLinuxName, trigger: 'blur', }, + databaseName: { + required: true, + validator: checkDatabaseName, + trigger: 'blur', + }, password: { validator: complexityPassword, trigger: 'blur', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 90d1f6151..96d0ec81c 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -113,6 +113,7 @@ export default { port: '请输入正确的端口', selectHelper: '请选择正确的 {0} 文件', domain: '域名格式错误', + databaseName: '支持英文、数字、_,长度1-30', }, res: { paramError: '请求失败,请稍后重试!', diff --git a/frontend/src/views/app-store/detail/params/index.vue b/frontend/src/views/app-store/detail/params/index.vue index 516a63ab1..d9ab317aa 100644 --- a/frontend/src/views/app-store/detail/params/index.vue +++ b/frontend/src/views/app-store/detail/params/index.vue @@ -108,7 +108,7 @@ const handleParams = () => { } else { rules[p.envKey] = [Rules.requiredInput]; if (p.envKey === 'PANEL_DB_NAME') { - rules[p.envKey].push(Rules.linuxName); + rules[p.envKey].push(Rules.databaseName); } } }