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