Browse Source

修改文件大小限制

zengyicheng 2 years ago
parent
commit
fbc3c8170b
2 changed files with 74 additions and 4 deletions
  1. 37 0
      src/components/study.vue
  2. 37 4
      src/components/studyStudent.vue

+ 37 - 0
src/components/study.vue

@@ -2592,6 +2592,43 @@ export default {
 
       var bucket = new window.AWS.S3({ params: { Bucket: "ccrb" } }); //选择桶
       var _this = this;
+      var b = [
+        "DOC",
+        "DOCX",
+        "DOCM",
+        "DOTM",
+        "DOTX",
+        "PPTX",
+        "PPSX",
+        "PPT",
+        "PPS",
+        "PPTM",
+        "POTM",
+        "PPAM",
+        "POTX",
+        "PPSM",
+      ];
+      if (
+        b.indexOf(
+          file.name.split(".")[file.name.split(".").length - 1].toLocaleUpperCase()
+        ) != -1
+      ) {
+        if (file.size / 1024 / 1024 > 10) {
+          _this.$message({
+            message: "上传文件大于10兆,请重新选择文件!",
+            type: "success",
+          });
+          return;
+        }
+      } else {
+        if (file.size / 1024 / 1024 > 5) {
+          _this.$message({
+            message: "上传文件大于5兆,请重新选择文件!",
+            type: "success",
+          });
+          return;
+        }
+      }
       _this.progress = 0;
       _this.proVisible = true;
 

+ 37 - 4
src/components/studyStudent.vue

@@ -373,7 +373,9 @@
                             "
                             alt
                           />
-                          <div class="vedioTime">{{ vedioTime[vedioIndex] }}</div>
+                          <div class="vedioTime">
+                            {{ vedioTime[vedioIndex] }}
+                          </div>
                           <!-- <div class="vedioName">{{ media.name }}</div> -->
                         </div>
                         <div class="vedioName">{{ media.name }}</div>
@@ -2750,7 +2752,7 @@ export default {
     },
     beforeUpload1(event, type, i) {
       // this.$message.success('进入上传')
-      
+
       var file = event.target.files[0];
       var credentials = {
         accessKeyId: "AKIATLPEDU37QV5CHLMH",
@@ -2761,6 +2763,37 @@ export default {
 
       var bucket = new window.AWS.S3({ params: { Bucket: "ccrb" } }); //选择桶
       var _this = this;
+      var b = [
+        "DOC",
+        "DOCX",
+        "DOCM",
+        "DOTM",
+        "DOTX",
+        "PPTX",
+        "PPSX",
+        "PPT",
+        "PPS",
+        "PPTM",
+        "POTM",
+        "PPAM",
+        "POTX",
+        "PPSM",
+      ];
+      if (
+        b.indexOf(
+          file.name.split(".")[file.name.split(".").length - 1].toLocaleUpperCase()
+        ) != -1
+      ) {
+        if (file.size / 1024 / 1024 > 10) {
+          this.$message.error("上传文件大于10兆,请重新选择文件!");
+          return;
+        }
+      } else {
+        if (file.size / 1024 / 1024 > 5) {
+          this.$message.error("添加成上传文件大于5兆,请重新选择文件!");
+          return;
+        }
+      }
       _this.progress = 0;
       _this.proVisible = true;
 
@@ -2778,7 +2811,7 @@ export default {
         }; //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
         var options = {
           // partSize: 2048 * 1024 * 1024,
-          partSize: 1024 * 1024* 1024,
+          partSize: 1024 * 1024 * 1024,
           queueSize: 2,
           leavePartsOnError: true,
         };
@@ -3965,7 +3998,7 @@ export default {
       document.getElementsByClassName("vedioList")[0].style.height = a + "px";
       document.getElementsByClassName("navBox")[0].style.height = a - 40 + "px";
     });
-    let _this = this
+    let _this = this;
     setTimeout(() => {
       _this.vedioTime = [];
       for (var i = 0; i < _this.vedio[_this.taskCount].length; i++) {