askbot-dragon 1.7.26-beta → 1.7.28-beta
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 +4 -2
- package/src/assets/js/AliyunlssUtil.js +32 -9
- package/src/components/AnswerDocknowledge.vue +101 -93
- package/src/components/ConversationContainer.vue +6 -17
- package/src/components/MyEditor.vue +1 -10
- package/src/components/askVideo.vue +2 -2
- package/src/components/formTemplate.vue +4 -14
- package/src/components/imgView.vue +32 -0
- package/src/components/intelligentSummary.vue +14 -12
- package/src/components/markDownText.vue +164 -0
- package/src/components/pdfPosition.vue +66 -58
- package/src/components/previewPdf.vue +16 -21
- package/src/components/utils/AliyunIssUtil.js +33 -12
- package/src/components/utils/ckeditor.js +59 -48
- package/src/locales/cn.json +26 -0
- package/src/locales/en.json +26 -0
- package/src/main.js +16 -0
- package/src/components/QwFeedback.vue +0 -301
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div @click="lookImage">
|
|
3
|
+
<vue-markdown class="mark_down" :source="typedContent" :ref="'markdown' + msgId">
|
|
4
|
+
</vue-markdown>
|
|
5
|
+
<div v-if="showPreview">
|
|
6
|
+
<img-view :url-list="imgList" @closeViewer="closeViewer"></img-view>
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script>
|
|
12
|
+
import VueMarkdown from "vue-markdown";
|
|
13
|
+
import ImgView from "./imgView.vue";
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
name: "markDownText",
|
|
17
|
+
data() {
|
|
18
|
+
return {
|
|
19
|
+
typedContent: "",
|
|
20
|
+
typingSpeed: 15,
|
|
21
|
+
showPreview: false,
|
|
22
|
+
imgList: [],
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
props: {
|
|
26
|
+
chainValues: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: "",
|
|
29
|
+
},
|
|
30
|
+
msgId: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: "",
|
|
33
|
+
},
|
|
34
|
+
isHistory: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
components: {
|
|
40
|
+
ImgView,
|
|
41
|
+
VueMarkdown,
|
|
42
|
+
},
|
|
43
|
+
mounted() {
|
|
44
|
+
this.$nextTick(() => {
|
|
45
|
+
// let ref = 'markdown' + this.msgId
|
|
46
|
+
// const el = this.$refs[ref].$el;
|
|
47
|
+
// if (this.isHistory){
|
|
48
|
+
// el.innerHTML = this.chainValues;
|
|
49
|
+
// } else {
|
|
50
|
+
// new Typed(el, {
|
|
51
|
+
// strings: [this.chainValues],
|
|
52
|
+
// typeSpeed: 30,
|
|
53
|
+
// showCursor: false
|
|
54
|
+
// })
|
|
55
|
+
// }
|
|
56
|
+
this.typedContent = this.chainValues;
|
|
57
|
+
// if (this.isHistory) {
|
|
58
|
+
// this.typedContent = this.chainValues;
|
|
59
|
+
// } else {
|
|
60
|
+
// this.startTypingEffect();
|
|
61
|
+
// }
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
methods: {
|
|
65
|
+
startTypingEffect() {
|
|
66
|
+
let i = 0;
|
|
67
|
+
const interval = setInterval(() => {
|
|
68
|
+
if (i < this.chainValues.length) {
|
|
69
|
+
this.typedContent += this.chainValues.charAt(i);
|
|
70
|
+
i++;
|
|
71
|
+
} else {
|
|
72
|
+
clearInterval(interval);
|
|
73
|
+
}
|
|
74
|
+
}, this.typingSpeed);
|
|
75
|
+
},
|
|
76
|
+
lookImage(e) {
|
|
77
|
+
let previewImageUrl = "";
|
|
78
|
+
console.log("e.target", e.target);
|
|
79
|
+
if (e.target.localName == "img") {
|
|
80
|
+
previewImageUrl = e.target.currentSrc;
|
|
81
|
+
this.showPreview = true;
|
|
82
|
+
}
|
|
83
|
+
let richtext = JSON.parse(JSON.stringify(this.typedContent));
|
|
84
|
+
this.imgList = [];
|
|
85
|
+
richtext.replace(
|
|
86
|
+
/<img [^>]*src=['"]([^'"]+)[^>]*>/g,
|
|
87
|
+
(match, capture) => {
|
|
88
|
+
this.imgList.push(capture);
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
/*当前点击的图片作为第一个图片*/
|
|
92
|
+
let index = this.imgList.indexOf(previewImageUrl);
|
|
93
|
+
this.imgList.splice(index, 1);
|
|
94
|
+
this.imgList.unshift(previewImageUrl);
|
|
95
|
+
},
|
|
96
|
+
closeViewer() {
|
|
97
|
+
this.showPreview = false;
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<style scoped lang="less">
|
|
104
|
+
.mark_down {
|
|
105
|
+
line-height: 24px;
|
|
106
|
+
|
|
107
|
+
/deep/p {
|
|
108
|
+
margin-bottom: 14px;
|
|
109
|
+
font-size: 16px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/deep/p:only-child {
|
|
113
|
+
margin: 0 !important;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/deep/p:last-child {
|
|
117
|
+
margin-bottom: 0 !important;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/deep/ul {
|
|
121
|
+
margin-bottom: 16px ;
|
|
122
|
+
li {
|
|
123
|
+
margin: 7px 0 !important;
|
|
124
|
+
font-size: 16px;
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/deep/ ol {
|
|
130
|
+
li {
|
|
131
|
+
margin: 7px 0 !important;
|
|
132
|
+
font-size: 16px;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/deep/img {
|
|
137
|
+
max-width: 400px;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/deep/h3,
|
|
141
|
+
/deep/h2,
|
|
142
|
+
/deep/h1,
|
|
143
|
+
/deep/h4,
|
|
144
|
+
/deep/h5,
|
|
145
|
+
/deep/h6 {
|
|
146
|
+
color: #000000;
|
|
147
|
+
font-weight: 500;
|
|
148
|
+
line-height: 26px;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/deep/h3 {
|
|
152
|
+
font-size: 20px;
|
|
153
|
+
}
|
|
154
|
+
/deep/h2 {
|
|
155
|
+
font-size: 22px;
|
|
156
|
+
}
|
|
157
|
+
/deep/h1 {
|
|
158
|
+
font-size: 24px;
|
|
159
|
+
}
|
|
160
|
+
/deep/h3 {
|
|
161
|
+
font-size: 20px;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
</style>
|
|
@@ -1,29 +1,36 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="pdf_view" id="pdf_view">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
3
|
+
<div class="change_scale" v-if="isPC">
|
|
4
|
+
<section @click="changeScale('reduce')">
|
|
5
|
+
<i class="el-icon-minus"></i>
|
|
6
|
+
</section>
|
|
7
|
+
<el-divider direction="vertical"></el-divider>
|
|
8
|
+
<section @click="changeScale('zoom')">
|
|
9
|
+
<i class="el-icon-plus"></i>
|
|
10
|
+
</section>
|
|
11
|
+
<el-select size="small" v-model="handScale" @change="changeScale" :placeholder="$t('dragonCommon.selectScale')">
|
|
12
|
+
<el-option v-for="item in scaleList" :key="item.value" :label="item.label" :value="item.value">
|
|
13
|
+
</el-option>
|
|
14
|
+
</el-select>
|
|
15
|
+
</div>
|
|
16
|
+
<div class="pdf_container_view" id="pdf_container_view" @scroll="pdfScroll" ref="pdfView"></div>
|
|
17
|
+
<div class="btn_footer" v-if="tagIds.length > 1 && !isPC">
|
|
18
|
+
<div class="prev" @click="prev">{{ $t('dragonCommon.previous') }}</div>
|
|
19
|
+
<div class="next" @click="next">{{ $t('dragonCommon.next') }}</div>
|
|
20
|
+
</div>
|
|
21
|
+
<div id="pagination" v-if="tagIds.length > 1 && isPC">
|
|
22
|
+
<el-pagination
|
|
23
|
+
:current-page="currentPage + 1"
|
|
24
|
+
@current-change="currentChange"
|
|
25
|
+
@prev-click="prev"
|
|
26
|
+
@next-click="next"
|
|
27
|
+
layout="slot, prev, pager, next"
|
|
28
|
+
:page-size="1"
|
|
29
|
+
:total="tagIds.length"
|
|
30
|
+
>
|
|
31
|
+
<span class="total-class">{{ $t('dragonCommon.answersGeneratedByPre') }}{{tagIds.length}}{{ $t('dragonCommon.answersGeneratedByAfter') }}</span>
|
|
32
|
+
</el-pagination>
|
|
33
|
+
</div>
|
|
27
34
|
</div>
|
|
28
35
|
</template>
|
|
29
36
|
<script>
|
|
@@ -97,37 +104,7 @@ export default {
|
|
|
97
104
|
transformSalce: null,
|
|
98
105
|
isPC: false,
|
|
99
106
|
handScale: 'auto',
|
|
100
|
-
scaleList: [
|
|
101
|
-
{
|
|
102
|
-
label: '自动缩放',
|
|
103
|
-
value: 'auto'
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
label: '实际比例',
|
|
107
|
-
value: 'reality'
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
label: '100%',
|
|
111
|
-
value: 1
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
label: '120%',
|
|
115
|
-
value: 1.2
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
label: '150%',
|
|
119
|
-
value: 1.5
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
label: '170%',
|
|
123
|
-
value: 1.7
|
|
124
|
-
}
|
|
125
|
-
,
|
|
126
|
-
{
|
|
127
|
-
label: '200%',
|
|
128
|
-
value: 2
|
|
129
|
-
}
|
|
130
|
-
],
|
|
107
|
+
scaleList: [],
|
|
131
108
|
scrollTop: 0,
|
|
132
109
|
scrollLeft: 0
|
|
133
110
|
}
|
|
@@ -552,7 +529,7 @@ export default {
|
|
|
552
529
|
this.currentPage = 0
|
|
553
530
|
if (!this.isPC) {
|
|
554
531
|
this.$toast({
|
|
555
|
-
message: '
|
|
532
|
+
message: this.$t('dragonCommon.firstParagraph'),
|
|
556
533
|
duration: 2000,
|
|
557
534
|
})
|
|
558
535
|
return
|
|
@@ -571,7 +548,7 @@ export default {
|
|
|
571
548
|
this.currentPage = this.tagIds.length - 1
|
|
572
549
|
if (!this.isPC) {
|
|
573
550
|
this.$toast({
|
|
574
|
-
message: '
|
|
551
|
+
message: this.$t('dragonCommon.lastParagraph'),
|
|
575
552
|
duration: 2000,
|
|
576
553
|
})
|
|
577
554
|
return
|
|
@@ -1079,7 +1056,7 @@ export default {
|
|
|
1079
1056
|
}
|
|
1080
1057
|
} else {
|
|
1081
1058
|
let div = document.createElement('div')
|
|
1082
|
-
div.innerText = '
|
|
1059
|
+
div.innerText = this.$t('dragonCommon.fileloadException')
|
|
1083
1060
|
this.contentView.appendChild(div)
|
|
1084
1061
|
this.$refs.pdfView.appendChild(this.contentView)
|
|
1085
1062
|
}
|
|
@@ -1091,6 +1068,37 @@ export default {
|
|
|
1091
1068
|
}
|
|
1092
1069
|
},
|
|
1093
1070
|
mounted () {
|
|
1071
|
+
this.scaleList = [
|
|
1072
|
+
{
|
|
1073
|
+
label: this.$t('dragonCommon.scaleAuto'),
|
|
1074
|
+
value: 'auto'
|
|
1075
|
+
},
|
|
1076
|
+
{
|
|
1077
|
+
label: this.$t('dragonCommon.scaleReality'),
|
|
1078
|
+
value: 'reality'
|
|
1079
|
+
},
|
|
1080
|
+
{
|
|
1081
|
+
label: '100%',
|
|
1082
|
+
value: 1
|
|
1083
|
+
},
|
|
1084
|
+
{
|
|
1085
|
+
label: '120%',
|
|
1086
|
+
value: 1.2
|
|
1087
|
+
},
|
|
1088
|
+
{
|
|
1089
|
+
label: '150%',
|
|
1090
|
+
value: 1.5
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
label: '170%',
|
|
1094
|
+
value: 1.7
|
|
1095
|
+
}
|
|
1096
|
+
,
|
|
1097
|
+
{
|
|
1098
|
+
label: '200%',
|
|
1099
|
+
value: 2
|
|
1100
|
+
}
|
|
1101
|
+
]
|
|
1094
1102
|
if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) {
|
|
1095
1103
|
this.isPC = false
|
|
1096
1104
|
} else {
|
|
@@ -5,34 +5,33 @@
|
|
|
5
5
|
另外增加了在知识项目中预览当前文件的一些功能
|
|
6
6
|
-->
|
|
7
7
|
<template>
|
|
8
|
-
<el-drawer title="
|
|
8
|
+
<el-drawer title="" :visible.sync="drawer" :with-header="false" :append-to-body="true" :destroy-on-close="true"
|
|
9
9
|
:modal="false" :direction="previewShowPopup ? 'btt' : 'rtl'" :size="previewShowPopup ? '90%' : '65%'"
|
|
10
10
|
custom-class="pdf-preview-drawer" v-if="drawer">
|
|
11
|
-
<!-- v-else-if="drawer" -->
|
|
12
11
|
<div class="drawer-header" :class="isLiBang ? 'libang_head' : ''" v-if="!isPc">
|
|
13
12
|
<div class="header-btn btn_position">
|
|
14
13
|
<div class="onload_btn" v-if="isDownload" @click="downLoad">
|
|
15
|
-
|
|
14
|
+
{{ $t('dragonCommon.download') }}
|
|
16
15
|
</div>
|
|
17
16
|
<div class="summaryBtn" :class="showSummary ? 'summaryActiveBtn' : ''" @click="summaryFun" v-if="isHasChat">
|
|
18
17
|
<i class="iconfont guoran-tongyichicun-write-29-jiqiren"></i>
|
|
19
|
-
<span
|
|
18
|
+
<span>{{ $t('dragonCommon.smartSummary') }}</span>
|
|
20
19
|
</div>
|
|
21
20
|
<template v-if="isHasChat">
|
|
22
21
|
<div class="chat" @click="previewToDialog(true)" v-if="!previewKnowledgeId">
|
|
23
22
|
<i class="iconfont guoran-wendapingjia"></i>
|
|
24
|
-
|
|
23
|
+
{{ $t('dragonCommon.chat') }}
|
|
25
24
|
</div>
|
|
26
25
|
<div class="chat chat_active" @click="previewToDialog(false)" v-else>
|
|
27
26
|
<i class="iconfont guoran-wendapingjia"></i>
|
|
28
|
-
|
|
27
|
+
{{ $t('dragonCommon.chat') }}
|
|
29
28
|
</div>
|
|
30
29
|
</template>
|
|
31
30
|
</div>
|
|
32
31
|
<div class="header_title">
|
|
33
32
|
<div class="header_close">
|
|
34
33
|
<span class="title_left">
|
|
35
|
-
{{ title ? title :
|
|
34
|
+
{{ title ? title : $t('dragonCommon.viewDetails') }}
|
|
36
35
|
</span>
|
|
37
36
|
<section @click="close">
|
|
38
37
|
<i class="iconfont guoran-shanchu"></i>
|
|
@@ -49,25 +48,25 @@
|
|
|
49
48
|
<div class="header_title">
|
|
50
49
|
<div :class="isLiBang && folderName ? 'header_close' : 'header_top'">
|
|
51
50
|
<span class="title_left">
|
|
52
|
-
{{ title ? title :
|
|
51
|
+
{{ title ? title : $t('dragonCommon.viewDetails') }}
|
|
53
52
|
</span>
|
|
54
53
|
<div class="header-btn">
|
|
55
|
-
<div class="onload_btn" v-if="isDownload
|
|
56
|
-
|
|
54
|
+
<div class="onload_btn" v-if="isDownload" @click="downLoad">
|
|
55
|
+
{{ $t('dragonCommon.download') }}
|
|
57
56
|
</div>
|
|
58
57
|
<div class="summaryBtn" :class="showSummary ? 'summaryActiveBtn' : ''" @click="summaryFun"
|
|
59
|
-
v-if="isHasChat
|
|
58
|
+
v-if="isHasChat">
|
|
60
59
|
<i class="iconfont guoran-tongyichicun-write-29-jiqiren"></i>
|
|
61
|
-
<span
|
|
60
|
+
<span>{{ $t('dragonCommon.smartSummary') }}</span>
|
|
62
61
|
</div>
|
|
63
|
-
<template v-if="isHasChat
|
|
62
|
+
<template v-if="isHasChat">
|
|
64
63
|
<div class="chat" @click="previewToDialog(true)" v-if="!previewKnowledgeId">
|
|
65
64
|
<i class="iconfont guoran-wendapingjia"></i>
|
|
66
|
-
|
|
65
|
+
{{ $t('dragonCommon.chat') }}
|
|
67
66
|
</div>
|
|
68
67
|
<div class="chat chat_active" @click="previewToDialog(false)" v-else>
|
|
69
68
|
<i class="iconfont guoran-wendapingjia"></i>
|
|
70
|
-
|
|
69
|
+
{{ $t('dragonCommon.chat') }}
|
|
71
70
|
</div>
|
|
72
71
|
</template>
|
|
73
72
|
<section @click="close">
|
|
@@ -83,7 +82,6 @@
|
|
|
83
82
|
</div>
|
|
84
83
|
</div>
|
|
85
84
|
<div id="drawer_content_pre" :class="isLiBang && folderName ? 'libang_content_pre' : ''">
|
|
86
|
-
<!-- :style="{marginTop:tagIds && tagIds.length != 0 && isPc ? '50px' : ''}" -->
|
|
87
85
|
<intelligent-summary v-show="showSummary && isHasChat" :tagIds="tagIds" :knowledgeId="knowledgeId"
|
|
88
86
|
@closeSummary="closeSummary" @recommendQues="recommendQues"
|
|
89
87
|
@getSummarySuccess="getSummarySuccess"></intelligent-summary>
|
|
@@ -96,7 +94,7 @@
|
|
|
96
94
|
<video :src="url" controls width="100%;" height="98%"></video>
|
|
97
95
|
</div>
|
|
98
96
|
<div v-else-if="fileType == 'HTML'" style="width: 100%;">
|
|
99
|
-
<div class="preview_iframe_html" style="text-
|
|
97
|
+
<div class="preview_iframe_html" style="text-align:left" v-html="fileText"></div>
|
|
100
98
|
</div>
|
|
101
99
|
<template v-else-if="url.includes('https://www') || url.includes('http://www')">
|
|
102
100
|
<iframe class="preview_iframe" :src="url" width="100%" height="100%" scrolling="100%" frameborder="no"
|
|
@@ -107,9 +105,6 @@
|
|
|
107
105
|
:style="{ height: iframeHeight }"></iframe>
|
|
108
106
|
</template>
|
|
109
107
|
</template>
|
|
110
|
-
<!-- <div class="mobile_onload_btn" v-if="isDownload && !isPc" @click="downLoad">
|
|
111
|
-
下载
|
|
112
|
-
</div> -->
|
|
113
108
|
</div>
|
|
114
109
|
<div class="loading_img" v-show="loading">
|
|
115
110
|
<img src="https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif" alt="">
|
|
@@ -397,7 +392,7 @@ export default {
|
|
|
397
392
|
selection.addRange(range);
|
|
398
393
|
document.execCommand('copy');
|
|
399
394
|
selection.removeAllRanges()
|
|
400
|
-
Toast('
|
|
395
|
+
Toast(this.$t('dragonCommon.Safaridownload'));
|
|
401
396
|
this.close()
|
|
402
397
|
},100)
|
|
403
398
|
} else {
|
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
// const OSS = require('ali-oss');
|
|
2
2
|
const OSS = window.OSS
|
|
3
3
|
|
|
4
|
+
const getPrivateOssConfig = () => {
|
|
5
|
+
let mainSource = sessionStorage.getItem('_mainSource') ? sessionStorage.getItem('_mainSource') : "askbot";
|
|
6
|
+
switch (mainSource) {
|
|
7
|
+
case "askbot":
|
|
8
|
+
return {
|
|
9
|
+
region: "oss-cn-zhangjiakou",
|
|
10
|
+
accessKeyId: "LTAI4G3QtdEdwkEbihBngAsK",
|
|
11
|
+
accessKeySecret: "OwgdVfc5PeCkIgqIdug660xmiSPchn",
|
|
12
|
+
bucket: "guoranopen-zjk",
|
|
13
|
+
}
|
|
14
|
+
case "lishi":
|
|
15
|
+
return {
|
|
16
|
+
region: "oss-ap-southeast-1",
|
|
17
|
+
accessKeyId: "LTAI5tAusPLDNJJwkvUbqi2T",
|
|
18
|
+
accessKeySecret: "xqPVaunOIbvTe3g9qsXal2IZO6RftK",
|
|
19
|
+
bucket: "askbotopen-ls",
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
4
24
|
let IDX = 256, HEX = [], SIZE = 256, BUFFER;
|
|
5
25
|
while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);
|
|
6
26
|
let mainId = sessionStorage.getItem('_mainId') ? sessionStorage.getItem('_mainId') : "";
|
|
@@ -36,12 +56,12 @@ function pathGenerate(filename) {
|
|
|
36
56
|
}
|
|
37
57
|
|
|
38
58
|
|
|
39
|
-
|
|
40
|
-
let ossClient = new OSS(
|
|
59
|
+
function upload(data) {
|
|
60
|
+
let ossClient = new OSS(getPrivateOssConfig());
|
|
41
61
|
// object-key可以自定义为文件名(例如file.txt)或目录(例如abc/test/file.txt)的形式,实现将文件上传至当前Bucket或Bucket下的指定目录。
|
|
42
62
|
let objectKey = pathGenerate(data.name);
|
|
43
|
-
let result =
|
|
44
|
-
headers:{
|
|
63
|
+
let result = ossClient.put(objectKey, data, {
|
|
64
|
+
headers: {
|
|
45
65
|
// 通过文件URL访问文件时,指定以附件形式下载文件,下载后的文件名称定义为example.jpg。
|
|
46
66
|
'Content-Disposition': `attachment; filename="${encodeURIComponent(data.name)}"`
|
|
47
67
|
},
|
|
@@ -50,13 +70,13 @@ function pathGenerate(filename) {
|
|
|
50
70
|
return result;
|
|
51
71
|
}
|
|
52
72
|
|
|
53
|
-
|
|
54
|
-
let ossClient = new OSS(
|
|
73
|
+
function multipartUpload(data, callback, extCallback) {
|
|
74
|
+
let ossClient = new OSS(getPrivateOssConfig());
|
|
55
75
|
// object-key可以自定义为文件名(例如file.txt)或目录(例如abc/test/file.txt)的形式,实现将文件上传至当前Bucket或Bucket下的指定目录。
|
|
56
76
|
let objectKey = pathGenerate(data.name);
|
|
57
77
|
|
|
58
|
-
let res =
|
|
59
|
-
headers:{
|
|
78
|
+
let res = ossClient.multipartUpload(objectKey, data, {
|
|
79
|
+
headers: {
|
|
60
80
|
// 通过文件URL访问文件时,指定以附件形式下载文件,下载后的文件名称定义为example.jpg。
|
|
61
81
|
'Content-Disposition': `attachment; filename="${encodeURIComponent(data.name)}"`
|
|
62
82
|
},
|
|
@@ -64,14 +84,15 @@ function pathGenerate(filename) {
|
|
|
64
84
|
console.debug('progress callback', p, checkpoint);
|
|
65
85
|
// 断点记录点。浏览器重启后无法直接继续上传,您需要手动触发上传操作。
|
|
66
86
|
if (callback && callback instanceof Function) {
|
|
67
|
-
callback(p, checkpoint,data,extCallback);
|
|
87
|
+
callback(p, checkpoint, data, extCallback);
|
|
68
88
|
}
|
|
69
89
|
}
|
|
70
90
|
})
|
|
71
|
-
|
|
91
|
+
return res;
|
|
72
92
|
}
|
|
73
93
|
|
|
74
|
-
function ossFileUrl(
|
|
94
|
+
function ossFileUrl(path, cname) {
|
|
95
|
+
let ossConfig = getPrivateOssConfig();
|
|
75
96
|
if (cname == null) {
|
|
76
97
|
return 'https://' + ossConfig.bucket + '.' + ossConfig.region + '.aliyuncs.com/' + path;
|
|
77
98
|
} else {
|
|
@@ -79,4 +100,4 @@ function ossFileUrl(ossConfig, path, cname) {
|
|
|
79
100
|
}
|
|
80
101
|
}
|
|
81
102
|
|
|
82
|
-
export {upload, multipartUpload, ossFileUrl}
|
|
103
|
+
export { upload, multipartUpload, ossFileUrl }
|