bri-components 1.6.3 → 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/controls/base/BriUpload/BriUpload.vue +8 -8
- package/src/components/controls/base/BriUpload/BriUploadImage.vue +68 -71
- package/src/components/controls/base/BriUpload/uploadList.vue +3 -4
- package/src/components/controls/base/BriUpload/uploadMixin.js +74 -85
- package/src/components/controls/base/DshEditor.vue +1 -1
package/package.json
CHANGED
|
@@ -205,7 +205,7 @@
|
|
|
205
205
|
handleEditName (fileItem) {
|
|
206
206
|
this.$https({
|
|
207
207
|
url: {
|
|
208
|
-
...this.
|
|
208
|
+
...this.finalUrlModule,
|
|
209
209
|
name: "updateFileName"
|
|
210
210
|
},
|
|
211
211
|
params: fileItem
|
|
@@ -231,18 +231,18 @@
|
|
|
231
231
|
}
|
|
232
232
|
},
|
|
233
233
|
|
|
234
|
-
handleChange (
|
|
235
|
-
if (
|
|
236
|
-
this.dealUpload(
|
|
234
|
+
handleChange (event) {
|
|
235
|
+
if (event.target.files) {
|
|
236
|
+
this.dealUpload(event.target.files);
|
|
237
237
|
this.$refs.input.value = null;
|
|
238
238
|
}
|
|
239
239
|
},
|
|
240
|
-
handleDrop (
|
|
240
|
+
handleDrop (event) {
|
|
241
241
|
this.dragOver = false;
|
|
242
|
-
this.dealUpload(
|
|
242
|
+
this.dealUpload(event.dataTransfer.files);
|
|
243
243
|
},
|
|
244
|
-
handlePaste (
|
|
245
|
-
this.dealUpload(
|
|
244
|
+
handlePaste (event) {
|
|
245
|
+
this.dealUpload(event.clipboardData.files);
|
|
246
246
|
},
|
|
247
247
|
dealUpload (files) {
|
|
248
248
|
if (!this.disabled) {
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
class="BriUploadImage-set"
|
|
6
6
|
>
|
|
7
7
|
<div
|
|
8
|
-
v-if="curVal ||
|
|
8
|
+
v-if="curVal || selfPropsObj._default || percent"
|
|
9
9
|
:class="{
|
|
10
10
|
'BriUploadImage-set-img': true,
|
|
11
11
|
'BriUploadImage-set-avatar': isAvatar
|
|
12
12
|
}"
|
|
13
13
|
:style="{
|
|
14
|
-
backgroundImage: `url(${$imageResize(curVal ||
|
|
15
|
-
borderRadius:
|
|
14
|
+
backgroundImage: `url(${$imageResize(curVal || selfPropsObj._default, imageResizeConfig)})`,
|
|
15
|
+
borderRadius: useBorderRadius ? '50%' : ''
|
|
16
16
|
}"
|
|
17
17
|
>
|
|
18
18
|
<img
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
<Button type="default">点击上传</Button>
|
|
61
61
|
<input
|
|
62
62
|
id="fileupload"
|
|
63
|
-
class="
|
|
64
|
-
:accept="
|
|
65
|
-
:type="
|
|
66
|
-
@change="
|
|
63
|
+
class="wrap-input"
|
|
64
|
+
:accept="accept"
|
|
65
|
+
:type="uploadType"
|
|
66
|
+
@change="handleChange"
|
|
67
67
|
/>
|
|
68
68
|
</div>
|
|
69
69
|
</div>
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
@on-visible-change="visibleChange"
|
|
77
77
|
>
|
|
78
78
|
<dsh-cropper
|
|
79
|
-
ref="
|
|
79
|
+
ref="cropperDom"
|
|
80
80
|
class="BriUploadImage-cropper"
|
|
81
81
|
:src="imgSrc"
|
|
82
82
|
alt="Source Image"
|
|
@@ -114,30 +114,11 @@
|
|
|
114
114
|
default () {
|
|
115
115
|
return {};
|
|
116
116
|
}
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
isAvatar: {
|
|
120
|
-
type: Boolean,
|
|
121
|
-
default: false
|
|
122
|
-
},
|
|
123
|
-
// 上传的是阿里云还是本地
|
|
124
|
-
requestOssType: {
|
|
125
|
-
type: String,
|
|
126
|
-
default: "default",
|
|
127
|
-
validator (val) {
|
|
128
|
-
// "default"代表阿里云
|
|
129
|
-
return ["default", "local"].includes(val);
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
// 阿里云上传方式
|
|
133
|
-
ossType: {
|
|
134
|
-
type: String,
|
|
135
|
-
default: "binaryMultipartUpload"
|
|
136
117
|
}
|
|
137
118
|
},
|
|
138
119
|
data () {
|
|
139
120
|
return {
|
|
140
|
-
|
|
121
|
+
uploadType: "file",
|
|
141
122
|
|
|
142
123
|
// 头像
|
|
143
124
|
avatarModal: false,
|
|
@@ -163,6 +144,15 @@
|
|
|
163
144
|
computed: {
|
|
164
145
|
selfPropsObj () {
|
|
165
146
|
return {
|
|
147
|
+
_accept: [],
|
|
148
|
+
_isAvatar: false, // 是否是头像
|
|
149
|
+
_canAction: false, // 是否使用操作图标
|
|
150
|
+
_cropper: false, // 使用裁剪
|
|
151
|
+
_useBorderRadius: false, // 用圆角
|
|
152
|
+
|
|
153
|
+
_requestOssType: "", //
|
|
154
|
+
_aliOssType: "binaryMultipartUpload", // 阿里云上传方式
|
|
155
|
+
|
|
166
156
|
...this.propsObj
|
|
167
157
|
};
|
|
168
158
|
},
|
|
@@ -172,10 +162,21 @@
|
|
|
172
162
|
controlName () {
|
|
173
163
|
return this.selfPropsObj._name;
|
|
174
164
|
},
|
|
175
|
-
|
|
165
|
+
accept () {
|
|
166
|
+
return this.selfPropsObj._accept.map(type => `.${type}`).join() || "*";
|
|
167
|
+
},
|
|
168
|
+
isAvatar () {
|
|
169
|
+
return this.selfPropsObj._isAvatar;
|
|
170
|
+
},
|
|
176
171
|
canAction () {
|
|
177
172
|
return this.selfPropsObj._canAction;
|
|
178
173
|
},
|
|
174
|
+
isCropper () {
|
|
175
|
+
return this.selfPropsObj._cropper;
|
|
176
|
+
},
|
|
177
|
+
useBorderRadius () {
|
|
178
|
+
return this.selfPropsObj._useBorderRadius;
|
|
179
|
+
},
|
|
179
180
|
imageResizeConfig () {
|
|
180
181
|
return this.selfPropsObj._imageResizeConfig || {
|
|
181
182
|
m: "fixed",
|
|
@@ -183,11 +184,8 @@
|
|
|
183
184
|
h: 100
|
|
184
185
|
};
|
|
185
186
|
},
|
|
186
|
-
|
|
187
|
-
return this.selfPropsObj._requestOssType
|
|
188
|
-
},
|
|
189
|
-
acceptType () {
|
|
190
|
-
return this.selfPropsObj._acceptType || "*";
|
|
187
|
+
requestOssType () {
|
|
188
|
+
return this.selfPropsObj._requestOssType;
|
|
191
189
|
},
|
|
192
190
|
|
|
193
191
|
modalPropsObj () {
|
|
@@ -209,56 +207,65 @@
|
|
|
209
207
|
},
|
|
210
208
|
created () {},
|
|
211
209
|
methods: {
|
|
212
|
-
|
|
213
|
-
if (
|
|
214
|
-
const file =
|
|
210
|
+
handleChange (event) {
|
|
211
|
+
if (event.target.files.length) {
|
|
212
|
+
const file = event.target.files[0];
|
|
213
|
+
|
|
215
214
|
if (!file.type.includes("image/")) {
|
|
216
215
|
this.$Message.error("请选择一张图片");
|
|
217
216
|
}
|
|
218
217
|
else if (typeof FileReader !== "function") {
|
|
219
|
-
this.$Message.error("Sorry, FileReader API not supported");
|
|
218
|
+
this.$Message.error("Sorry, FileReader API not supported!");
|
|
220
219
|
}
|
|
221
220
|
else {
|
|
222
221
|
const reader = new FileReader();
|
|
223
|
-
|
|
222
|
+
// 使用裁剪
|
|
223
|
+
if (this.isCropper) {
|
|
224
224
|
reader.onload = (event) => {
|
|
225
|
-
this.
|
|
226
|
-
this.
|
|
225
|
+
this.uploadType = "text";
|
|
226
|
+
this.imgSrc = event.target.result;
|
|
227
|
+
this.$refs.cropperDom.replace(event.target.result); // event.target.result是base64格式
|
|
227
228
|
};
|
|
228
229
|
reader.readAsDataURL(file);
|
|
230
|
+
|
|
231
|
+
this.openAvatarModal();
|
|
229
232
|
}
|
|
230
|
-
// 使用裁剪
|
|
231
233
|
else {
|
|
232
234
|
reader.onload = (event) => {
|
|
233
|
-
this.
|
|
234
|
-
this.
|
|
235
|
-
this.$refs.cropper.replace(event.target.result); // event.target.result是base64格式
|
|
235
|
+
this.uploadType = "text";
|
|
236
|
+
this.dealPostImage(event.target.result); // event.target.result是base64格式
|
|
236
237
|
};
|
|
237
238
|
reader.readAsDataURL(file);
|
|
238
|
-
|
|
239
|
-
this.openAvatarModal();
|
|
240
239
|
}
|
|
241
240
|
}
|
|
242
241
|
}
|
|
243
242
|
},
|
|
244
243
|
// 提交裁剪后的图片
|
|
245
244
|
submitCropImage () {
|
|
246
|
-
this.
|
|
247
|
-
this.dealPostImage(
|
|
245
|
+
const cropImg = this.$refs.cropperDom.getCroppedCanvas().toDataURL(); // base64格式
|
|
246
|
+
this.dealPostImage(cropImg);
|
|
248
247
|
|
|
249
248
|
this.closeAvatarModal();
|
|
250
249
|
},
|
|
250
|
+
successCb (response, res) {
|
|
251
|
+
this.curVal = res.data.downloadUrl;
|
|
252
|
+
this.$emit("change", res);
|
|
253
|
+
},
|
|
254
|
+
handleError (err) {
|
|
255
|
+
alert(err);
|
|
256
|
+
},
|
|
251
257
|
|
|
252
258
|
// 获取裁剪的图片
|
|
253
259
|
cropImage () {
|
|
254
260
|
// get image data for post processing, e.g. upload or setting image src
|
|
255
|
-
this.cropImg = this.$refs.
|
|
261
|
+
this.cropImg = this.$refs.cropperDom.getCroppedCanvas().toDataURL(); // base64格式
|
|
256
262
|
},
|
|
257
263
|
// 处理图片的提交
|
|
258
264
|
dealPostImage (data) {
|
|
259
|
-
//
|
|
260
|
-
if (this.
|
|
261
|
-
//
|
|
265
|
+
// 本地上传
|
|
266
|
+
if (this.requestOssType === "local") {
|
|
267
|
+
const imgFile = this.dataURLtoFile(data, ""); // 将图片Base64转成文件
|
|
268
|
+
this.handlePost(imgFile); // object类型
|
|
262
269
|
// {
|
|
263
270
|
// lastModified: 1752065308269
|
|
264
271
|
// name: ".png"
|
|
@@ -266,16 +273,14 @@
|
|
|
266
273
|
// type: "image/png"
|
|
267
274
|
// webkitRelativePath: ""
|
|
268
275
|
// }
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
} else {
|
|
276
|
+
}
|
|
277
|
+
// 阿里上传用
|
|
278
|
+
else {
|
|
273
279
|
const dataBuffer = Buffer.from(data.split(",")[1], "base64");
|
|
274
|
-
this.handlePost(dataBuffer);
|
|
275
|
-
// console.dir(dataBuffer); // object类型
|
|
280
|
+
this.handlePost(dataBuffer); // object类型
|
|
276
281
|
}
|
|
277
282
|
},
|
|
278
|
-
// 将图片Base64
|
|
283
|
+
// 将图片Base64转成文件
|
|
279
284
|
dataURLtoFile (dataurl, filename) {
|
|
280
285
|
// 获取文件扩展名称
|
|
281
286
|
let arr = dataurl.split(",");
|
|
@@ -290,14 +295,6 @@
|
|
|
290
295
|
return new File([u8arr], `${filename}.${extension}`, { type: mime });
|
|
291
296
|
},
|
|
292
297
|
|
|
293
|
-
successCb (response, res) {
|
|
294
|
-
this.curVal = res.data.downloadUrl;
|
|
295
|
-
this.$emit("change", res);
|
|
296
|
-
},
|
|
297
|
-
handleError (err) {
|
|
298
|
-
alert(err);
|
|
299
|
-
},
|
|
300
|
-
|
|
301
298
|
// 点击文件预览
|
|
302
299
|
handlePreview (file) {
|
|
303
300
|
let viewerImage = this.$refs.viewerImage;
|
|
@@ -313,7 +310,7 @@
|
|
|
313
310
|
},
|
|
314
311
|
// 点击文件删除 - fileList服务器的数据列表
|
|
315
312
|
handleRemove (file) {
|
|
316
|
-
this.
|
|
313
|
+
this.uploadType = "file"; // 删除后可以重新上传
|
|
317
314
|
this.curVal = "";
|
|
318
315
|
this.change(this.value);
|
|
319
316
|
},
|
|
@@ -332,7 +329,7 @@
|
|
|
332
329
|
// 头像模态框状态变化,关闭后改变input框类型,保证上传能够连续上传同一张图片
|
|
333
330
|
visibleChange (bool) {
|
|
334
331
|
if (!bool) {
|
|
335
|
-
this.
|
|
332
|
+
this.uploadType = "file";
|
|
336
333
|
}
|
|
337
334
|
}
|
|
338
335
|
}
|
|
@@ -408,7 +405,7 @@
|
|
|
408
405
|
left: 0;
|
|
409
406
|
}
|
|
410
407
|
|
|
411
|
-
|
|
408
|
+
&-input {
|
|
412
409
|
position: absolute;
|
|
413
410
|
bottom: 0;
|
|
414
411
|
left: 0;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :class="{
|
|
3
3
|
uploadList: true,
|
|
4
|
-
[`uploadList-${showMode}`]: true
|
|
5
|
-
[`uploadList-${subType}`]: true
|
|
4
|
+
[`uploadList-${showMode}`]: true
|
|
6
5
|
}">
|
|
7
6
|
<!-- 普通文本模式 -->
|
|
8
7
|
<template v-if="showMode ==='old'">
|
|
@@ -19,7 +18,7 @@
|
|
|
19
18
|
v-for="(fileItem, fileIndex) in files"
|
|
20
19
|
:key="fileItem._key || fileItem._id"
|
|
21
20
|
:class="{
|
|
22
|
-
'item': subType
|
|
21
|
+
'item': subType !== 'file',
|
|
23
22
|
[`item-${subType}`]: true
|
|
24
23
|
}"
|
|
25
24
|
>
|
|
@@ -75,7 +74,7 @@
|
|
|
75
74
|
v-for="(fileItem, fileIndex) in files"
|
|
76
75
|
:key="fileItem._key || fileItem._id"
|
|
77
76
|
:class="{
|
|
78
|
-
'item': subType
|
|
77
|
+
'item': subType !== 'file',
|
|
79
78
|
[`item-${subType}`]: true
|
|
80
79
|
}"
|
|
81
80
|
>
|
|
@@ -4,24 +4,7 @@ const minio = require("minio");
|
|
|
4
4
|
const stream = require("stream");
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
|
-
props: {
|
|
8
|
-
groupKey: {
|
|
9
|
-
type: String
|
|
10
|
-
},
|
|
11
|
-
urlModule: {
|
|
12
|
-
type: Object,
|
|
13
|
-
default: function () {
|
|
14
|
-
return {
|
|
15
|
-
module: "file",
|
|
16
|
-
name: "ossToken"
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
ossType: {
|
|
21
|
-
type: String,
|
|
22
|
-
default: "multipartUpload"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
7
|
+
props: {},
|
|
25
8
|
data () {
|
|
26
9
|
return {
|
|
27
10
|
percent: 0,
|
|
@@ -30,18 +13,22 @@ export default {
|
|
|
30
13
|
},
|
|
31
14
|
created () { },
|
|
32
15
|
computed: {
|
|
33
|
-
|
|
34
|
-
return this.
|
|
16
|
+
finalUrlModule () {
|
|
17
|
+
return this.selfPropsObj.urlModule || {
|
|
18
|
+
module: "file",
|
|
19
|
+
name: "ossToken"
|
|
20
|
+
};
|
|
35
21
|
},
|
|
36
|
-
|
|
37
|
-
return this.
|
|
22
|
+
uploadGroupKey () {
|
|
23
|
+
return this.selfPropsObj.groupKey;
|
|
38
24
|
},
|
|
39
|
-
|
|
40
|
-
return this.
|
|
25
|
+
aliOssType () {
|
|
26
|
+
return this.selfPropsObj._aliOssType || "multipartUpload";
|
|
41
27
|
},
|
|
42
28
|
archiveKey () {
|
|
43
|
-
return this.
|
|
29
|
+
return this.selfPropsObj._archiveKey || [];
|
|
44
30
|
},
|
|
31
|
+
|
|
45
32
|
percentColor () {
|
|
46
33
|
return Number(this.percent) === 100 ? "#5cb85c" : "#6090ed";
|
|
47
34
|
}
|
|
@@ -49,16 +36,17 @@ export default {
|
|
|
49
36
|
methods: {
|
|
50
37
|
handlePost (file, callback) {
|
|
51
38
|
this.$https({
|
|
52
|
-
url: this.
|
|
39
|
+
url: this.finalUrlModule,
|
|
53
40
|
params: {},
|
|
54
41
|
callback: res => {
|
|
55
|
-
this.
|
|
42
|
+
this.uploadType = "file";
|
|
43
|
+
|
|
56
44
|
if (res.ossType === "ali-oss") {
|
|
57
45
|
// 上传到阿里云res
|
|
58
|
-
if (this.
|
|
46
|
+
if (this.aliOssType === "binaryMultipartUpload") {
|
|
59
47
|
this.binaryMultipartUpload(file, res, callback);
|
|
60
48
|
}
|
|
61
|
-
else if (this.
|
|
49
|
+
else if (this.aliOssType === "multipartUpload") {
|
|
62
50
|
this.multipartUpload(file, res, callback);
|
|
63
51
|
}
|
|
64
52
|
}
|
|
@@ -71,7 +59,6 @@ export default {
|
|
|
71
59
|
else {
|
|
72
60
|
console.log(`请开发这种类型‘${res.ossType}’的上传模式`);
|
|
73
61
|
}
|
|
74
|
-
|
|
75
62
|
}
|
|
76
63
|
});
|
|
77
64
|
},
|
|
@@ -84,7 +71,7 @@ export default {
|
|
|
84
71
|
headers: {
|
|
85
72
|
filetoken: res.filetoken,
|
|
86
73
|
filebody: JSON.stringify({
|
|
87
|
-
groupKey: this.
|
|
74
|
+
groupKey: this.uploadGroupKey,
|
|
88
75
|
archiveKey: this.archiveKey[this.archiveKey.length - 1]
|
|
89
76
|
})
|
|
90
77
|
},
|
|
@@ -186,7 +173,7 @@ export default {
|
|
|
186
173
|
path: remoteName,
|
|
187
174
|
bucket: res.ossConfig.bucket,
|
|
188
175
|
filetoken: res.filetoken,
|
|
189
|
-
groupKey: this.
|
|
176
|
+
groupKey: this.uploadGroupKey,
|
|
190
177
|
archiveKey: this.archiveKey[this.archiveKey.length - 1]
|
|
191
178
|
};
|
|
192
179
|
axios.post(res.ossHost + res.confirmPath, { ...callbackBody })
|
|
@@ -235,10 +222,9 @@ export default {
|
|
|
235
222
|
path: remoteName,
|
|
236
223
|
bucket: res.ossConfig.bucket,
|
|
237
224
|
filetoken: res.filetoken,
|
|
238
|
-
groupKey: this.
|
|
225
|
+
groupKey: this.uploadGroupKey,
|
|
239
226
|
archiveKey: this.archiveKey[this.archiveKey.length - 1]
|
|
240
227
|
};
|
|
241
|
-
|
|
242
228
|
let ossCallback = {
|
|
243
229
|
callbackUrl: res.ossHost + res.confirmPath,
|
|
244
230
|
callbackBodyType: "application/json",
|
|
@@ -258,31 +244,34 @@ export default {
|
|
|
258
244
|
refreshSTSTokenInterval: 3600 * 1000
|
|
259
245
|
};
|
|
260
246
|
|
|
261
|
-
new Oss(newOss)
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
247
|
+
new Oss(newOss)
|
|
248
|
+
.multipartUpload(remoteName, file, {
|
|
249
|
+
progress: (percentage) => {
|
|
250
|
+
this.inProgress(Number((percentage * 100).toFixed(1)));
|
|
251
|
+
this.handleProgress && this.handleProgress(percentage, file);
|
|
252
|
+
},
|
|
253
|
+
headers: {
|
|
254
|
+
"x-oss-callback": this.base64Encode(JSON.stringify(ossCallback)),
|
|
255
|
+
"Content-Disposition": type === "pdf" ? `inline;filename=${encodeURI(file.name)}` : `attachment;filename=${encodeURI(file.name)}`
|
|
256
|
+
}
|
|
257
|
+
})
|
|
258
|
+
.then(response => {
|
|
259
|
+
this.uploadSuccess = true;
|
|
260
|
+
this.percent = 100;
|
|
261
|
+
setTimeout(() => {
|
|
262
|
+
this.uploadSuccess = false;
|
|
263
|
+
this.percent = 0;
|
|
264
|
+
}, 500);
|
|
265
|
+
|
|
266
|
+
this.successCb && this.successCb(response, response.data, file);
|
|
267
|
+
callback && callback(response.data);
|
|
268
|
+
})
|
|
269
|
+
.catch((err, response) => {
|
|
274
270
|
this.uploadSuccess = false;
|
|
275
271
|
this.percent = 0;
|
|
276
|
-
}, 500);
|
|
277
|
-
|
|
278
|
-
this.successCb && this.successCb(response, response.data, file);
|
|
279
|
-
callback && callback(response.data);
|
|
280
|
-
}).catch((err, response) => {
|
|
281
|
-
this.uploadSuccess = false;
|
|
282
|
-
this.percent = 0;
|
|
283
272
|
|
|
284
|
-
|
|
285
|
-
|
|
273
|
+
this.handleError && this.handleError(err, response, file);
|
|
274
|
+
callback && callback(err);
|
|
286
275
|
});
|
|
287
276
|
},
|
|
288
277
|
// bri-upload-image 用的是这种方式
|
|
@@ -297,10 +286,9 @@ export default {
|
|
|
297
286
|
path: remoteName,
|
|
298
287
|
bucket: res.ossConfig.bucket,
|
|
299
288
|
filetoken: res.filetoken,
|
|
300
|
-
groupKey: this.
|
|
289
|
+
groupKey: this.uploadGroupKey,
|
|
301
290
|
archiveKey: this.archiveKey[this.archiveKey.length - 1]
|
|
302
291
|
};
|
|
303
|
-
|
|
304
292
|
let ossCallback = {
|
|
305
293
|
callbackUrl: res.ossHost + res.confirmPath,
|
|
306
294
|
callbackBodyType: "application/json",
|
|
@@ -320,41 +308,42 @@ export default {
|
|
|
320
308
|
refreshSTSTokenInterval: 3600 * 1000
|
|
321
309
|
};
|
|
322
310
|
|
|
323
|
-
new Oss(newOss)
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
311
|
+
new Oss(newOss)
|
|
312
|
+
.multipartUpload(remoteName, file, {
|
|
313
|
+
progress: (percentage) => {
|
|
314
|
+
this.inProgress(Number((percentage * 100).toFixed(1)));
|
|
315
|
+
this.handleProgress && this.handleProgress(percentage, file);
|
|
316
|
+
},
|
|
317
|
+
headers: {
|
|
318
|
+
"x-oss-callback": this.base64Encode(JSON.stringify(ossCallback)),
|
|
319
|
+
"Content-Disposition": type === "pdf" ? `inline;filename=${encodeURI(file.name)}` : `attachment;filename=${encodeURI(file.name)}`
|
|
320
|
+
}
|
|
321
|
+
})
|
|
322
|
+
.then(response => {
|
|
323
|
+
this.uploadSuccess = true;
|
|
324
|
+
this.percent = 100;
|
|
325
|
+
setTimeout(() => {
|
|
326
|
+
this.uploadSuccess = false;
|
|
327
|
+
this.percent = 0;
|
|
328
|
+
}, 500);
|
|
329
|
+
|
|
330
|
+
this.successCb && this.successCb(response, response.data, file);
|
|
331
|
+
callback && callback(response.data);
|
|
332
|
+
})
|
|
333
|
+
.catch((err, response) => {
|
|
336
334
|
this.uploadSuccess = false;
|
|
337
335
|
this.percent = 0;
|
|
338
|
-
}, 500);
|
|
339
336
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}).catch((err, response) => {
|
|
343
|
-
this.uploadSuccess = false;
|
|
344
|
-
this.percent = 0;
|
|
345
|
-
|
|
346
|
-
this.handleError && this.handleError(err, response, file);
|
|
347
|
-
callback && callback(err);
|
|
337
|
+
this.handleError && this.handleError(err, response, file);
|
|
338
|
+
callback && callback(err);
|
|
348
339
|
});
|
|
349
340
|
},
|
|
350
341
|
|
|
351
342
|
// 处理上传进度
|
|
352
343
|
inProgress (percent) {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
this.percent = percent;
|
|
357
|
-
}
|
|
344
|
+
this.percent = percent === 100 && !this.uploadSuccess
|
|
345
|
+
? 99.9
|
|
346
|
+
: percent;
|
|
358
347
|
|
|
359
348
|
if (this.percent >= 100) {
|
|
360
349
|
this.percent = 100;
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
let that = this;
|
|
107
107
|
let editor = new E(this.$refs.toolbar, this.$refs.editor);
|
|
108
108
|
editor.config.uploadImgShowBase64 = false; // base 64 存储图片
|
|
109
|
-
let url = this.$getRequests(this.
|
|
109
|
+
let url = this.$getRequests(this.finalUrlModule);
|
|
110
110
|
editor.config.uploadImgServer = `${location.origin}${config.apiUrl}${url}`;// 配置服务器端地址(自己更换为自己项目的服务器)
|
|
111
111
|
editor.config.uploadImgHeaders = this.propsObj._headers || { authtoken: sessionStorage.getItem("authtoken") }; // 自定义 header
|
|
112
112
|
editor.config.uploadFileName = "file_stream"; // 后端接受上传文件的参数名
|