diff --git a/flossom-ui/src/views/system/mode/index.vue b/flossom-ui/src/views/system/mode/index.vue index 0ff2604..b335fa0 100644 --- a/flossom-ui/src/views/system/mode/index.vue +++ b/flossom-ui/src/views/system/mode/index.vue @@ -85,6 +85,8 @@ :on-success="handleOpenSourceFileSuccess" :headers="upload.headers" :file-list="fileOpenSourceList" + :before-upload="limitFileType" + accept=".jpeg,.jpg,.png,.svg,.mp4,.avi,.mov,.rmvb,.rm,.flv,.3gp,.GIF,.gif" > 点击上传
只能上传视频/图片文件,且不超过50M
@@ -246,7 +248,29 @@ 添加弹窗 - + + + @@ -752,6 +776,16 @@ export default { return true; }, + limitFileType(file) { + const imageType = ['image/jpeg', 'image/jpg', 'image/png', 'image/svg', ['image/jpeg', 'image/jpg', 'image/png', 'image/svg', 'video/mp4','video/avi','video/mov','video/rmvb','video/rm','video/flv','video/3gp']] + let isVideo = imageType.includes(file.type) + // 检验文件格式 + if (!isVideo) { + this.$message.error(`文件格式错误!`) + return false + } + return true; + }, limitImageFileType(file) { const imageType = ['image/jpeg', 'image/jpg', 'image/png', 'image/svg'] let isVideo = imageType.includes(file.type)