bri-components 1.6.2 → 1.6.4
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bri-components",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.4",
|
|
4
4
|
"author": "dengshanghui",
|
|
5
5
|
"description": "a component lib for vue project",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"ali-oss": "^6.13.1",
|
|
34
34
|
"axios": "^0.23.0",
|
|
35
|
-
"bri-datas": "^1.4
|
|
35
|
+
"bri-datas": "^1.5.4",
|
|
36
36
|
"jshint": "^2.12.0",
|
|
37
37
|
"jsonlint": "^1.6.3",
|
|
38
38
|
"minio": "7.1.0",
|
|
@@ -101,20 +101,7 @@
|
|
|
101
101
|
import uploadMixin from "./uploadMixin.js";
|
|
102
102
|
import BriUploadImage from "./BriUploadImage.vue";
|
|
103
103
|
import uploadList from "./uploadList.vue";
|
|
104
|
-
|
|
105
|
-
const prefixCls = "ivu-upload";
|
|
106
|
-
const fileTypesMap = {
|
|
107
|
-
document: ["txt", "doc", "xls", "ppt", "docx", "xlsx", "pptx", "pdf", "xmind"],
|
|
108
|
-
image: ["jpg", "png", "gif", "jpeg", "tiff", "swf"],
|
|
109
|
-
video: ["flv", "rmvb", "mp4", "mvb"],
|
|
110
|
-
audio: ["wma", "mp3", "m4a"],
|
|
111
|
-
// text: ["log", "csv", "html", "json"],
|
|
112
|
-
package: ["rar", "zip"]
|
|
113
|
-
};
|
|
114
|
-
const allFileTypes = Object.entries(fileTypesMap).reduce((arr, fileTypeArr, fileTypeIndex, map) => [
|
|
115
|
-
...arr,
|
|
116
|
-
...fileTypeArr[1]
|
|
117
|
-
], []);
|
|
104
|
+
import { fileTypes } from "../../../../data/index.js";
|
|
118
105
|
|
|
119
106
|
export default {
|
|
120
107
|
name: "BriUpload",
|
|
@@ -129,7 +116,7 @@
|
|
|
129
116
|
props: {},
|
|
130
117
|
data () {
|
|
131
118
|
return {
|
|
132
|
-
prefixCls:
|
|
119
|
+
prefixCls: "ivu-upload",
|
|
133
120
|
dragOver: false,
|
|
134
121
|
|
|
135
122
|
operationMap: {
|
|
@@ -148,11 +135,11 @@
|
|
|
148
135
|
_fileType: "file", // "file", "image", "video"
|
|
149
136
|
_showMode: this.isHeightAuto ? "old" : "inline", // 宽度为100%、且不在表格字段里的 显示老版
|
|
150
137
|
|
|
151
|
-
_multiple: true,
|
|
152
|
-
_useType: "drag",
|
|
138
|
+
_multiple: true, // 默认多选
|
|
139
|
+
_useType: "drag", // "drag", "select"
|
|
153
140
|
_maxSize: 1024 * 1024 * 2, // 根据四局要求,限制文件为2G
|
|
154
141
|
_format: [],
|
|
155
|
-
_accept: [],
|
|
142
|
+
_accept: [], // 限制只能传那些文件类型,_accept有值的话,_fileType就没用了
|
|
156
143
|
|
|
157
144
|
...this.propsObj,
|
|
158
145
|
...this.commonDealPropsObj
|
|
@@ -179,28 +166,32 @@
|
|
|
179
166
|
},
|
|
180
167
|
// 限制文件格式
|
|
181
168
|
accept () {
|
|
182
|
-
const types = this.selfPropsObj._accept
|
|
169
|
+
const types = this.selfPropsObj._accept.length
|
|
183
170
|
? this.selfPropsObj._accept
|
|
184
|
-
:
|
|
185
|
-
|
|
186
|
-
|
|
171
|
+
: (
|
|
172
|
+
this.subType === "file"
|
|
173
|
+
? fileTypes
|
|
174
|
+
: fileTypes.filter(fileTypeItem => fileTypeItem.type === this.subType)
|
|
175
|
+
).map(fileTypeItem => fileTypeItem._key);
|
|
187
176
|
|
|
188
177
|
return types.map(type => `.${type}`).join();
|
|
189
178
|
},
|
|
190
179
|
isShowEditIcon () {
|
|
191
180
|
// 因为编辑name 需要这三个参数,因此没有这三个参数时不显示此按钮
|
|
192
|
-
return this.compKey && this.appKey && this.modKey &&
|
|
181
|
+
return this.compKey && this.appKey && this.modKey &&
|
|
182
|
+
!!(this.$getHttpPathMap({}).file && this.$getHttpPathMap({}).file.updateFileName);
|
|
193
183
|
},
|
|
194
184
|
classes () {
|
|
195
185
|
return {
|
|
196
|
-
[`${prefixCls}`]: true,
|
|
197
|
-
[`${prefixCls}-select`]: this.useType === "select",
|
|
198
|
-
[`${prefixCls}-drag`]: this.useType === "drag",
|
|
199
|
-
[`${prefixCls}-dragOver`]: this.useType === "drag" && this.dragOver,
|
|
186
|
+
[`${this.prefixCls}`]: true,
|
|
187
|
+
[`${this.prefixCls}-select`]: this.useType === "select",
|
|
188
|
+
[`${this.prefixCls}-drag`]: this.useType === "drag",
|
|
189
|
+
[`${this.prefixCls}-dragOver`]: this.useType === "drag" && this.dragOver,
|
|
200
190
|
[`BriUpload-${this.showMode}-wrapper`]: true
|
|
201
191
|
};
|
|
202
192
|
}
|
|
203
193
|
},
|
|
194
|
+
created () {},
|
|
204
195
|
methods: {
|
|
205
196
|
clickUpload () {
|
|
206
197
|
if (!this.disabled) {
|
|
@@ -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'">
|
|
@@ -10,16 +9,16 @@
|
|
|
10
9
|
<div
|
|
11
10
|
v-if="files.length"
|
|
12
11
|
ref="viewerImage"
|
|
13
|
-
:class="
|
|
14
|
-
'uploadList-list'
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
:class="[
|
|
13
|
+
'uploadList-list',
|
|
14
|
+
`uploadList-list-${subType}`
|
|
15
|
+
]"
|
|
17
16
|
>
|
|
18
17
|
<div
|
|
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
|
>
|
|
@@ -39,7 +38,7 @@
|
|
|
39
38
|
</div>
|
|
40
39
|
|
|
41
40
|
<!-- 展示名称 -->
|
|
42
|
-
<p class="item-name
|
|
41
|
+
<p class="item-name">{{ fileItem.name }}</p>
|
|
43
42
|
|
|
44
43
|
<!-- 图标 -->
|
|
45
44
|
<dsh-icons
|
|
@@ -54,7 +53,7 @@
|
|
|
54
53
|
<!-- 无值 -->
|
|
55
54
|
<div
|
|
56
55
|
v-else
|
|
57
|
-
class="uploadList-
|
|
56
|
+
class="uploadList-old-odata"
|
|
58
57
|
>
|
|
59
58
|
<span>{{ emptyShowVal }}</span>
|
|
60
59
|
</div>
|
|
@@ -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
|
>
|
|
@@ -95,7 +94,7 @@
|
|
|
95
94
|
</div>
|
|
96
95
|
|
|
97
96
|
<!-- 展示名称 -->
|
|
98
|
-
<p class="item-name
|
|
97
|
+
<p class="item-name">{{ fileItem.name }}</p>
|
|
99
98
|
|
|
100
99
|
<!-- 图标 -->
|
|
101
100
|
<dsh-icons
|
|
@@ -128,11 +127,11 @@
|
|
|
128
127
|
<dsh-dropdown
|
|
129
128
|
:list="files"
|
|
130
129
|
trigger="hover"
|
|
131
|
-
class="uploadList-
|
|
130
|
+
class="uploadList-inline-dropdown"
|
|
132
131
|
>
|
|
133
132
|
<div :class="{
|
|
134
|
-
'uploadList-
|
|
135
|
-
'uploadList-
|
|
133
|
+
'uploadList-inline-dropdown-fileName': true,
|
|
134
|
+
'uploadList-inline-dropdown-fileName-edit': canEdit
|
|
136
135
|
}">
|
|
137
136
|
{{ files.length }}个
|
|
138
137
|
<Icon
|
|
@@ -144,49 +143,32 @@
|
|
|
144
143
|
<div
|
|
145
144
|
slot="dropdownItem"
|
|
146
145
|
slot-scope="{ dropdownItem, dropdownIndex }"
|
|
147
|
-
class="uploadList-
|
|
146
|
+
class="uploadList-inline-dropdown-item"
|
|
148
147
|
>
|
|
149
148
|
<img
|
|
150
149
|
v-if="dropdownItem.mimetype.includes('image')"
|
|
151
150
|
:data-original="dropdownItem.url"
|
|
152
151
|
:src="$imageResize(dropdownItem.url, imageResizeConfig)"
|
|
153
152
|
:alt="dropdownItem.name"
|
|
154
|
-
class="
|
|
153
|
+
class="item-img"
|
|
155
154
|
>
|
|
156
155
|
<img
|
|
157
156
|
v-else
|
|
158
157
|
:src="getFileImage(dropdownItem)"
|
|
159
158
|
:alt="dropdownItem.name"
|
|
160
|
-
class="
|
|
159
|
+
class="item-img"
|
|
161
160
|
>
|
|
162
161
|
|
|
163
|
-
<p class="
|
|
162
|
+
<p class="item-name">{{ dropdownItem.name }}</p>
|
|
164
163
|
|
|
165
164
|
<dsh-icons
|
|
166
|
-
class="
|
|
167
|
-
item-class="
|
|
165
|
+
class="item-action"
|
|
166
|
+
item-class="item-action-icon"
|
|
168
167
|
:list="$getOperationList(getBtns(dropdownItem))"
|
|
169
168
|
@click="$dispatchEvent($event, dropdownItem, dropdownIndex)"
|
|
170
169
|
></dsh-icons>
|
|
171
170
|
</div>
|
|
172
171
|
</dsh-dropdown>
|
|
173
|
-
|
|
174
|
-
<div
|
|
175
|
-
v-for="(fileItem) in files"
|
|
176
|
-
:key="fileItem._key || fileItem._id"
|
|
177
|
-
:class="{
|
|
178
|
-
'item': subType === 'image',
|
|
179
|
-
[`item-${subType}`]: true
|
|
180
|
-
}"
|
|
181
|
-
>
|
|
182
|
-
<img
|
|
183
|
-
v-if="fileItem.mimetype.includes('image')"
|
|
184
|
-
:data-original="fileItem.url"
|
|
185
|
-
:src="$imageResize(fileItem.url, imageResizeConfig)"
|
|
186
|
-
:alt="fileItem.name"
|
|
187
|
-
style="display: none;"
|
|
188
|
-
>
|
|
189
|
-
</div>
|
|
190
172
|
</template>
|
|
191
173
|
|
|
192
174
|
<!-- 无值 -->
|
|
@@ -256,14 +238,14 @@
|
|
|
256
238
|
// DshVideoPlayer
|
|
257
239
|
},
|
|
258
240
|
props: {
|
|
259
|
-
showMode: {
|
|
260
|
-
type: String,
|
|
261
|
-
default: "old" // inline, old, normal
|
|
262
|
-
},
|
|
263
241
|
canEdit: {
|
|
264
242
|
type: Boolean,
|
|
265
243
|
default: true
|
|
266
244
|
},
|
|
245
|
+
showMode: {
|
|
246
|
+
type: String,
|
|
247
|
+
default: "old" // old, tableList, inline
|
|
248
|
+
},
|
|
267
249
|
files: {
|
|
268
250
|
type: Array,
|
|
269
251
|
default () {
|
|
@@ -330,6 +312,7 @@
|
|
|
330
312
|
operations.canDownload.customIcon = "bri-xiazai";
|
|
331
313
|
operations.canPreview.customIcon = "bri-keshi";
|
|
332
314
|
}
|
|
315
|
+
|
|
333
316
|
return this.canEdit
|
|
334
317
|
? this.$categoryMapToMap(
|
|
335
318
|
operations,
|
|
@@ -475,29 +458,11 @@
|
|
|
475
458
|
};
|
|
476
459
|
</script>
|
|
477
460
|
|
|
478
|
-
<style lang="less">
|
|
461
|
+
<style lang="less" scoped>
|
|
479
462
|
.uploadList {
|
|
480
463
|
width: 100%;
|
|
481
464
|
overflow: auto;
|
|
482
465
|
|
|
483
|
-
// 普通文件
|
|
484
|
-
&-old {
|
|
485
|
-
margin: 16px;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
&-nodata {
|
|
489
|
-
width: 100%;
|
|
490
|
-
height: 100%;
|
|
491
|
-
text-align: center;
|
|
492
|
-
line-height: 120px;
|
|
493
|
-
color: @placeholderColor;
|
|
494
|
-
white-space: nowrap;
|
|
495
|
-
|
|
496
|
-
span {
|
|
497
|
-
margin-left: 5px;
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
|
|
501
466
|
&-list {
|
|
502
467
|
display: flex;
|
|
503
468
|
flex-wrap: nowrap;
|
|
@@ -515,12 +480,6 @@
|
|
|
515
480
|
justify-content: space-between;
|
|
516
481
|
position: relative;
|
|
517
482
|
|
|
518
|
-
&:hover {
|
|
519
|
-
.item-action {
|
|
520
|
-
display: flex !important;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
|
|
524
483
|
&-show {
|
|
525
484
|
display: flex;
|
|
526
485
|
overflow: hidden;
|
|
@@ -536,17 +495,11 @@
|
|
|
536
495
|
}
|
|
537
496
|
|
|
538
497
|
&-name {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
padding: 0 8px;
|
|
545
|
-
overflow: hidden;
|
|
546
|
-
text-overflow: ellipsis;
|
|
547
|
-
white-space: nowrap;
|
|
548
|
-
color: @themeColor;
|
|
549
|
-
}
|
|
498
|
+
padding: 0 8px;
|
|
499
|
+
overflow: hidden;
|
|
500
|
+
text-overflow: ellipsis;
|
|
501
|
+
white-space: nowrap;
|
|
502
|
+
color: @themeColor;
|
|
550
503
|
}
|
|
551
504
|
|
|
552
505
|
&-action {
|
|
@@ -567,11 +520,18 @@
|
|
|
567
520
|
color: #fff;
|
|
568
521
|
}
|
|
569
522
|
}
|
|
523
|
+
|
|
524
|
+
&:hover {
|
|
525
|
+
.item-action {
|
|
526
|
+
display: flex !important;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
570
529
|
}
|
|
571
530
|
|
|
572
531
|
// file 模式
|
|
573
532
|
&-file {
|
|
574
533
|
flex-direction: column;
|
|
534
|
+
|
|
575
535
|
.item-file {
|
|
576
536
|
flex: 0 0 100%;
|
|
577
537
|
height: auto;
|
|
@@ -583,32 +543,57 @@
|
|
|
583
543
|
margin: 0px;
|
|
584
544
|
padding: 2px 0;
|
|
585
545
|
background: transparent;
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
546
|
+
|
|
547
|
+
.item {
|
|
548
|
+
&-show {
|
|
549
|
+
flex: 0 0 22px;
|
|
550
|
+
min-height: 20px;
|
|
551
|
+
img {
|
|
552
|
+
width: 22px;
|
|
553
|
+
height: 22px;
|
|
554
|
+
}
|
|
595
555
|
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
556
|
+
|
|
557
|
+
&-name {
|
|
558
|
+
flex: 1;
|
|
559
|
+
text-align: left;
|
|
560
|
+
color: @textColor;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
&-action {
|
|
564
|
+
position: static;
|
|
565
|
+
display: flex !important;
|
|
566
|
+
background: transparent;
|
|
567
|
+
white-space: nowrap;
|
|
568
|
+
|
|
569
|
+
&-icon {
|
|
570
|
+
color: @contentColor;
|
|
571
|
+
width: 16px;
|
|
572
|
+
}
|
|
610
573
|
}
|
|
611
574
|
}
|
|
575
|
+
|
|
576
|
+
&:hover {
|
|
577
|
+
background: #f4f5fa;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
// 普通文件
|
|
584
|
+
&-old {
|
|
585
|
+
margin: 16px;
|
|
586
|
+
|
|
587
|
+
&-nodata {
|
|
588
|
+
width: 100%;
|
|
589
|
+
height: 100%;
|
|
590
|
+
text-align: center;
|
|
591
|
+
line-height: 120px;
|
|
592
|
+
color: @placeholderColor;
|
|
593
|
+
white-space: nowrap;
|
|
594
|
+
|
|
595
|
+
span {
|
|
596
|
+
margin-left: 5px;
|
|
612
597
|
}
|
|
613
598
|
}
|
|
614
599
|
}
|
|
@@ -617,6 +602,55 @@
|
|
|
617
602
|
height: 32px;
|
|
618
603
|
line-height: 32px;
|
|
619
604
|
|
|
605
|
+
&-dropdown {
|
|
606
|
+
width: 100%;
|
|
607
|
+
|
|
608
|
+
&-fileName {
|
|
609
|
+
cursor: pointer;
|
|
610
|
+
|
|
611
|
+
&-edit {
|
|
612
|
+
padding: 0 8px;
|
|
613
|
+
display: flex;
|
|
614
|
+
justify-content: space-between;
|
|
615
|
+
align-items: center;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
&-item {
|
|
620
|
+
width: 100%;
|
|
621
|
+
display: flex;
|
|
622
|
+
justify-content: space-between;
|
|
623
|
+
align-items: center;
|
|
624
|
+
|
|
625
|
+
.item {
|
|
626
|
+
&-img {
|
|
627
|
+
width: 22px;
|
|
628
|
+
height: 22px;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
&-name {
|
|
632
|
+
white-space: nowrap;
|
|
633
|
+
overflow: hidden;
|
|
634
|
+
text-overflow: ellipsis;
|
|
635
|
+
margin: 0 8px;
|
|
636
|
+
flex: 1;
|
|
637
|
+
text-align: left;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
&-action {
|
|
641
|
+
display: flex;
|
|
642
|
+
align-items: center;
|
|
643
|
+
justify-content: flex-end;
|
|
644
|
+
|
|
645
|
+
&-icon {
|
|
646
|
+
width: 16px;
|
|
647
|
+
color: @contentColor;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
|
|
620
654
|
&-list {
|
|
621
655
|
width: 100%;
|
|
622
656
|
height: 100%;
|
|
@@ -686,53 +720,5 @@
|
|
|
686
720
|
color: @placeholderColor;
|
|
687
721
|
}
|
|
688
722
|
}
|
|
689
|
-
|
|
690
|
-
&-fileList {
|
|
691
|
-
width: 100%;
|
|
692
|
-
|
|
693
|
-
&-fileName {
|
|
694
|
-
cursor: pointer;
|
|
695
|
-
|
|
696
|
-
&-edit {
|
|
697
|
-
padding: 0 8px;
|
|
698
|
-
display: flex;
|
|
699
|
-
justify-content: space-between;
|
|
700
|
-
align-items: center;
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
.DshDropdown {
|
|
707
|
-
.uploadList-fileList-fileItem {
|
|
708
|
-
width: 100%;
|
|
709
|
-
display: flex;
|
|
710
|
-
justify-content: space-between;
|
|
711
|
-
align-items: center;
|
|
712
|
-
.fileItem {
|
|
713
|
-
&-img {
|
|
714
|
-
width: 22px;
|
|
715
|
-
height: 22px;
|
|
716
|
-
}
|
|
717
|
-
&-name-title {
|
|
718
|
-
white-space: nowrap;
|
|
719
|
-
overflow: hidden;
|
|
720
|
-
text-overflow: ellipsis;
|
|
721
|
-
margin: 0 8px;
|
|
722
|
-
flex: 1;
|
|
723
|
-
text-align: left;
|
|
724
|
-
}
|
|
725
|
-
&-action {
|
|
726
|
-
display: flex;
|
|
727
|
-
align-items: center;
|
|
728
|
-
justify-content: flex-end;
|
|
729
|
-
&-icon {
|
|
730
|
-
width: 16px;
|
|
731
|
-
color: @contentColor;
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
}
|
|
737
723
|
}
|
|
738
724
|
</style>
|
|
@@ -77,19 +77,16 @@ export default {
|
|
|
77
77
|
},
|
|
78
78
|
|
|
79
79
|
localUpload (file, res, callback) {
|
|
80
|
-
let fileBody = {
|
|
81
|
-
groupKey: this.computedGroupKey,
|
|
82
|
-
archiveKey: this.archiveKey[this.archiveKey.length - 1]
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const url = `${res.ossHost}${res.uploadPath}`;
|
|
86
80
|
let formData = new FormData();
|
|
87
81
|
formData.append("file_stream", file);
|
|
88
82
|
|
|
89
|
-
axios.post(
|
|
83
|
+
axios.post(`${res.ossHost}${res.uploadPath}`, formData, {
|
|
90
84
|
headers: {
|
|
91
85
|
filetoken: res.filetoken,
|
|
92
|
-
filebody: JSON.stringify(
|
|
86
|
+
filebody: JSON.stringify({
|
|
87
|
+
groupKey: this.computedGroupKey,
|
|
88
|
+
archiveKey: this.archiveKey[this.archiveKey.length - 1]
|
|
89
|
+
})
|
|
93
90
|
},
|
|
94
91
|
onUploadProgress: progressEvent => {
|
|
95
92
|
this.inProgress(Number((progressEvent.loaded / progressEvent.total * 100).toFixed(1)));
|
|
@@ -98,14 +95,16 @@ export default {
|
|
|
98
95
|
this.uploadSuccess = true;
|
|
99
96
|
this.percent = 100;
|
|
100
97
|
setTimeout(() => {
|
|
101
|
-
this.percent = 0;
|
|
102
98
|
this.uploadSuccess = false;
|
|
99
|
+
this.percent = 0;
|
|
103
100
|
}, 500);
|
|
101
|
+
|
|
104
102
|
this.successCb && this.successCb(response, response.data, file);
|
|
105
103
|
callback && callback(response.data);
|
|
106
104
|
}).catch(error => {
|
|
107
|
-
this.percent = 0;
|
|
108
105
|
this.uploadSuccess = false;
|
|
106
|
+
this.percent = 0;
|
|
107
|
+
|
|
109
108
|
this.handleError && this.handleError(error, {}, file);
|
|
110
109
|
callback && callback(error);
|
|
111
110
|
});
|
|
@@ -245,7 +244,6 @@ export default {
|
|
|
245
244
|
callbackBodyType: "application/json",
|
|
246
245
|
callbackBody: this.transferCallBody(callbackBody)
|
|
247
246
|
};
|
|
248
|
-
|
|
249
247
|
let newOss = {
|
|
250
248
|
...res.ossConfig,
|
|
251
249
|
refreshSTSToken: async () => {
|
|
@@ -273,14 +271,16 @@ export default {
|
|
|
273
271
|
this.uploadSuccess = true;
|
|
274
272
|
this.percent = 100;
|
|
275
273
|
setTimeout(() => {
|
|
276
|
-
this.percent = 0;
|
|
277
274
|
this.uploadSuccess = false;
|
|
275
|
+
this.percent = 0;
|
|
278
276
|
}, 500);
|
|
277
|
+
|
|
279
278
|
this.successCb && this.successCb(response, response.data, file);
|
|
280
279
|
callback && callback(response.data);
|
|
281
280
|
}).catch((err, response) => {
|
|
282
|
-
this.percent = 0;
|
|
283
281
|
this.uploadSuccess = false;
|
|
282
|
+
this.percent = 0;
|
|
283
|
+
|
|
284
284
|
this.handleError && this.handleError(err, response, file);
|
|
285
285
|
callback && callback(err);
|
|
286
286
|
});
|
|
@@ -306,7 +306,6 @@ export default {
|
|
|
306
306
|
callbackBodyType: "application/json",
|
|
307
307
|
callbackBody: this.transferCallBody(callbackBody)
|
|
308
308
|
};
|
|
309
|
-
|
|
310
309
|
let newOss = {
|
|
311
310
|
...res.ossConfig,
|
|
312
311
|
refreshSTSToken: async () => {
|
|
@@ -331,17 +330,19 @@ export default {
|
|
|
331
330
|
"Content-Disposition": type === "pdf" ? `inline;filename=${encodeURI(file.name)}` : `attachment;filename=${encodeURI(file.name)}`
|
|
332
331
|
}
|
|
333
332
|
}).then(response => {
|
|
334
|
-
this.percent = 100;
|
|
335
333
|
this.uploadSuccess = true;
|
|
334
|
+
this.percent = 100;
|
|
336
335
|
setTimeout(() => {
|
|
337
|
-
this.percent = 0;
|
|
338
336
|
this.uploadSuccess = false;
|
|
337
|
+
this.percent = 0;
|
|
339
338
|
}, 500);
|
|
339
|
+
|
|
340
340
|
this.successCb && this.successCb(response, response.data, file);
|
|
341
341
|
callback && callback(response.data);
|
|
342
342
|
}).catch((err, response) => {
|
|
343
|
-
this.percent = 0;
|
|
344
343
|
this.uploadSuccess = false;
|
|
344
|
+
this.percent = 0;
|
|
345
|
+
|
|
345
346
|
this.handleError && this.handleError(err, response, file);
|
|
346
347
|
callback && callback(err);
|
|
347
348
|
});
|
|
@@ -375,17 +376,17 @@ export default {
|
|
|
375
376
|
return JSON.stringify(newObj);
|
|
376
377
|
},
|
|
377
378
|
// base64转换
|
|
378
|
-
base64Encode (
|
|
379
|
+
base64Encode (str) {
|
|
380
|
+
str = this.utf8Encode(str);
|
|
379
381
|
let _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
380
|
-
|
|
381
382
|
let output = "";
|
|
382
383
|
let chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
|
383
384
|
let i = 0;
|
|
384
|
-
|
|
385
|
-
while (i <
|
|
386
|
-
chr1 =
|
|
387
|
-
chr2 =
|
|
388
|
-
chr3 =
|
|
385
|
+
|
|
386
|
+
while (i < str.length) {
|
|
387
|
+
chr1 = str.charCodeAt(i++);
|
|
388
|
+
chr2 = str.charCodeAt(i++);
|
|
389
|
+
chr3 = str.charCodeAt(i++);
|
|
389
390
|
enc1 = chr1 >> 2;
|
|
390
391
|
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
|
391
392
|
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
|
@@ -399,6 +400,7 @@ export default {
|
|
|
399
400
|
_keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
|
|
400
401
|
_keyStr.charAt(enc3) + _keyStr.charAt(enc4);
|
|
401
402
|
}
|
|
403
|
+
|
|
402
404
|
return output;
|
|
403
405
|
},
|
|
404
406
|
utf8Encode (str) {
|
|
@@ -418,6 +420,7 @@ export default {
|
|
|
418
420
|
}
|
|
419
421
|
|
|
420
422
|
}
|
|
423
|
+
|
|
421
424
|
return utftext;
|
|
422
425
|
},
|
|
423
426
|
// base64转blob
|
|
@@ -428,13 +431,12 @@ export default {
|
|
|
428
431
|
} else {
|
|
429
432
|
byteString = unescape(base64Data.split(",")[1]);
|
|
430
433
|
}
|
|
434
|
+
|
|
431
435
|
// 获取文件类型
|
|
432
436
|
const mimeString = base64Data.split(";")[0].split(":")[1]; // mime类型
|
|
433
|
-
|
|
434
437
|
// ArrayBuffer 对象用来表示通用的、固定长度的原始二进制数据缓冲区
|
|
435
438
|
// let arrayBuffer = new ArrayBuffer(byteString.length) // 创建缓冲数组
|
|
436
439
|
// let uintArr = new Uint8Array(arrayBuffer) // 创建视图
|
|
437
|
-
|
|
438
440
|
const uintArr = new Uint8Array(byteString.length); // 创建视图
|
|
439
441
|
|
|
440
442
|
for (let i = 0; i < byteString.length; i += 1) {
|
|
@@ -444,6 +446,7 @@ export default {
|
|
|
444
446
|
const blob = new Blob([uintArr], {
|
|
445
447
|
type: mimeString
|
|
446
448
|
});
|
|
449
|
+
|
|
447
450
|
// 使用 Blob 创建一个指向类型化数组的URL, URL.createObjectURL是new Blob文件的方法,可以生成一个普通的url,可以直接使用,比如用在img.src上
|
|
448
451
|
return blob;
|
|
449
452
|
}
|
package/src/data/index.js
CHANGED