mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-09 23:17:21 +08:00
feat: 更新限制APP名称的正则
This commit is contained in:
parent
8e76c9603a
commit
4f4fa49961
4 changed files with 22 additions and 1 deletions
|
@ -132,6 +132,19 @@ const checkDatabaseName = (rule: any, value: any, callback: any) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const checkAppName = (rule: any, value: any, callback: any) => {
|
||||||
|
if (value === '' || typeof value === 'undefined' || value == null) {
|
||||||
|
callback(new Error(i18n.global.t('commons.rule.appName')));
|
||||||
|
} else {
|
||||||
|
const reg = /^(?![_-])[a-zA-Z0-9_-]{1,29}[a-zA-Z0-9]$/;
|
||||||
|
if (!reg.test(value) && value !== '') {
|
||||||
|
callback(new Error(i18n.global.t('commons.rule.appName')));
|
||||||
|
} else {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const checkDomain = (rule: any, value: any, callback: any) => {
|
const checkDomain = (rule: any, value: any, callback: any) => {
|
||||||
if (value === '' || typeof value === 'undefined' || value == null) {
|
if (value === '' || typeof value === 'undefined' || value == null) {
|
||||||
callback(new Error(i18n.global.t('commons.rule.domain')));
|
callback(new Error(i18n.global.t('commons.rule.domain')));
|
||||||
|
@ -242,6 +255,7 @@ interface CommonRule {
|
||||||
domain: FormItemRule;
|
domain: FormItemRule;
|
||||||
databaseName: FormItemRule;
|
databaseName: FormItemRule;
|
||||||
nginxDoc: FormItemRule;
|
nginxDoc: FormItemRule;
|
||||||
|
appName: FormItemRule;
|
||||||
|
|
||||||
paramCommon: FormItemRule;
|
paramCommon: FormItemRule;
|
||||||
paramComplexity: FormItemRule;
|
paramComplexity: FormItemRule;
|
||||||
|
@ -368,4 +382,9 @@ export const Rules: CommonRule = {
|
||||||
validator: checkDoc,
|
validator: checkDoc,
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
},
|
},
|
||||||
|
appName: {
|
||||||
|
required: true,
|
||||||
|
trigger: 'blur',
|
||||||
|
validator: checkAppName,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -143,6 +143,7 @@ export default {
|
||||||
paramComplexity: 'Support English, numbers, {0}, length 6-30',
|
paramComplexity: 'Support English, numbers, {0}, length 6-30',
|
||||||
paramUrlAndPort: 'The format is http(s)://(domain name/ip):(port)',
|
paramUrlAndPort: 'The format is http(s)://(domain name/ip):(port)',
|
||||||
nginxDoc: 'Only supports English case, numbers, and .',
|
nginxDoc: 'Only supports English case, numbers, and .',
|
||||||
|
appName: 'Support English, numbers, - and _, length 2-30, and cannot start and end with -_',
|
||||||
},
|
},
|
||||||
res: {
|
res: {
|
||||||
paramError: 'The request failed, please try again later!',
|
paramError: 'The request failed, please try again later!',
|
||||||
|
|
|
@ -148,6 +148,7 @@ export default {
|
||||||
paramComplexity: '支持英文、数字、{0},长度6-30',
|
paramComplexity: '支持英文、数字、{0},长度6-30',
|
||||||
paramUrlAndPort: '格式为 http(s)://(域名/ip):(端口)',
|
paramUrlAndPort: '格式为 http(s)://(域名/ip):(端口)',
|
||||||
nginxDoc: '仅支持英文大小写,数字,和.',
|
nginxDoc: '仅支持英文大小写,数字,和.',
|
||||||
|
appName: '支持英文、数字、-和_,长度2-30,并且不能以-_开头和结尾',
|
||||||
},
|
},
|
||||||
res: {
|
res: {
|
||||||
paramError: '请求失败,请稍后重试!',
|
paramError: '请求失败,请稍后重试!',
|
||||||
|
|
|
@ -62,7 +62,7 @@ const installData = ref<InstallRrops>({
|
||||||
let open = ref(false);
|
let open = ref(false);
|
||||||
let form = ref<{ [key: string]: any }>({});
|
let form = ref<{ [key: string]: any }>({});
|
||||||
let rules = ref<FormRules>({
|
let rules = ref<FormRules>({
|
||||||
NAME: [Rules.linuxName],
|
NAME: [Rules.appName],
|
||||||
});
|
});
|
||||||
let loading = ref(false);
|
let loading = ref(false);
|
||||||
const paramForm = ref<FormInstance>();
|
const paramForm = ref<FormInstance>();
|
||||||
|
|
Loading…
Add table
Reference in a new issue