From 8625979cc38f4e9acd56e097afcad25f402ea60e Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Mon, 15 Apr 2024 11:56:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=20supervisor=20?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E9=99=90=E5=88=B6=20(#4513)?= 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/en.ts | 1 + frontend/src/lang/modules/tw.ts | 1 + frontend/src/lang/modules/zh.ts | 1 + .../views/toolbox/supervisor/create/index.vue | 2 +- 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/frontend/src/global/form-rules.ts b/frontend/src/global/form-rules.ts index 0613a241c..d7e6ef212 100644 --- a/frontend/src/global/form-rules.ts +++ b/frontend/src/global/form-rules.ts @@ -219,6 +219,19 @@ const checkLinuxName = (rule: any, value: any, callback: any) => { } }; +const checkSupervisorName = (rule: any, value: any, callback: any) => { + if (value === '' || typeof value === 'undefined' || value == null) { + callback(new Error(i18n.global.t('commons.rule.supervisorName'))); + } else { + const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9_-]{1,128}$/; + if (!reg.test(value) && value !== '') { + callback(new Error(i18n.global.t('commons.rule.supervisorName'))); + } else { + callback(); + } + } +}; + const checkDatabaseName = (rule: any, value: any, callback: any) => { if (value === '' || typeof value === 'undefined' || value == null) { callback(new Error(i18n.global.t('commons.rule.databaseName'))); @@ -534,6 +547,7 @@ interface CommonRule { domainWithPort: FormItemRule; filePermission: FormItemRule; phpExtensions: FormItemRule; + supervisorName: FormItemRule; paramCommon: FormItemRule; paramComplexity: FormItemRule; @@ -724,6 +738,11 @@ export const Rules: CommonRule = { trigger: 'blur', validator: checkLeechExts, }, + supervisorName: { + required: true, + trigger: 'blur', + validator: checkSupervisorName, + }, paramSimple: { required: true, trigger: 'blur', diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index ed533b1c1..7e3eb5296 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -172,6 +172,7 @@ const message = { dbName: 'Supports non-special character starting, including English, Chinese, numbers, .-_, with a length of 1-64', imageName: 'Support English, numbers, :/.-_, length 1-150', volumeName: 'Support English, numbers, .-_, length 2-30', + supervisorName: 'Supports non-special characters starting with English, numbers, - and _, length 1-128', complexityPassword: 'Please enter a password combination with a length of 8-30 characters, including letters, numbers, and at least two special characters.', commonPassword: 'Please enter a password with more than 6 characters', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index f2df758fe..867eae81c 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -172,6 +172,7 @@ const message = { dbName: '支持非特殊字符開頭,英文、中文、數字、.-_,長度1-64', imageName: '支持英文、數字、:/.-_,長度1-150', volumeName: '支持英文、數字、.-和_,長度2-30', + supervisorName: '支援非特殊字元開頭,英文、數字、-和_,長度1-128', complexityPassword: '請輸入長度為 8-30 位,並包含字母、數字、至少兩種特殊字符的密碼組合', commonPassword: '請輸入 6 位以上長度密碼', linuxName: '長度1-128,名稱不能含有{0}等符號', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index c5323968a..2bd32afc4 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -172,6 +172,7 @@ const message = { dbName: '支持非特殊字符开头,英文、中文、数字、.-_,长度1-64', imageName: '支持英文、数字、:/.-_,长度1-150', volumeName: '支持英文、数字、.-和_,长度2-30', + supervisorName: '支持非特殊字符开头,英文、数字、-和_,长度1-128', complexityPassword: '请输入长度为 8-30 位且包含字母、数字、特殊字符至少两项的密码组合', commonPassword: '请输入 6 位以上长度密码', linuxName: '长度1-128,名称不能含有{0}等符号', diff --git a/frontend/src/views/toolbox/supervisor/create/index.vue b/frontend/src/views/toolbox/supervisor/create/index.vue index 6e8b8ff58..2acfcbfe6 100644 --- a/frontend/src/views/toolbox/supervisor/create/index.vue +++ b/frontend/src/views/toolbox/supervisor/create/index.vue @@ -54,7 +54,7 @@ const open = ref(false); const loading = ref(false); const processForm = ref(); const rules = ref({ - name: [Rules.requiredInput, Rules.linuxName], + name: [Rules.requiredInput, Rules.supervisorName], dir: [Rules.requiredInput], command: [Rules.requiredInput], user: [Rules.requiredInput],