|
@@ -13,7 +13,7 @@ import {FsExtendsEditor, FsExtendsUploader } from '@fast-crud/fast-extends';
|
|
import '@fast-crud/fast-extends/dist/style.css';
|
|
import '@fast-crud/fast-extends/dist/style.css';
|
|
import {successNotification} from '/@/utils/message';
|
|
import {successNotification} from '/@/utils/message';
|
|
import XEUtils from "xe-utils";
|
|
import XEUtils from "xe-utils";
|
|
-
|
|
|
|
|
|
+import Cookies from 'js-cookie';
|
|
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
@@ -118,19 +118,21 @@ export default {
|
|
defaultType: "form",
|
|
defaultType: "form",
|
|
form: {
|
|
form: {
|
|
action: `/api/system/file/`,
|
|
action: `/api/system/file/`,
|
|
- // action: `/api/system/device/upload-image/`,
|
|
|
|
name: "file",
|
|
name: "file",
|
|
withCredentials: false,
|
|
withCredentials: false,
|
|
uploadRequest: async ({ action, file, onProgress }: { action: string; file: any; onProgress: Function }) => {
|
|
uploadRequest: async ({ action, file, onProgress }: { action: string; file: any; onProgress: Function }) => {
|
|
// @ts-ignore
|
|
// @ts-ignore
|
|
const data = new FormData();
|
|
const data = new FormData();
|
|
data.append("file", file);
|
|
data.append("file", file);
|
|
|
|
+ const token = Cookies.get('token');
|
|
|
|
+ // console.log("tokens::::::::",token);
|
|
return await request({
|
|
return await request({
|
|
url: action,
|
|
url: action,
|
|
method: "post",
|
|
method: "post",
|
|
timeout: 60000,
|
|
timeout: 60000,
|
|
headers: {
|
|
headers: {
|
|
- "Content-Type": "multipart/form-data"
|
|
|
|
|
|
+ "Content-Type": "multipart/form-data",
|
|
|
|
+ Authorization: `Bearer ${token}`
|
|
},
|
|
},
|
|
data,
|
|
data,
|
|
onUploadProgress: (p: any) => {
|
|
onUploadProgress: (p: any) => {
|
|
@@ -139,12 +141,11 @@ export default {
|
|
});
|
|
});
|
|
},
|
|
},
|
|
successHandle(ret: any) {
|
|
successHandle(ret: any) {
|
|
- // 上传完成后的结果处理, 此处应返回格式为{url:xxx,key:xxx}
|
|
|
|
return {
|
|
return {
|
|
|
|
+ ...ret.data,
|
|
url: getBaseURL(ret.data.url),
|
|
url: getBaseURL(ret.data.url),
|
|
- // url: getBaseURL(ret.data.image_url),
|
|
|
|
key: ret.data.id,
|
|
key: ret.data.id,
|
|
- ...ret.data
|
|
|
|
|
|
+
|
|
};
|
|
};
|
|
}
|
|
}
|
|
},
|
|
},
|