|
@@ -1,6 +1,7 @@
|
|
|
import { request, getRequestParams } from '@/utils/request';
|
|
|
import { getToken } from '@/utils/auth';
|
|
|
-import { Loading } from 'element-ui';
|
|
|
+import { app } from '@/store/mutation-types.js';
|
|
|
+import store from '@/store';
|
|
|
|
|
|
/**
|
|
|
* 得到语言列表
|
|
@@ -43,13 +44,7 @@ export function fileUpload(SecurityLevel, file) {
|
|
|
};
|
|
|
const formData = new FormData();
|
|
|
formData.append(file.filename, file.file, file.file.name);
|
|
|
- // store.commit(`app/${app.SHOW_PROGRESS}`, true);
|
|
|
- let loadingInstance = Loading.service({
|
|
|
- lock: true,
|
|
|
- text: 'Loading',
|
|
|
- spinner: 'el-icon-loading',
|
|
|
- background: 'rgba(0, 0, 0, 0.7)'
|
|
|
- });
|
|
|
+ store.commit(`app/${app.SHOW_PROGRESS}`, true);
|
|
|
|
|
|
return request({
|
|
|
method: 'post',
|
|
@@ -59,17 +54,16 @@ export function fileUpload(SecurityLevel, file) {
|
|
|
headers: {
|
|
|
'Content-Type': 'multipart/form-data'
|
|
|
},
|
|
|
- data: formData
|
|
|
- // onUploadProgress: progressEvent => {
|
|
|
- // store.commit(
|
|
|
- // `app/${app.SET_PERCENTAGE}`,
|
|
|
- // ((progressEvent.loaded / progressEvent.total) * 100) | 0
|
|
|
- // );
|
|
|
- // }
|
|
|
+ data: formData,
|
|
|
+ onUploadProgress: progressEvent => {
|
|
|
+ store.commit(
|
|
|
+ `app/${app.SET_PERCENTAGE}`,
|
|
|
+ ((progressEvent.loaded / progressEvent.total) * 100) | 0
|
|
|
+ );
|
|
|
+ }
|
|
|
}).finally(() => {
|
|
|
- loadingInstance.close();
|
|
|
- // store.commit(`app/${app.SHOW_PROGRESS}`, false);
|
|
|
- // store.commit(`app/${app.SET_PERCENTAGE}`, 0);
|
|
|
+ store.commit(`app/${app.SHOW_PROGRESS}`, false);
|
|
|
+ store.commit(`app/${app.SET_PERCENTAGE}`, 0);
|
|
|
});
|
|
|
}
|
|
|
|