panhui 4 лет назад
Родитель
Сommit
ba6f99bc24

+ 4 - 1
src/main/nine-space/src/mixins/common.js

@@ -51,9 +51,12 @@ export default {
                     });
             }
         },
-        updateFile(e) {
+        updateFile(e, size = 2000) {
             const formData = new FormData();
             formData.append('file', e.file, e.file.name);
+            formData.append('compress', true);
+            formData.append('width', size);
+            formData.append('height', size);
             return http.axios.post('/upload/file', formData).then(res => {
                 return Promise.resolve(res.data);
             });

+ 2 - 2
src/main/nine-space/src/views/account/Setting.vue

@@ -81,7 +81,7 @@ export default {
                 message: '加载中...',
                 forbidClick: true
             });
-            this.updateFile(e).then(img => {
+            this.updateFile(e, 500).then(img => {
                 this.updateUser({ avatar: img }).then(res => {
                     this.$toast.clear();
                 });
@@ -92,7 +92,7 @@ export default {
                 message: '加载中...',
                 forbidClick: true
             });
-            this.updateFile(e).then(img => {
+            this.updateFile(e, 1000).then(img => {
                 this.updateUser({ bg: img }).then(res => {
                     this.$toast.clear();
                 });