refactor: 优化固件更改中版本号验证

This commit is contained in:
聂黎 2023-11-13 14:36:19 +08:00
parent e253a0a873
commit c02207ba2e
1 changed files with 2 additions and 4 deletions

View File

@ -449,17 +449,16 @@ export default {
}, },
methods: { methods: {
chenking_otaVersion(rule, value, callback){ chenking_otaVersion(rule, value, callback){
const regex = /^\d+(\.\d+)*$/; const regex = /^(\d{1,3}\.){3}\d{1,3}$/;
if (!this.form.otaVersion) { if (!this.form.otaVersion) {
callback(new Error('版本不能为空')) callback(new Error('版本不能为空'))
} else if(!regex.test(this.form.otaVersion)) { } else if(!regex.test(this.form.otaVersion)) {
callback(new Error('版本格式不正确: x.x.x.x (如1.0.05.121)')) callback(new Error('版本格式不正确: x.x.x.x (如: 0~999.0~999.0~999.0~999)'))
} else { } else {
callback(); callback();
} }
}, },
beforeAvatarUpload(file) { beforeAvatarUpload(file) {
console.log('oat-upload-file--', file, file.type === 'application/octet-stream');
const isBin = file.type === 'application/octet-stream'; const isBin = file.type === 'application/octet-stream';
if (!isBin) { if (!isBin) {
this.$message.error('上传文件类型错误,只能上传.bin文件!'); this.$message.error('上传文件类型错误,只能上传.bin文件!');
@ -496,7 +495,6 @@ export default {
this.handleQuery(); this.handleQuery();
}, },
uploud(file) { uploud(file) {
console.log(file);
var formData = new FormData(); var formData = new FormData();
var that = this; var that = this;
formData.append("file", file.file); formData.append("file", file.file);