Browse Source

图片压缩

zengyicheng 2 years ago
parent
commit
9d300e7288
2 changed files with 13 additions and 16278 deletions
  1. 1 16277
      package-lock.json
  2. 12 1
      src/components/study.vue

File diff suppressed because it is too large
+ 1 - 16277
package-lock.json


+ 12 - 1
src/components/study.vue

@@ -1956,6 +1956,7 @@ import Time from "./tools/time.vue";
 import Mind from "./tools/jsmind.vue";
 import Sunburst from "./tools/sunburst";
 import SeeBoard from "./tools/seeBoard";
+import * as imageConversion from 'image-conversion'
 export default {
   components: { EditorBar, Time, pdf, AskStatic, Mind, Sunburst, SeeBoard, AnswerData2 },
   data() {
@@ -2809,7 +2810,7 @@ export default {
           console.error(err);
         });
     },
-    beforeUpload1(event, type, i) {
+    async beforeUpload1(event, type, i) {
       var file = event.target.files[0];
       var credentials = {
         accessKeyId: "AKIATLPEDU37QV5CHLMH",
@@ -2837,6 +2838,7 @@ export default {
         "PPSM",
       ];
       var excelA = ['XLSX', 'XLXB', 'XLS', 'XLSM']
+      var photoA = ["BMP", "GIF", "PNG", "JPGE", "JPG", "TIF", "PCX", "TGA", "EXIF", "FPX", "SVG", "APNG"];
       if (
         b.indexOf(
           file.name
@@ -2862,6 +2864,15 @@ export default {
           return;
         }
       }
+      if (photoA.indexOf(
+        file.name
+          .split(".")
+        [file.name.split(".").length - 1].toLocaleUpperCase()
+      ) != -1) {
+        // const blob = await imageConversion.compress(file, 0.8)
+        const blob = await imageConversion.compressAccurately(file, 32)
+        file = new File([blob], file.name, {type: file.type})
+      }
       _this.progress = 0;
       _this.proVisible = true;
 

Some files were not shown because too many files changed in this diff