fix: 修改镜像构建名称校验规则

pull/60/head
ssongliu 2022-12-02 16:38:36 +08:00 committed by ssongliu
parent 05ef2373ef
commit 6f425a6a0e
8 changed files with 37 additions and 12 deletions

View File

@ -41,6 +41,19 @@ const checkName = (rule: any, value: any, callback: any) => {
} }
}; };
const checkImageName = (rule: any, value: any, callback: any) => {
if (value === '' || typeof value === 'undefined' || value == null) {
callback(new Error(i18n.global.t('commons.rule.commonName')));
} else {
const reg = /^[a-zA-Z0-9\u4e00-\u9fa5]{1}[a-z:A-Z0-9_.\u4e00-\u9fa5-]{0,30}$/;
if (!reg.test(value) && value !== '') {
callback(new Error(i18n.global.t('commons.rule.imageName')));
} else {
callback();
}
}
};
const checkLinuxName = (rule: any, value: any, callback: any) => { const checkLinuxName = (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.linuxName'))); callback(new Error(i18n.global.t('commons.rule.linuxName')));
@ -59,6 +72,7 @@ interface CommonRule {
requiredSelect: FormItemRule; requiredSelect: FormItemRule;
requiredSelectBusiness: FormItemRule; requiredSelectBusiness: FormItemRule;
name: FormItemRule; name: FormItemRule;
imageName: FormItemRule;
linuxName: FormItemRule; linuxName: FormItemRule;
password: FormItemRule; password: FormItemRule;
email: FormItemRule; email: FormItemRule;
@ -86,6 +100,11 @@ export const Rules: CommonRule = {
message: i18n.global.t('commons.rule.requiredSelect'), message: i18n.global.t('commons.rule.requiredSelect'),
trigger: 'change', trigger: 'change',
}, },
imageName: {
required: true,
validator: checkImageName,
trigger: 'blur',
},
name: { name: {
required: true, required: true,
validator: checkName, validator: checkName,

View File

@ -99,6 +99,7 @@ export default {
requiredInput: 'Please enter the required fields', requiredInput: 'Please enter the required fields',
requiredSelect: 'Please select the required fields', requiredSelect: 'Please select the required fields',
commonName: 'Support English, Chinese, numbers, .-_, length 1-30', commonName: 'Support English, Chinese, numbers, .-_, length 1-30',
imageName: 'Support English, Chinese, numbers, :.-_, length 1-30',
complexityPassword: complexityPassword:
'Please enter a password with more than 8 characters and must contain letters, digits, and special symbols', 'Please enter a password with more than 8 characters and must contain letters, digits, and special symbols',
commonPassword: 'Please enter a password with more than 6 characters', commonPassword: 'Please enter a password with more than 6 characters',
@ -636,6 +637,7 @@ export default {
backup: 'Backup', backup: 'Backup',
noTypeForCreate: 'No backup type is currently created', noTypeForCreate: 'No backup type is currently created',
serverDisk: 'Server disks', serverDisk: 'Server disks',
currentPath: 'Current path',
OSS: 'Ali OSS', OSS: 'Ali OSS',
S3: 'Amazon S3', S3: 'Amazon S3',
backupAccount: 'Backup account', backupAccount: 'Backup account',

View File

@ -99,6 +99,7 @@ export default {
requiredInput: '', requiredInput: '',
requiredSelect: '', requiredSelect: '',
commonName: '.-_,1-30', commonName: '.-_,1-30',
imageName: ':.-_,1-30',
complexityPassword: ' 8 ', complexityPassword: ' 8 ',
commonPassword: ' 6 ', commonPassword: ' 6 ',
linuxName: '.-_,1-30', linuxName: '.-_,1-30',
@ -653,6 +654,7 @@ export default {
backup: '', backup: '',
noTypeForCreate: '', noTypeForCreate: '',
serverDisk: '', serverDisk: '',
currentPath: '',
OSS: ' OSS', OSS: ' OSS',
S3: ' S3 ', S3: ' S3 ',
backupAccount: '', backupAccount: '',

View File

@ -47,7 +47,7 @@
placeholder="Wait for build output..." placeholder="Wait for build output..."
:indent-with-tab="true" :indent-with-tab="true"
:tabSize="4" :tabSize="4"
style="max-height: 500px" style="max-height: 300px"
:lineWrapping="true" :lineWrapping="true"
:matchBrackets="true" :matchBrackets="true"
theme="cobalt" theme="cobalt"
@ -100,7 +100,7 @@ const varifyPath = (rule: any, value: any, callback: any) => {
callback(); callback();
}; };
const rules = reactive({ const rules = reactive({
name: [Rules.requiredInput, Rules.name], name: [Rules.requiredInput, Rules.imageName],
from: [Rules.requiredSelect], from: [Rules.requiredSelect],
dockerfile: [Rules.requiredInput, { validator: varifyPath, trigger: 'change', required: true }], dockerfile: [Rules.requiredInput, { validator: varifyPath, trigger: 'change', required: true }],
}); });
@ -110,6 +110,7 @@ const acceptParams = async () => {
form.dockerfile = ''; form.dockerfile = '';
form.tagStr = ''; form.tagStr = '';
form.name = ''; form.name = '';
logInfo.value = '';
}; };
const emit = defineEmits<{ (e: 'search'): void }>(); const emit = defineEmits<{ (e: 'search'): void }>();

View File

@ -14,7 +14,7 @@
<el-table-column type="selection" fix /> <el-table-column type="selection" fix />
<el-table-column :label="$t('commons.table.name')" min-width="100" prop="name" fix /> <el-table-column :label="$t('commons.table.name')" min-width="100" prop="name" fix />
<el-table-column :label="$t('terminal.command')" min-width="300" show-overflow-tooltip prop="command" /> <el-table-column :label="$t('terminal.command')" min-width="300" show-overflow-tooltip prop="command" />
<fu-table-operations type="icon" :buttons="buttons" :label="$t('commons.table.operate')" fix /> <fu-table-operations :buttons="buttons" :label="$t('commons.table.operate')" fix />
</ComplexTable> </ComplexTable>
</el-card> </el-card>
<el-dialog v-model="cmdVisiable" :title="$t('terminal.addHost')" width="30%"> <el-dialog v-model="cmdVisiable" :title="$t('terminal.addHost')" width="30%">

View File

@ -106,6 +106,12 @@ const SaveSetting = async (formEl: FormInstance | undefined, key: string, val: a
globalStore.setThemeConfig({ ...themeConfig.value, theme: val }); globalStore.setThemeConfig({ ...themeConfig.value, theme: val });
switchDark(); switchDark();
break; break;
case 'SessionTimeout':
if (Number(val) < 300) {
ElMessage.error(i18n.t('setting.sessionTimeoutError'));
search();
return;
}
case 'PanelName': case 'PanelName':
globalStore.setThemeConfig({ ...themeConfig.value, panelName: val }); globalStore.setThemeConfig({ ...themeConfig.value, panelName: val });
break; break;

View File

@ -17,14 +17,14 @@
<span style="font-size: 16px; font-weight: 500">&nbsp;{{ loadBackupName(item.type) }}</span> <span style="font-size: 16px; font-weight: 500">&nbsp;{{ loadBackupName(item.type) }}</span>
<div style="float: right"> <div style="float: right">
<el-button @click="onEdit(item)">{{ $t('commons.button.edit') }}</el-button> <el-button @click="onEdit(item)">{{ $t('commons.button.edit') }}</el-button>
<el-button @click="onBatchDelete(item)"> <el-button v-if="item.type !== 'LOCAL'" @click="onBatchDelete(item)">
{{ $t('commons.button.delete') }} {{ $t('commons.button.delete') }}
</el-button> </el-button>
</div> </div>
</div> </div>
</template> </template>
<el-form label-position="left" label-width="130px"> <el-form label-position="left" label-width="130px">
<el-form-item v-if="item.type === 'LOCAL'" label="Directory"> <el-form-item v-if="item.type === 'LOCAL'" :label="$t('setting.currentPath')">
{{ item.varsJson['dir'] }} {{ item.varsJson['dir'] }}
</el-form-item> </el-form-item>
<el-form-item v-if="item.type === 'S3'" label="Region"> <el-form-item v-if="item.type === 'S3'" label="Region">
@ -73,7 +73,7 @@
</el-form-item> </el-form-item>
<el-form-item <el-form-item
v-if="form.type === 'LOCAL'" v-if="form.type === 'LOCAL'"
label="Directory" :label="$t('setting.currentPath')"
prop="varsJson['dir']" prop="varsJson['dir']"
:rules="Rules.requiredInput" :rules="Rules.requiredInput"
> >

View File

@ -95,7 +95,7 @@
<el-form-item <el-form-item
:label="$t('setting.sessionTimeout')" :label="$t('setting.sessionTimeout')"
:rules="sessionTimeoutRules" :rules="Rules.number"
prop="settingInfo.sessionTimeout" prop="settingInfo.sessionTimeout"
> >
<el-input v-model.number="form.settingInfo.sessionTimeout"> <el-input v-model.number="form.settingInfo.sessionTimeout">
@ -199,11 +199,6 @@ const passForm = reactive({
retryPassword: '', retryPassword: '',
}); });
const sessionTimeoutRules = [
Rules.number,
{ min: 300, type: 'number', message: i18n.global.t('setting.sessionTimeoutError'), trigger: 'blur' },
];
interface Props { interface Props {
settingInfo: any; settingInfo: any;
} }