Browse Source

新增视频图片类型强制检测

wyling 3 years ago
parent
commit
109a5a7e60
1 changed files with 8 additions and 0 deletions
  1. 8 0
      src/views/teachingVideo/info/index.vue

+ 8 - 0
src/views/teachingVideo/info/index.vue

@@ -242,6 +242,10 @@ export default {
     //上传视频
     fileUpload(e) {
       this.mediaFile = e.target.files[0]
+      if (!this.mediaFile.type.includes('video')) {
+        this.msgError('请选择视频文件')
+        return false
+      }
       this.videoPercentage = 0
       const uploader = this.tcVod.upload({
         mediaFile: this.mediaFile // 媒体文件(视频或音频或图片),类型为 File
@@ -256,6 +260,10 @@ export default {
     //上传封面
     async coverUpload(e) {
       this.coverFile = e.target.files[0]
+      if (!this.coverFile.type.includes('image')) {
+        this.msgError('请选择视频文件')
+        return false
+      }
       this.imagePercentage = 0
       let formData = new FormData()
       formData.append('coverFile', this.coverFile)