askbot-dragon 1.7.29-beta → 1.7.31-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 +2 -4
- package/src/assets/js/AliyunlssUtil.js +9 -32
- package/src/components/AiGuide.vue +1 -1
- package/src/components/AnswerDocknowledge.vue +257 -245
- package/src/components/ConversationContainer.vue +17 -6
- package/src/components/MyEditor.vue +11 -2
- package/src/components/QwFeedback.vue +302 -0
- package/src/components/actionSatisfaction.vue +2 -2
- package/src/components/answerRadio.vue +2 -2
- package/src/components/askVideo.vue +2 -2
- package/src/components/assetDetails.vue +1 -1
- package/src/components/assetMessage.vue +12 -10
- package/src/components/fielListView.vue +1 -1
- package/src/components/formTemplate.vue +14 -4
- package/src/components/intelligentSummary.vue +12 -14
- package/src/components/myPopup.vue +10 -10
- package/src/components/pdfPosition.vue +58 -66
- package/src/components/popup.vue +7 -7
- package/src/components/previewPdf.vue +21 -16
- package/src/components/receiverMessagePlatform.vue +19 -20
- package/src/components/senderMessagePlatform.vue +10 -15
- package/src/components/tree.vue +2 -2
- package/src/components/utils/AliyunIssUtil.js +12 -33
- package/src/components/utils/ckeditor.js +48 -59
- package/src/components/welcomeKnowledgeFile.vue +1 -1
- package/src/components/welcomeSuggest.vue +1 -1
- package/src/main.js +0 -16
- package/src/components/imgView.vue +0 -32
- package/src/components/markDownText.vue +0 -164
- package/src/locales/cn.json +0 -60
- package/src/locales/en.json +0 -60
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="container">
|
|
3
3
|
<div class="top-container">
|
|
4
|
-
<div class="close"
|
|
5
|
-
<div class="sure"
|
|
4
|
+
<div class="close">取消</div>
|
|
5
|
+
<div class="sure">确定</div>
|
|
6
6
|
</div>
|
|
7
|
-
<van-list
|
|
8
|
-
v-model="loading"
|
|
9
|
-
:finished="finished"
|
|
10
|
-
:finished-text="$t('dragonCommon.noMore')"
|
|
11
|
-
:offset="1"
|
|
12
|
-
@load="onLoad"
|
|
13
|
-
class="list-container"
|
|
14
|
-
>
|
|
7
|
+
<van-list v-model="loading" :finished="finished" finished-text="没有更多了" :offset="1" @load="onload" class="list-container">
|
|
15
8
|
<van-cell v-for="item in list" :key="item.id" :title="item.name" />
|
|
9
|
+
<!-- <van-cell title="123" />
|
|
10
|
+
<van-cell title="asdasd" />
|
|
11
|
+
<van-cell title="adszx" />
|
|
12
|
+
<van-cell title="zxc zc" />
|
|
13
|
+
<van-cell title="asdasd" />
|
|
14
|
+
<van-cell title="wqeqweqwe" />
|
|
15
|
+
<van-cell title="icvbncvbn" /> -->
|
|
16
16
|
</van-list>
|
|
17
17
|
</div>
|
|
18
18
|
</template>
|
|
@@ -1,36 +1,29 @@
|
|
|
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
|
-
|
|
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>
|
|
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="请选择">
|
|
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">上一段</div>
|
|
19
|
+
<div class="next" @click="next">下一段</div>
|
|
20
|
+
</div>
|
|
21
|
+
<div id="pagination" v-if="tagIds.length > 1 && isPC">
|
|
22
|
+
<el-pagination :current-page="currentPage + 1" @current-change="currentChange" @prev-click="prev"
|
|
23
|
+
@next-click="next" layout="slot, prev, pager, next" :page-size="1" :total="tagIds.length">
|
|
24
|
+
<span class="total-class">答案由{{ tagIds.length }}段内容生成</span>
|
|
25
|
+
</el-pagination>
|
|
26
|
+
</div>
|
|
34
27
|
</div>
|
|
35
28
|
</template>
|
|
36
29
|
<script>
|
|
@@ -104,7 +97,37 @@ export default {
|
|
|
104
97
|
transformSalce: null,
|
|
105
98
|
isPC: false,
|
|
106
99
|
handScale: 'auto',
|
|
107
|
-
scaleList: [
|
|
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
|
+
],
|
|
108
131
|
scrollTop: 0,
|
|
109
132
|
scrollLeft: 0
|
|
110
133
|
}
|
|
@@ -529,7 +552,7 @@ export default {
|
|
|
529
552
|
this.currentPage = 0
|
|
530
553
|
if (!this.isPC) {
|
|
531
554
|
this.$toast({
|
|
532
|
-
message:
|
|
555
|
+
message: '当前已经是第一段了',
|
|
533
556
|
duration: 2000,
|
|
534
557
|
})
|
|
535
558
|
return
|
|
@@ -548,7 +571,7 @@ export default {
|
|
|
548
571
|
this.currentPage = this.tagIds.length - 1
|
|
549
572
|
if (!this.isPC) {
|
|
550
573
|
this.$toast({
|
|
551
|
-
message:
|
|
574
|
+
message: '当前已经是最后一段了',
|
|
552
575
|
duration: 2000,
|
|
553
576
|
})
|
|
554
577
|
return
|
|
@@ -1056,7 +1079,7 @@ export default {
|
|
|
1056
1079
|
}
|
|
1057
1080
|
} else {
|
|
1058
1081
|
let div = document.createElement('div')
|
|
1059
|
-
div.innerText =
|
|
1082
|
+
div.innerText = '文件加载异常'
|
|
1060
1083
|
this.contentView.appendChild(div)
|
|
1061
1084
|
this.$refs.pdfView.appendChild(this.contentView)
|
|
1062
1085
|
}
|
|
@@ -1068,37 +1091,6 @@ export default {
|
|
|
1068
1091
|
}
|
|
1069
1092
|
},
|
|
1070
1093
|
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
|
-
]
|
|
1102
1094
|
if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) {
|
|
1103
1095
|
this.isPC = false
|
|
1104
1096
|
} else {
|
package/src/components/popup.vue
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="popUp">
|
|
3
3
|
<div class="topBtn">
|
|
4
|
-
<span class="cancel" @click="closeBtn"
|
|
5
|
-
<span class="sure" @click="sure"
|
|
4
|
+
<span class="cancel" @click="closeBtn">取消</span>
|
|
5
|
+
<span class="sure" @click="sure">确定</span>
|
|
6
6
|
</div>
|
|
7
7
|
<slot name="popup-header" class="popup-header"></slot>
|
|
8
8
|
<div class="popup-content">
|
|
9
9
|
<div
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
class="filter-item"
|
|
11
|
+
v-for="(item,index) in options"
|
|
12
|
+
:key="index"
|
|
13
|
+
@click="checked(item,index)"
|
|
14
14
|
>
|
|
15
|
-
<div :class="[checkIdList.includes(item[props.value]) && 'setColor', 'label']">{{
|
|
15
|
+
<div :class="[checkIdList.includes(item[props.value]) && 'setColor', 'label']">{{item[props.label]}}</div>
|
|
16
16
|
</div>
|
|
17
17
|
</div>
|
|
18
18
|
<div class="popup-footer">
|
|
@@ -5,33 +5,34 @@
|
|
|
5
5
|
另外增加了在知识项目中预览当前文件的一些功能
|
|
6
6
|
-->
|
|
7
7
|
<template>
|
|
8
|
-
<el-drawer title="" :visible.sync="drawer" :with-header="false" :append-to-body="true" :destroy-on-close="true"
|
|
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" -->
|
|
11
12
|
<div class="drawer-header" :class="isLiBang ? 'libang_head' : ''" v-if="!isPc">
|
|
12
13
|
<div class="header-btn btn_position">
|
|
13
14
|
<div class="onload_btn" v-if="isDownload" @click="downLoad">
|
|
14
|
-
|
|
15
|
+
下载
|
|
15
16
|
</div>
|
|
16
17
|
<div class="summaryBtn" :class="showSummary ? 'summaryActiveBtn' : ''" @click="summaryFun" v-if="isHasChat">
|
|
17
18
|
<i class="iconfont guoran-tongyichicun-write-29-jiqiren"></i>
|
|
18
|
-
<span
|
|
19
|
+
<span>智能摘要</span>
|
|
19
20
|
</div>
|
|
20
21
|
<template v-if="isHasChat">
|
|
21
22
|
<div class="chat" @click="previewToDialog(true)" v-if="!previewKnowledgeId">
|
|
22
23
|
<i class="iconfont guoran-wendapingjia"></i>
|
|
23
|
-
|
|
24
|
+
聊一聊
|
|
24
25
|
</div>
|
|
25
26
|
<div class="chat chat_active" @click="previewToDialog(false)" v-else>
|
|
26
27
|
<i class="iconfont guoran-wendapingjia"></i>
|
|
27
|
-
|
|
28
|
+
聊一聊
|
|
28
29
|
</div>
|
|
29
30
|
</template>
|
|
30
31
|
</div>
|
|
31
32
|
<div class="header_title">
|
|
32
33
|
<div class="header_close">
|
|
33
34
|
<span class="title_left">
|
|
34
|
-
{{ title ? title :
|
|
35
|
+
{{ title ? title : "查看详情" }}
|
|
35
36
|
</span>
|
|
36
37
|
<section @click="close">
|
|
37
38
|
<i class="iconfont guoran-shanchu"></i>
|
|
@@ -48,25 +49,25 @@
|
|
|
48
49
|
<div class="header_title">
|
|
49
50
|
<div :class="isLiBang && folderName ? 'header_close' : 'header_top'">
|
|
50
51
|
<span class="title_left">
|
|
51
|
-
{{ title ? title :
|
|
52
|
+
{{ title ? title : "查看详情" }}
|
|
52
53
|
</span>
|
|
53
54
|
<div class="header-btn">
|
|
54
|
-
<div class="onload_btn" v-if="isDownload" @click="downLoad">
|
|
55
|
-
|
|
55
|
+
<div class="onload_btn" v-if="isDownload || true" @click="downLoad">
|
|
56
|
+
下载
|
|
56
57
|
</div>
|
|
57
58
|
<div class="summaryBtn" :class="showSummary ? 'summaryActiveBtn' : ''" @click="summaryFun"
|
|
58
|
-
v-if="isHasChat">
|
|
59
|
+
v-if="isHasChat || true">
|
|
59
60
|
<i class="iconfont guoran-tongyichicun-write-29-jiqiren"></i>
|
|
60
|
-
<span
|
|
61
|
+
<span>智能摘要</span>
|
|
61
62
|
</div>
|
|
62
|
-
<template v-if="isHasChat">
|
|
63
|
+
<template v-if="isHasChat || true">
|
|
63
64
|
<div class="chat" @click="previewToDialog(true)" v-if="!previewKnowledgeId">
|
|
64
65
|
<i class="iconfont guoran-wendapingjia"></i>
|
|
65
|
-
|
|
66
|
+
聊一聊
|
|
66
67
|
</div>
|
|
67
68
|
<div class="chat chat_active" @click="previewToDialog(false)" v-else>
|
|
68
69
|
<i class="iconfont guoran-wendapingjia"></i>
|
|
69
|
-
|
|
70
|
+
聊一聊
|
|
70
71
|
</div>
|
|
71
72
|
</template>
|
|
72
73
|
<section @click="close">
|
|
@@ -82,6 +83,7 @@
|
|
|
82
83
|
</div>
|
|
83
84
|
</div>
|
|
84
85
|
<div id="drawer_content_pre" :class="isLiBang && folderName ? 'libang_content_pre' : ''">
|
|
86
|
+
<!-- :style="{marginTop:tagIds && tagIds.length != 0 && isPc ? '50px' : ''}" -->
|
|
85
87
|
<intelligent-summary v-show="showSummary && isHasChat" :tagIds="tagIds" :knowledgeId="knowledgeId"
|
|
86
88
|
@closeSummary="closeSummary" @recommendQues="recommendQues"
|
|
87
89
|
@getSummarySuccess="getSummarySuccess"></intelligent-summary>
|
|
@@ -94,7 +96,7 @@
|
|
|
94
96
|
<video :src="url" controls width="100%;" height="98%"></video>
|
|
95
97
|
</div>
|
|
96
98
|
<div v-else-if="fileType == 'HTML'" style="width: 100%;">
|
|
97
|
-
<div class="preview_iframe_html" style="text-
|
|
99
|
+
<div class="preview_iframe_html" style="text-algin:left" v-html="fileText"></div>
|
|
98
100
|
</div>
|
|
99
101
|
<template v-else-if="url.includes('https://www') || url.includes('http://www')">
|
|
100
102
|
<iframe class="preview_iframe" :src="url" width="100%" height="100%" scrolling="100%" frameborder="no"
|
|
@@ -105,6 +107,9 @@
|
|
|
105
107
|
:style="{ height: iframeHeight }"></iframe>
|
|
106
108
|
</template>
|
|
107
109
|
</template>
|
|
110
|
+
<!-- <div class="mobile_onload_btn" v-if="isDownload && !isPc" @click="downLoad">
|
|
111
|
+
下载
|
|
112
|
+
</div> -->
|
|
108
113
|
</div>
|
|
109
114
|
<div class="loading_img" v-show="loading">
|
|
110
115
|
<img src="https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif" alt="">
|
|
@@ -392,7 +397,7 @@ export default {
|
|
|
392
397
|
selection.addRange(range);
|
|
393
398
|
document.execCommand('copy');
|
|
394
399
|
selection.removeAllRanges()
|
|
395
|
-
Toast(
|
|
400
|
+
Toast('下载地址已复制,请前往Safari浏览器访问下载');
|
|
396
401
|
this.close()
|
|
397
402
|
},100)
|
|
398
403
|
} else {
|
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
<span v-if="messagePlateform == 'IM'">
|
|
4
|
+
与
|
|
5
|
+
<span :class="payload.newSession.receiverId == userId ? '':'text_color'">
|
|
6
|
+
{{payload.newSession.receiverId == userId ? '您': payload.newSession.receiverDisplayInfo.name}}
|
|
7
|
+
</span>
|
|
8
|
+
建立对话
|
|
9
|
+
</span>
|
|
10
|
+
<span v-if="messagePlateform == 'BOT'">
|
|
11
|
+
与机器人【
|
|
12
|
+
<span class="text_color">{{payload.newSession.receiverDisplayInfo.name}}</span>
|
|
13
|
+
】建立对话
|
|
14
|
+
</span>
|
|
15
|
+
<span v-if="messagePlateform == 'oldTransfer' && (isShow == true || isShow === null)">
|
|
16
|
+
您将会话转接给 <span class="text_color">{{payload.newSession.receiverDisplayInfo.name}}</span>
|
|
17
|
+
</span>
|
|
18
|
+
<span v-if="messagePlateform == 'newTransfer' && (isShow == true || isShow === null)">
|
|
19
|
+
<span class="text_color">{{payload.oldSession.receiverDisplayInfo.name}}</span> 将会话转接给您
|
|
7
20
|
</span>
|
|
8
|
-
{{ $t('dragonCommon.establishConversationWith') }}
|
|
9
|
-
</span>
|
|
10
|
-
<span v-if="messagePlateform == 'BOT'">
|
|
11
|
-
{{ $t('dragonCommon.establishConversationWith') }}
|
|
12
|
-
<span class="text_color">{{ $t('dragonCommon.bot') }}【{{ payload.newSession.receiverDisplayInfo.name }}】</span>
|
|
13
|
-
{{ $t('dragonCommon.establishConversationWith') }}
|
|
14
|
-
</span>
|
|
15
|
-
<span v-if="messagePlateform == 'oldTransfer' && (isShow == true || isShow === null)">
|
|
16
|
-
{{ $t('dragonCommon.transferTo') }}
|
|
17
|
-
<span class="text_color">{{ payload.newSession.receiverDisplayInfo.name }}</span>
|
|
18
|
-
</span>
|
|
19
|
-
<span v-if="messagePlateform == 'newTransfer' && (isShow == true || isShow === null)">
|
|
20
|
-
<span class="text_color">{{ payload.oldSession.receiverDisplayInfo.name }}</span>
|
|
21
|
-
{{ $t('dragonCommon.transferFrom') }}
|
|
22
|
-
</span>
|
|
23
21
|
</div>
|
|
24
|
-
|
|
22
|
+
</template>
|
|
23
|
+
|
|
25
24
|
<script>
|
|
26
25
|
// 客服 的接入消息展示
|
|
27
26
|
export default {
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<span
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<span v-if="messagePlateform == 'Transfer' && (isShow === true || isShow === null)">
|
|
13
|
-
<span class="text_color">{{ payload.oldSession.receiverDisplayInfo.name }}</span>
|
|
14
|
-
{{ $t('dragonCommon.transferTo') }}
|
|
15
|
-
<span class="text_color">{{ payload.newSession.receiverDisplayInfo.name }}</span>
|
|
16
|
-
</span>
|
|
3
|
+
<span v-if="messagePlateform == 'IM'">
|
|
4
|
+
IM人工 <span class="text_color">{{payload.newSession.receiverDisplayInfo.name}}</span> 将为您服务
|
|
5
|
+
</span>
|
|
6
|
+
<span v-if="messagePlateform == 'BOT'">
|
|
7
|
+
<span class="text_color">{{payload.newSession.receiverDisplayInfo.name}}</span> 将为您服务
|
|
8
|
+
</span>
|
|
9
|
+
<span v-if="messagePlateform == 'Transfer' && (isShow === true || isShow === null)">
|
|
10
|
+
<span class="text_color">{{payload.oldSession.receiverDisplayInfo.name}}</span> 将会话转接给 <span class="text_color">{{payload.newSession.receiverDisplayInfo.name}}</span>
|
|
11
|
+
</span>
|
|
17
12
|
</div>
|
|
18
|
-
|
|
13
|
+
</template>
|
|
19
14
|
|
|
20
15
|
<script>
|
|
21
16
|
// 咨询者的接入消息展示
|
package/src/components/tree.vue
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div id="tree">
|
|
3
3
|
<div class="tree-header">
|
|
4
|
-
<span class="cacel" @click="cancelBtn"
|
|
5
|
-
<span class="primary" @click="saveData"
|
|
4
|
+
<span class="cacel" @click="cancelBtn">取消</span>
|
|
5
|
+
<span class="primary" @click="saveData">确认</span>
|
|
6
6
|
</div>
|
|
7
7
|
<div class="tree-input" v-if="setCascadeOption && setCascadeOption.length > 0">
|
|
8
8
|
<el-input placeholder="请搜索" v-model="filterText">
|
|
@@ -1,26 +1,6 @@
|
|
|
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
|
-
|
|
24
4
|
let IDX = 256, HEX = [], SIZE = 256, BUFFER;
|
|
25
5
|
while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);
|
|
26
6
|
let mainId = sessionStorage.getItem('_mainId') ? sessionStorage.getItem('_mainId') : "";
|
|
@@ -56,12 +36,12 @@ function pathGenerate(filename) {
|
|
|
56
36
|
}
|
|
57
37
|
|
|
58
38
|
|
|
59
|
-
function upload(data) {
|
|
60
|
-
let ossClient = new OSS(
|
|
39
|
+
function upload(ossConfig, data) {
|
|
40
|
+
let ossClient = new OSS(ossConfig);
|
|
61
41
|
// object-key可以自定义为文件名(例如file.txt)或目录(例如abc/test/file.txt)的形式,实现将文件上传至当前Bucket或Bucket下的指定目录。
|
|
62
42
|
let objectKey = pathGenerate(data.name);
|
|
63
|
-
let result =
|
|
64
|
-
headers:
|
|
43
|
+
let result = ossClient.put(objectKey, data, {
|
|
44
|
+
headers:{
|
|
65
45
|
// 通过文件URL访问文件时,指定以附件形式下载文件,下载后的文件名称定义为example.jpg。
|
|
66
46
|
'Content-Disposition': `attachment; filename="${encodeURIComponent(data.name)}"`
|
|
67
47
|
},
|
|
@@ -70,13 +50,13 @@ function upload(data) {
|
|
|
70
50
|
return result;
|
|
71
51
|
}
|
|
72
52
|
|
|
73
|
-
function multipartUpload(data, callback,
|
|
74
|
-
let ossClient = new OSS(
|
|
53
|
+
function multipartUpload(ossConfig, data, callback,extCallback) {
|
|
54
|
+
let ossClient = new OSS(ossConfig);
|
|
75
55
|
// object-key可以自定义为文件名(例如file.txt)或目录(例如abc/test/file.txt)的形式,实现将文件上传至当前Bucket或Bucket下的指定目录。
|
|
76
56
|
let objectKey = pathGenerate(data.name);
|
|
77
57
|
|
|
78
|
-
let res =
|
|
79
|
-
headers:
|
|
58
|
+
let res = ossClient.multipartUpload(objectKey, data, {
|
|
59
|
+
headers:{
|
|
80
60
|
// 通过文件URL访问文件时,指定以附件形式下载文件,下载后的文件名称定义为example.jpg。
|
|
81
61
|
'Content-Disposition': `attachment; filename="${encodeURIComponent(data.name)}"`
|
|
82
62
|
},
|
|
@@ -84,15 +64,14 @@ function multipartUpload(data, callback, extCallback) {
|
|
|
84
64
|
console.debug('progress callback', p, checkpoint);
|
|
85
65
|
// 断点记录点。浏览器重启后无法直接继续上传,您需要手动触发上传操作。
|
|
86
66
|
if (callback && callback instanceof Function) {
|
|
87
|
-
callback(p, checkpoint,
|
|
67
|
+
callback(p, checkpoint,data,extCallback);
|
|
88
68
|
}
|
|
89
69
|
}
|
|
90
70
|
})
|
|
91
|
-
|
|
71
|
+
return res;
|
|
92
72
|
}
|
|
93
73
|
|
|
94
|
-
function ossFileUrl(path, cname) {
|
|
95
|
-
let ossConfig = getPrivateOssConfig();
|
|
74
|
+
function ossFileUrl(ossConfig, path, cname) {
|
|
96
75
|
if (cname == null) {
|
|
97
76
|
return 'https://' + ossConfig.bucket + '.' + ossConfig.region + '.aliyuncs.com/' + path;
|
|
98
77
|
} else {
|
|
@@ -100,4 +79,4 @@ function ossFileUrl(path, cname) {
|
|
|
100
79
|
}
|
|
101
80
|
}
|
|
102
81
|
|
|
103
|
-
export {
|
|
82
|
+
export {upload, multipartUpload, ossFileUrl}
|