bri-components 1.6.4 → 1.6.6
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
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,14 @@
|
|
|
163
144
|
computed: {
|
|
164
145
|
selfPropsObj () {
|
|
165
146
|
return {
|
|
147
|
+
_accept: [],
|
|
148
|
+
_isAvatar: false, // 是否是头像
|
|
149
|
+
_canAction: false, // 是否使用操作图标
|
|
150
|
+
_cropper: false, // 使用裁剪
|
|
151
|
+
_useBorderRadius: false, // 用圆角
|
|
152
|
+
_imageResizeConfig: undefined,
|
|
153
|
+
_aliOssType: "binaryMultipartUpload", // 阿里云上传方式
|
|
154
|
+
|
|
166
155
|
...this.propsObj
|
|
167
156
|
};
|
|
168
157
|
},
|
|
@@ -172,10 +161,21 @@
|
|
|
172
161
|
controlName () {
|
|
173
162
|
return this.selfPropsObj._name;
|
|
174
163
|
},
|
|
175
|
-
|
|
164
|
+
accept () {
|
|
165
|
+
return this.selfPropsObj._accept.map(type => `.${type}`).join() || "*";
|
|
166
|
+
},
|
|
167
|
+
isAvatar () {
|
|
168
|
+
return this.selfPropsObj._isAvatar;
|
|
169
|
+
},
|
|
176
170
|
canAction () {
|
|
177
171
|
return this.selfPropsObj._canAction;
|
|
178
172
|
},
|
|
173
|
+
isCropper () {
|
|
174
|
+
return this.selfPropsObj._cropper;
|
|
175
|
+
},
|
|
176
|
+
useBorderRadius () {
|
|
177
|
+
return this.selfPropsObj._useBorderRadius;
|
|
178
|
+
},
|
|
179
179
|
imageResizeConfig () {
|
|
180
180
|
return this.selfPropsObj._imageResizeConfig || {
|
|
181
181
|
m: "fixed",
|
|
@@ -183,12 +183,6 @@
|
|
|
183
183
|
h: 100
|
|
184
184
|
};
|
|
185
185
|
},
|
|
186
|
-
finalRequestOssType () {
|
|
187
|
-
return this.selfPropsObj._requestOssType || this.requestOssType;
|
|
188
|
-
},
|
|
189
|
-
acceptType () {
|
|
190
|
-
return this.selfPropsObj._acceptType || "*";
|
|
191
|
-
},
|
|
192
186
|
|
|
193
187
|
modalPropsObj () {
|
|
194
188
|
return {
|
|
@@ -209,73 +203,90 @@
|
|
|
209
203
|
},
|
|
210
204
|
created () {},
|
|
211
205
|
methods: {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
206
|
+
// 点击文件预览
|
|
207
|
+
handlePreview (file) {
|
|
208
|
+
let viewerImage = this.$refs.viewerImage;
|
|
209
|
+
let viewer = new Viewer(viewerImage, {
|
|
210
|
+
url: "data-original",
|
|
211
|
+
hidden: function () {
|
|
212
|
+
viewer.destroy();
|
|
213
|
+
},
|
|
214
|
+
loop: false,
|
|
215
|
+
zIndex: 2147483647
|
|
216
|
+
});
|
|
217
|
+
viewer.show();
|
|
218
|
+
},
|
|
219
|
+
// 点击文件删除 - fileList服务器的数据列表
|
|
220
|
+
handleRemove (file) {
|
|
221
|
+
this.uploadType = "file"; // 删除后可以重新上传
|
|
222
|
+
this.curVal = "";
|
|
223
|
+
this.change(this.value);
|
|
224
|
+
},
|
|
225
|
+
change (...params) {
|
|
226
|
+
this.$emit("change", ...params);
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
handleChange (event) {
|
|
230
|
+
if (event.target.files.length) {
|
|
231
|
+
const file = event.target.files[0];
|
|
232
|
+
|
|
215
233
|
if (!file.type.includes("image/")) {
|
|
216
234
|
this.$Message.error("请选择一张图片");
|
|
217
235
|
}
|
|
218
236
|
else if (typeof FileReader !== "function") {
|
|
219
|
-
this.$Message.error("Sorry, FileReader API not supported");
|
|
237
|
+
this.$Message.error("Sorry, FileReader API not supported!");
|
|
220
238
|
}
|
|
221
239
|
else {
|
|
222
240
|
const reader = new FileReader();
|
|
223
|
-
|
|
241
|
+
// 使用裁剪
|
|
242
|
+
if (this.isCropper) {
|
|
224
243
|
reader.onload = (event) => {
|
|
225
|
-
this.
|
|
226
|
-
this.
|
|
244
|
+
this.uploadType = "text";
|
|
245
|
+
this.imgSrc = event.target.result;
|
|
246
|
+
this.$refs.cropperDom.replace(event.target.result); // event.target.result是base64格式
|
|
227
247
|
};
|
|
228
248
|
reader.readAsDataURL(file);
|
|
249
|
+
|
|
250
|
+
this.openAvatarModal();
|
|
229
251
|
}
|
|
230
|
-
// 使用裁剪
|
|
231
252
|
else {
|
|
232
253
|
reader.onload = (event) => {
|
|
233
|
-
this.
|
|
234
|
-
this.
|
|
235
|
-
this.$refs.cropper.replace(event.target.result); // event.target.result是base64格式
|
|
254
|
+
this.uploadType = "text";
|
|
255
|
+
this.dealPostImage(event.target.result); // event.target.result是base64格式
|
|
236
256
|
};
|
|
237
257
|
reader.readAsDataURL(file);
|
|
238
|
-
|
|
239
|
-
this.openAvatarModal();
|
|
240
258
|
}
|
|
241
259
|
}
|
|
242
260
|
}
|
|
243
261
|
},
|
|
244
262
|
// 提交裁剪后的图片
|
|
245
263
|
submitCropImage () {
|
|
246
|
-
this.
|
|
247
|
-
this.dealPostImage(this.cropImg);
|
|
264
|
+
this.dealPostImage(this.$refs.cropperDom.getCroppedCanvas().toDataURL()); // base64格式
|
|
248
265
|
|
|
249
266
|
this.closeAvatarModal();
|
|
250
267
|
},
|
|
268
|
+
// 处理图片的提交
|
|
269
|
+
dealPostImage (fileData) {
|
|
270
|
+
this.handlePost((ossType) => {
|
|
271
|
+
return ossType === "local"
|
|
272
|
+
? this.dataURLtoFile(fileData, "") // 本地上传,将图片Base64转成文件
|
|
273
|
+
: Buffer.from(fileData.split(",")[1], "base64"); // 阿里上传,object类型
|
|
274
|
+
});
|
|
275
|
+
},
|
|
276
|
+
successCb (response, res) {
|
|
277
|
+
this.curVal = res.data.downloadUrl;
|
|
278
|
+
this.$emit("change", res);
|
|
279
|
+
},
|
|
280
|
+
handleError (err) {
|
|
281
|
+
alert(err);
|
|
282
|
+
},
|
|
251
283
|
|
|
252
284
|
// 获取裁剪的图片
|
|
253
285
|
cropImage () {
|
|
254
286
|
// get image data for post processing, e.g. upload or setting image src
|
|
255
|
-
this.cropImg = this.$refs.
|
|
256
|
-
},
|
|
257
|
-
// 处理图片的提交
|
|
258
|
-
dealPostImage (data) {
|
|
259
|
-
// local好像是minio在用
|
|
260
|
-
if (this.finalRequestOssType === "local") {
|
|
261
|
-
// base64转文件
|
|
262
|
-
// {
|
|
263
|
-
// lastModified: 1752065308269
|
|
264
|
-
// name: ".png"
|
|
265
|
-
// size: 528557
|
|
266
|
-
// type: "image/png"
|
|
267
|
-
// webkitRelativePath: ""
|
|
268
|
-
// }
|
|
269
|
-
const imgFile = this.dataURLtoFile(data, "");
|
|
270
|
-
this.handlePost(imgFile);
|
|
271
|
-
// console.dir(imgFile); // object类型
|
|
272
|
-
} else {
|
|
273
|
-
const dataBuffer = Buffer.from(data.split(",")[1], "base64");
|
|
274
|
-
this.handlePost(dataBuffer);
|
|
275
|
-
// console.dir(dataBuffer); // object类型
|
|
276
|
-
}
|
|
287
|
+
this.cropImg = this.$refs.cropperDom.getCroppedCanvas().toDataURL(); // base64格式
|
|
277
288
|
},
|
|
278
|
-
// 将图片Base64
|
|
289
|
+
// 将图片Base64转成文件
|
|
279
290
|
dataURLtoFile (dataurl, filename) {
|
|
280
291
|
// 获取文件扩展名称
|
|
281
292
|
let arr = dataurl.split(",");
|
|
@@ -287,38 +298,15 @@
|
|
|
287
298
|
while (n--) {
|
|
288
299
|
u8arr[n] = bstr.charCodeAt(n);
|
|
289
300
|
}
|
|
290
|
-
return new File([u8arr], `${filename}.${extension}`, { type: mime });
|
|
291
|
-
},
|
|
292
301
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
// 点击文件预览
|
|
302
|
-
handlePreview (file) {
|
|
303
|
-
let viewerImage = this.$refs.viewerImage;
|
|
304
|
-
let viewer = new Viewer(viewerImage, {
|
|
305
|
-
url: "data-original",
|
|
306
|
-
hidden: function () {
|
|
307
|
-
viewer.destroy();
|
|
308
|
-
},
|
|
309
|
-
loop: false,
|
|
310
|
-
zIndex: 2147483647
|
|
311
|
-
});
|
|
312
|
-
viewer.show();
|
|
313
|
-
},
|
|
314
|
-
// 点击文件删除 - fileList服务器的数据列表
|
|
315
|
-
handleRemove (file) {
|
|
316
|
-
this.inputType = "file"; // 删除后可以重新上传
|
|
317
|
-
this.curVal = "";
|
|
318
|
-
this.change(this.value);
|
|
319
|
-
},
|
|
320
|
-
change (...params) {
|
|
321
|
-
this.$emit("change", ...params);
|
|
302
|
+
return new File([u8arr], `${filename}.${extension}`, { type: mime });
|
|
303
|
+
// {
|
|
304
|
+
// lastModified: 1752065308269
|
|
305
|
+
// name: ".png"
|
|
306
|
+
// size: 528557
|
|
307
|
+
// type: "image/png"
|
|
308
|
+
// webkitRelativePath: ""
|
|
309
|
+
// }
|
|
322
310
|
},
|
|
323
311
|
|
|
324
312
|
// 打开修改头像
|
|
@@ -332,7 +320,7 @@
|
|
|
332
320
|
// 头像模态框状态变化,关闭后改变input框类型,保证上传能够连续上传同一张图片
|
|
333
321
|
visibleChange (bool) {
|
|
334
322
|
if (!bool) {
|
|
335
|
-
this.
|
|
323
|
+
this.uploadType = "file";
|
|
336
324
|
}
|
|
337
325
|
}
|
|
338
326
|
}
|
|
@@ -347,9 +335,9 @@
|
|
|
347
335
|
width: 100%;
|
|
348
336
|
|
|
349
337
|
&-img {
|
|
338
|
+
float: left;
|
|
350
339
|
width: 100px;
|
|
351
340
|
height: 100px;
|
|
352
|
-
float: left;
|
|
353
341
|
background-repeat: no-repeat;
|
|
354
342
|
background-position: center;
|
|
355
343
|
background-size: contain;
|
|
@@ -360,7 +348,9 @@
|
|
|
360
348
|
overflow: hidden;
|
|
361
349
|
|
|
362
350
|
&-action {
|
|
351
|
+
font-weight: 600;
|
|
363
352
|
color: @themeColor;
|
|
353
|
+
// color: #ffffff;
|
|
364
354
|
cursor: pointer;
|
|
365
355
|
}
|
|
366
356
|
|
|
@@ -408,7 +398,7 @@
|
|
|
408
398
|
left: 0;
|
|
409
399
|
}
|
|
410
400
|
|
|
411
|
-
|
|
401
|
+
&-input {
|
|
412
402
|
position: absolute;
|
|
413
403
|
bottom: 0;
|
|
414
404
|
left: 0;
|
|
@@ -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,22 @@ 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
|
+
|
|
44
|
+
// BriUploadImage使用时,file参数是个函数
|
|
45
|
+
if (typeof file === "function") {
|
|
46
|
+
file = file(res.ossType);
|
|
47
|
+
}
|
|
48
|
+
|
|
56
49
|
if (res.ossType === "ali-oss") {
|
|
57
50
|
// 上传到阿里云res
|
|
58
|
-
if (this.
|
|
51
|
+
if (this.aliOssType === "binaryMultipartUpload") {
|
|
59
52
|
this.binaryMultipartUpload(file, res, callback);
|
|
60
53
|
}
|
|
61
|
-
else if (this.
|
|
54
|
+
else if (this.aliOssType === "multipartUpload") {
|
|
62
55
|
this.multipartUpload(file, res, callback);
|
|
63
56
|
}
|
|
64
57
|
}
|
|
@@ -71,7 +64,6 @@ export default {
|
|
|
71
64
|
else {
|
|
72
65
|
console.log(`请开发这种类型‘${res.ossType}’的上传模式`);
|
|
73
66
|
}
|
|
74
|
-
|
|
75
67
|
}
|
|
76
68
|
});
|
|
77
69
|
},
|
|
@@ -84,7 +76,7 @@ export default {
|
|
|
84
76
|
headers: {
|
|
85
77
|
filetoken: res.filetoken,
|
|
86
78
|
filebody: JSON.stringify({
|
|
87
|
-
groupKey: this.
|
|
79
|
+
groupKey: this.uploadGroupKey,
|
|
88
80
|
archiveKey: this.archiveKey[this.archiveKey.length - 1]
|
|
89
81
|
})
|
|
90
82
|
},
|
|
@@ -186,7 +178,7 @@ export default {
|
|
|
186
178
|
path: remoteName,
|
|
187
179
|
bucket: res.ossConfig.bucket,
|
|
188
180
|
filetoken: res.filetoken,
|
|
189
|
-
groupKey: this.
|
|
181
|
+
groupKey: this.uploadGroupKey,
|
|
190
182
|
archiveKey: this.archiveKey[this.archiveKey.length - 1]
|
|
191
183
|
};
|
|
192
184
|
axios.post(res.ossHost + res.confirmPath, { ...callbackBody })
|
|
@@ -235,10 +227,9 @@ export default {
|
|
|
235
227
|
path: remoteName,
|
|
236
228
|
bucket: res.ossConfig.bucket,
|
|
237
229
|
filetoken: res.filetoken,
|
|
238
|
-
groupKey: this.
|
|
230
|
+
groupKey: this.uploadGroupKey,
|
|
239
231
|
archiveKey: this.archiveKey[this.archiveKey.length - 1]
|
|
240
232
|
};
|
|
241
|
-
|
|
242
233
|
let ossCallback = {
|
|
243
234
|
callbackUrl: res.ossHost + res.confirmPath,
|
|
244
235
|
callbackBodyType: "application/json",
|
|
@@ -258,31 +249,34 @@ export default {
|
|
|
258
249
|
refreshSTSTokenInterval: 3600 * 1000
|
|
259
250
|
};
|
|
260
251
|
|
|
261
|
-
new Oss(newOss)
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
252
|
+
new Oss(newOss)
|
|
253
|
+
.multipartUpload(remoteName, file, {
|
|
254
|
+
progress: (percentage) => {
|
|
255
|
+
this.inProgress(Number((percentage * 100).toFixed(1)));
|
|
256
|
+
this.handleProgress && this.handleProgress(percentage, file);
|
|
257
|
+
},
|
|
258
|
+
headers: {
|
|
259
|
+
"x-oss-callback": this.base64Encode(JSON.stringify(ossCallback)),
|
|
260
|
+
"Content-Disposition": type === "pdf" ? `inline;filename=${encodeURI(file.name)}` : `attachment;filename=${encodeURI(file.name)}`
|
|
261
|
+
}
|
|
262
|
+
})
|
|
263
|
+
.then(response => {
|
|
264
|
+
this.uploadSuccess = true;
|
|
265
|
+
this.percent = 100;
|
|
266
|
+
setTimeout(() => {
|
|
267
|
+
this.uploadSuccess = false;
|
|
268
|
+
this.percent = 0;
|
|
269
|
+
}, 500);
|
|
270
|
+
|
|
271
|
+
this.successCb && this.successCb(response, response.data, file);
|
|
272
|
+
callback && callback(response.data);
|
|
273
|
+
})
|
|
274
|
+
.catch((err, response) => {
|
|
274
275
|
this.uploadSuccess = false;
|
|
275
276
|
this.percent = 0;
|
|
276
|
-
}, 500);
|
|
277
277
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}).catch((err, response) => {
|
|
281
|
-
this.uploadSuccess = false;
|
|
282
|
-
this.percent = 0;
|
|
283
|
-
|
|
284
|
-
this.handleError && this.handleError(err, response, file);
|
|
285
|
-
callback && callback(err);
|
|
278
|
+
this.handleError && this.handleError(err, response, file);
|
|
279
|
+
callback && callback(err);
|
|
286
280
|
});
|
|
287
281
|
},
|
|
288
282
|
// bri-upload-image 用的是这种方式
|
|
@@ -297,10 +291,9 @@ export default {
|
|
|
297
291
|
path: remoteName,
|
|
298
292
|
bucket: res.ossConfig.bucket,
|
|
299
293
|
filetoken: res.filetoken,
|
|
300
|
-
groupKey: this.
|
|
294
|
+
groupKey: this.uploadGroupKey,
|
|
301
295
|
archiveKey: this.archiveKey[this.archiveKey.length - 1]
|
|
302
296
|
};
|
|
303
|
-
|
|
304
297
|
let ossCallback = {
|
|
305
298
|
callbackUrl: res.ossHost + res.confirmPath,
|
|
306
299
|
callbackBodyType: "application/json",
|
|
@@ -320,41 +313,42 @@ export default {
|
|
|
320
313
|
refreshSTSTokenInterval: 3600 * 1000
|
|
321
314
|
};
|
|
322
315
|
|
|
323
|
-
new Oss(newOss)
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
316
|
+
new Oss(newOss)
|
|
317
|
+
.multipartUpload(remoteName, file, {
|
|
318
|
+
progress: (percentage) => {
|
|
319
|
+
this.inProgress(Number((percentage * 100).toFixed(1)));
|
|
320
|
+
this.handleProgress && this.handleProgress(percentage, file);
|
|
321
|
+
},
|
|
322
|
+
headers: {
|
|
323
|
+
"x-oss-callback": this.base64Encode(JSON.stringify(ossCallback)),
|
|
324
|
+
"Content-Disposition": type === "pdf" ? `inline;filename=${encodeURI(file.name)}` : `attachment;filename=${encodeURI(file.name)}`
|
|
325
|
+
}
|
|
326
|
+
})
|
|
327
|
+
.then(response => {
|
|
328
|
+
this.uploadSuccess = true;
|
|
329
|
+
this.percent = 100;
|
|
330
|
+
setTimeout(() => {
|
|
331
|
+
this.uploadSuccess = false;
|
|
332
|
+
this.percent = 0;
|
|
333
|
+
}, 500);
|
|
334
|
+
|
|
335
|
+
this.successCb && this.successCb(response, response.data, file);
|
|
336
|
+
callback && callback(response.data);
|
|
337
|
+
})
|
|
338
|
+
.catch((err, response) => {
|
|
336
339
|
this.uploadSuccess = false;
|
|
337
340
|
this.percent = 0;
|
|
338
|
-
}, 500);
|
|
339
341
|
|
|
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);
|
|
342
|
+
this.handleError && this.handleError(err, response, file);
|
|
343
|
+
callback && callback(err);
|
|
348
344
|
});
|
|
349
345
|
},
|
|
350
346
|
|
|
351
347
|
// 处理上传进度
|
|
352
348
|
inProgress (percent) {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
this.percent = percent;
|
|
357
|
-
}
|
|
349
|
+
this.percent = percent === 100 && !this.uploadSuccess
|
|
350
|
+
? 99.9
|
|
351
|
+
: percent;
|
|
358
352
|
|
|
359
353
|
if (this.percent >= 100) {
|
|
360
354
|
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"; // 后端接受上传文件的参数名
|