From b1a4d9df009ef75528c3eafed92fa82376e027ea Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Fri, 25 Nov 2022 15:55:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E4=B8=BB=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E5=92=8C=E4=BB=A3=E5=8F=B7=E7=9A=84=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/website/website/create/index.vue | 4 ++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/frontend/src/global/form-rules.ts b/frontend/src/global/form-rules.ts index c78dc2fda..12396f308 100644 --- a/frontend/src/global/form-rules.ts +++ b/frontend/src/global/form-rules.ts @@ -41,11 +41,25 @@ const checkName = (rule: any, value: any, callback: any) => { } }; +const checkLinuxName = (rule: any, value: any, callback: any) => { + if (value === '' || typeof value === 'undefined' || value == null) { + callback(new Error(i18n.global.t('commons.rule.linuxName'))); + } 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.linuxName'))); + } else { + callback(); + } + } +}; + interface CommonRule { requiredInput: FormItemRule; requiredSelect: FormItemRule; requiredSelectBusiness: FormItemRule; name: FormItemRule; + linuxName: FormItemRule; password: FormItemRule; email: FormItemRule; number: FormItemRule; @@ -77,6 +91,11 @@ export const Rules: CommonRule = { validator: checkName, trigger: 'blur', }, + linuxName: { + required: true, + validator: checkLinuxName, + trigger: 'blur', + }, password: { validator: complexityPassword, trigger: 'blur', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 96c239815..997c1604f 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -100,6 +100,7 @@ export default { commonName: '支持英文、中文、数字、.-_,长度1-30', complexityPassword: '请输入 8 位以上、必须含有字母、数字、特殊符号的密码', commonPassword: '请输入 6 位以上长度密码', + linuxName: '支持英文、数字、.-_,长度1-30', email: '请输入正确的邮箱', number: '请输入正确的数字', ip: '请输入正确的 IP 地址', diff --git a/frontend/src/views/website/website/create/index.vue b/frontend/src/views/website/website/create/index.vue index b287fb835..c09533407 100644 --- a/frontend/src/views/website/website/create/index.vue +++ b/frontend/src/views/website/website/create/index.vue @@ -141,8 +141,8 @@ const website = ref({ }, }); let rules = ref({ - primaryDomain: [Rules.requiredInput], - alias: [Rules.requiredInput], + primaryDomain: [Rules.linuxName], + alias: [Rules.linuxName], type: [Rules.requiredInput], webSiteGroupId: [Rules.requiredSelectBusiness], appInstallId: [Rules.requiredSelectBusiness],