askbot-dragon 0.6.17 → 0.6.21
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/README.md +27 -27
- package/babel.config.js +5 -5
- package/dragon.iml +7 -7
- package/package.json +54 -52
- package/public/index.html +27 -26
- package/src/App.vue +31 -31
- package/src/api/index.js +1 -1
- package/src/api/mock.http +2 -2
- package/src/api/requestUrl.js +185 -185
- package/src/assets/less/common.css +6760 -6760
- package/src/assets/less/converSationContainer/common.less +4751 -4751
- package/src/assets/less/converSationContainer/converSatonContainer.less +492 -492
- package/src/assets/less/ticketMessage.less +319 -319
- package/src/components/ActionAlertIframe.vue +117 -117
- package/src/components/AskIFrame.vue +15 -15
- package/src/components/ConversationContainer.vue +1388 -1388
- package/src/components/FileType.vue +88 -88
- package/src/components/Message.vue +27 -27
- package/src/components/ask-components/DissatisfactionOptions.vue +57 -57
- package/src/components/ask-components/Msgloading.vue +37 -37
- package/src/components/ask-components/SatisfactionV2.vue +15 -15
- package/src/components/chatContent.vue +512 -512
- package/src/components/feedBack.vue +133 -133
- package/src/components/file/AliyunOssComponents.vue +109 -109
- package/src/components/formTemplate.vue +1898 -2039
- package/src/components/message/ActionAlertIframe.vue +116 -116
- package/src/components/message/ShopMessage.vue +168 -168
- package/src/components/message/TextMessage.vue +895 -895
- package/src/components/message/TicketMessage.vue +173 -173
- package/src/components/message/swiper/index.js +4 -4
- package/src/components/message/swiper/ticketSwiper.vue +530 -530
- package/src/components/message/swiper/ticketSwiperItem.vue +61 -61
- package/src/components/selector/hOption.vue +20 -20
- package/src/components/selector/hSelector.vue +199 -199
- package/src/components/selector/hWrapper.vue +216 -216
- package/src/components/source/BotMessage.vue +24 -24
- package/src/components/source/CustomMessage.vue +24 -24
- package/src/components/test.vue +260 -260
- package/src/components/utils/AliyunIssUtil.js +72 -72
- package/src/components/utils/ckeditor.js +124 -0
- package/src/components/utils/format_date.js +18 -18
- package/src/components/utils/index.js +6 -6
- package/src/components/utils/math_utils.js +15 -15
- package/src/main.js +44 -43
- package/vue.config.js +34 -28
|
@@ -1,134 +1,134 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div id="feedBack" class="companyNotRem" :class="{phoneClass:isPhone,companyClass:isCompany,notClick:isDisabled===true}">
|
|
3
|
-
<span class="marginRight" >
|
|
4
|
-
<el-button round class="btnClass" @click="positiveFeedback(feedBack,1)" v-html="feedBack.positiveFeedback.text" v-if="positiveClick ===false">{{feedBack.positiveFeedback.text}}</el-button>
|
|
5
|
-
<el-button round class="btnClassActive" v-html="feedBack.positiveFeedback.text" v-if="positiveClick ===true">{{feedBack.positiveFeedback.text}}</el-button>
|
|
6
|
-
</span>
|
|
7
|
-
<span class="marginRight">
|
|
8
|
-
<el-button round class="btnClass" @click="positiveFeedback(feedBack,2)" v-html="feedBack.negativeFeedback.text" v-if="negativeClick ===false">{{feedBack.negativeFeedback.text}}</el-button>
|
|
9
|
-
<el-button round class="btnClassActive" v-html="feedBack.negativeFeedback.text" v-if="negativeClick ===true">{{feedBack.negativeFeedback.text}}</el-button>
|
|
10
|
-
</span>
|
|
11
|
-
</div>
|
|
12
|
-
</template>
|
|
13
|
-
<script>
|
|
14
|
-
export default {
|
|
15
|
-
name: "feedBack",
|
|
16
|
-
data(){
|
|
17
|
-
return{
|
|
18
|
-
isPhone:false,
|
|
19
|
-
isCompany:false,
|
|
20
|
-
isDisabled:false,
|
|
21
|
-
positiveClick:false,
|
|
22
|
-
negativeClick:false
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
props:{
|
|
26
|
-
feedBack:Object,
|
|
27
|
-
rem:String,
|
|
28
|
-
disable:Boolean,
|
|
29
|
-
},
|
|
30
|
-
beforeMount() {
|
|
31
|
-
if(this.disable===true)
|
|
32
|
-
{
|
|
33
|
-
this.isDisabled=true
|
|
34
|
-
}
|
|
35
|
-
else
|
|
36
|
-
{
|
|
37
|
-
this.isDisabled=false
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
mounted() {
|
|
41
|
-
this.isMobile()
|
|
42
|
-
console.log(this.disable)
|
|
43
|
-
},
|
|
44
|
-
methods:{
|
|
45
|
-
isMobile() {
|
|
46
|
-
let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
|
|
47
|
-
if (flag) {
|
|
48
|
-
this.isPhone=true
|
|
49
|
-
}
|
|
50
|
-
else
|
|
51
|
-
{
|
|
52
|
-
this.isCompany=true
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
positiveFeedback(Feedback,index){
|
|
56
|
-
let feedbackObj={};
|
|
57
|
-
let feedback={};
|
|
58
|
-
if(index===1)
|
|
59
|
-
{
|
|
60
|
-
feedbackObj['positiveFeedback']=Feedback.positiveFeedback;
|
|
61
|
-
feedback['feedback']=feedbackObj;
|
|
62
|
-
feedback['feedbackActions']=Feedback.feedbackActions
|
|
63
|
-
feedback['feedbackUid']=Feedback.feedbackUid
|
|
64
|
-
this.positiveClick=true
|
|
65
|
-
}
|
|
66
|
-
else if(index === 2)
|
|
67
|
-
{
|
|
68
|
-
feedbackObj['negativeFeedback']=Feedback.negativeFeedback;
|
|
69
|
-
feedback['feedback']=feedbackObj;
|
|
70
|
-
feedback['feedbackActions']=Feedback.feedbackActions
|
|
71
|
-
feedback['feedbackUid']=Feedback.feedbackUid
|
|
72
|
-
this.negativeClick=true
|
|
73
|
-
}
|
|
74
|
-
feedback.feedbackUid = this.feedBack.feedbackUid;
|
|
75
|
-
console.log(feedback)
|
|
76
|
-
feedback.apiKey=this.feedBack.apiKey
|
|
77
|
-
this.$emit('positiveFeedback',feedback,this.feedBack.apiKey);
|
|
78
|
-
this.isDisabled=true
|
|
79
|
-
},
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
</script>
|
|
83
|
-
|
|
84
|
-
<style scoped lang="less">
|
|
85
|
-
|
|
86
|
-
.phoneClass{
|
|
87
|
-
width: 100vw;
|
|
88
|
-
text-align: center;
|
|
89
|
-
margin: 0 auto;
|
|
90
|
-
line-height: 56px;
|
|
91
|
-
.marginRight{
|
|
92
|
-
margin-right: 10px;
|
|
93
|
-
margin-left: 10px;
|
|
94
|
-
}
|
|
95
|
-
.el-button{
|
|
96
|
-
min-width: 60px;
|
|
97
|
-
height: 36px;
|
|
98
|
-
line-height: 0.9;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
.btnClass{
|
|
102
|
-
color: #4C61E1;
|
|
103
|
-
border-color: #4C61E1
|
|
104
|
-
}
|
|
105
|
-
.btnClassActive{
|
|
106
|
-
color: #ffffff;
|
|
107
|
-
background-color: #4C61E1
|
|
108
|
-
}
|
|
109
|
-
.companyClass{
|
|
110
|
-
/* min-width: 300px;*/
|
|
111
|
-
width: 370px;
|
|
112
|
-
text-align: center;
|
|
113
|
-
margin: 0 auto;
|
|
114
|
-
line-height: 56px;
|
|
115
|
-
.marginRight{
|
|
116
|
-
margin-right: 10px;
|
|
117
|
-
margin-left: 10px;
|
|
118
|
-
}
|
|
119
|
-
.el-button{
|
|
120
|
-
min-width: 60px;
|
|
121
|
-
height: 36px;
|
|
122
|
-
line-height: 0.9;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
.notClick{
|
|
126
|
-
pointer-events: none;
|
|
127
|
-
}
|
|
128
|
-
.positiveActive{
|
|
129
|
-
color: red;
|
|
130
|
-
}
|
|
131
|
-
.negativeActive{
|
|
132
|
-
color: red;
|
|
133
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<div id="feedBack" class="companyNotRem" :class="{phoneClass:isPhone,companyClass:isCompany,notClick:isDisabled===true}">
|
|
3
|
+
<span class="marginRight" >
|
|
4
|
+
<el-button round class="btnClass" @click="positiveFeedback(feedBack,1)" v-html="feedBack.positiveFeedback.text" v-if="positiveClick ===false">{{feedBack.positiveFeedback.text}}</el-button>
|
|
5
|
+
<el-button round class="btnClassActive" v-html="feedBack.positiveFeedback.text" v-if="positiveClick ===true">{{feedBack.positiveFeedback.text}}</el-button>
|
|
6
|
+
</span>
|
|
7
|
+
<span class="marginRight">
|
|
8
|
+
<el-button round class="btnClass" @click="positiveFeedback(feedBack,2)" v-html="feedBack.negativeFeedback.text" v-if="negativeClick ===false">{{feedBack.negativeFeedback.text}}</el-button>
|
|
9
|
+
<el-button round class="btnClassActive" v-html="feedBack.negativeFeedback.text" v-if="negativeClick ===true">{{feedBack.negativeFeedback.text}}</el-button>
|
|
10
|
+
</span>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
<script>
|
|
14
|
+
export default {
|
|
15
|
+
name: "feedBack",
|
|
16
|
+
data(){
|
|
17
|
+
return{
|
|
18
|
+
isPhone:false,
|
|
19
|
+
isCompany:false,
|
|
20
|
+
isDisabled:false,
|
|
21
|
+
positiveClick:false,
|
|
22
|
+
negativeClick:false
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
props:{
|
|
26
|
+
feedBack:Object,
|
|
27
|
+
rem:String,
|
|
28
|
+
disable:Boolean,
|
|
29
|
+
},
|
|
30
|
+
beforeMount() {
|
|
31
|
+
if(this.disable===true)
|
|
32
|
+
{
|
|
33
|
+
this.isDisabled=true
|
|
34
|
+
}
|
|
35
|
+
else
|
|
36
|
+
{
|
|
37
|
+
this.isDisabled=false
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
mounted() {
|
|
41
|
+
this.isMobile()
|
|
42
|
+
console.log(this.disable)
|
|
43
|
+
},
|
|
44
|
+
methods:{
|
|
45
|
+
isMobile() {
|
|
46
|
+
let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
|
|
47
|
+
if (flag) {
|
|
48
|
+
this.isPhone=true
|
|
49
|
+
}
|
|
50
|
+
else
|
|
51
|
+
{
|
|
52
|
+
this.isCompany=true
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
positiveFeedback(Feedback,index){
|
|
56
|
+
let feedbackObj={};
|
|
57
|
+
let feedback={};
|
|
58
|
+
if(index===1)
|
|
59
|
+
{
|
|
60
|
+
feedbackObj['positiveFeedback']=Feedback.positiveFeedback;
|
|
61
|
+
feedback['feedback']=feedbackObj;
|
|
62
|
+
feedback['feedbackActions']=Feedback.feedbackActions
|
|
63
|
+
feedback['feedbackUid']=Feedback.feedbackUid
|
|
64
|
+
this.positiveClick=true
|
|
65
|
+
}
|
|
66
|
+
else if(index === 2)
|
|
67
|
+
{
|
|
68
|
+
feedbackObj['negativeFeedback']=Feedback.negativeFeedback;
|
|
69
|
+
feedback['feedback']=feedbackObj;
|
|
70
|
+
feedback['feedbackActions']=Feedback.feedbackActions
|
|
71
|
+
feedback['feedbackUid']=Feedback.feedbackUid
|
|
72
|
+
this.negativeClick=true
|
|
73
|
+
}
|
|
74
|
+
feedback.feedbackUid = this.feedBack.feedbackUid;
|
|
75
|
+
console.log(feedback)
|
|
76
|
+
feedback.apiKey=this.feedBack.apiKey
|
|
77
|
+
this.$emit('positiveFeedback',feedback,this.feedBack.apiKey);
|
|
78
|
+
this.isDisabled=true
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<style scoped lang="less">
|
|
85
|
+
|
|
86
|
+
.phoneClass{
|
|
87
|
+
width: 100vw;
|
|
88
|
+
text-align: center;
|
|
89
|
+
margin: 0 auto;
|
|
90
|
+
line-height: 56px;
|
|
91
|
+
.marginRight{
|
|
92
|
+
margin-right: 10px;
|
|
93
|
+
margin-left: 10px;
|
|
94
|
+
}
|
|
95
|
+
.el-button{
|
|
96
|
+
min-width: 60px;
|
|
97
|
+
height: 36px;
|
|
98
|
+
line-height: 0.9;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
.btnClass{
|
|
102
|
+
color: #4C61E1;
|
|
103
|
+
border-color: #4C61E1
|
|
104
|
+
}
|
|
105
|
+
.btnClassActive{
|
|
106
|
+
color: #ffffff;
|
|
107
|
+
background-color: #4C61E1
|
|
108
|
+
}
|
|
109
|
+
.companyClass{
|
|
110
|
+
/* min-width: 300px;*/
|
|
111
|
+
width: 370px;
|
|
112
|
+
text-align: center;
|
|
113
|
+
margin: 0 auto;
|
|
114
|
+
line-height: 56px;
|
|
115
|
+
.marginRight{
|
|
116
|
+
margin-right: 10px;
|
|
117
|
+
margin-left: 10px;
|
|
118
|
+
}
|
|
119
|
+
.el-button{
|
|
120
|
+
min-width: 60px;
|
|
121
|
+
height: 36px;
|
|
122
|
+
line-height: 0.9;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
.notClick{
|
|
126
|
+
pointer-events: none;
|
|
127
|
+
}
|
|
128
|
+
.positiveActive{
|
|
129
|
+
color: red;
|
|
130
|
+
}
|
|
131
|
+
.negativeActive{
|
|
132
|
+
color: red;
|
|
133
|
+
}
|
|
134
134
|
</style>
|
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
<!-- TODO 暂时不使用组件,请使用js工具类 AliyunIssUtil.js -->
|
|
2
|
-
<template>
|
|
3
|
-
|
|
4
|
-
<div class="aliyun-oss-components">
|
|
5
|
-
<input type="file" v-on:change="fileChange" ref="inputer">
|
|
6
|
-
</div>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script>
|
|
10
|
-
import {uid} from 'uid';
|
|
11
|
-
|
|
12
|
-
const OSS = require('ali-oss');
|
|
13
|
-
|
|
14
|
-
Date.prototype.Format = function (fmt) {
|
|
15
|
-
const o = {
|
|
16
|
-
"M+": this.getMonth() + 1, //月份
|
|
17
|
-
"d+": this.getDate(), //日
|
|
18
|
-
"h+": this.getHours(), //小时
|
|
19
|
-
"m+": this.getMinutes(), //分
|
|
20
|
-
"s+": this.getSeconds(), //秒
|
|
21
|
-
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
|
|
22
|
-
"S": this.getMilliseconds() //毫秒
|
|
23
|
-
};
|
|
24
|
-
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
|
|
25
|
-
for (const k in o)
|
|
26
|
-
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
|
|
27
|
-
return fmt;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export default {
|
|
32
|
-
name: "AliyunOssComponents",
|
|
33
|
-
data() {
|
|
34
|
-
return {
|
|
35
|
-
file: null,
|
|
36
|
-
ossClient: null
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
props: {
|
|
40
|
-
// Aliyun OSS 配置
|
|
41
|
-
ossConfig: {
|
|
42
|
-
type: Object,
|
|
43
|
-
default: function () {
|
|
44
|
-
return {
|
|
45
|
-
region: "",
|
|
46
|
-
//云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,创建并使用STS方式来进行API访问
|
|
47
|
-
accessKeyId: "",
|
|
48
|
-
accessKeySecret: "",
|
|
49
|
-
bucket: ""
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
// 路径生成函数
|
|
54
|
-
pathGenerate: {
|
|
55
|
-
type: Function,
|
|
56
|
-
default: function (filename) {
|
|
57
|
-
return "front-oss/" + new Date().Format("yyyy/MM/dd/hh/mm/") + uid(32) + "/" + filename;
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
data: [Blob, Buffer, File]
|
|
61
|
-
},
|
|
62
|
-
mounted() {
|
|
63
|
-
console.debug(this.ossConfig);
|
|
64
|
-
this.ossClient = new OSS(this.ossConfig);
|
|
65
|
-
},
|
|
66
|
-
methods: {
|
|
67
|
-
fileChange() {
|
|
68
|
-
let inputDOM = this.$refs.inputer;
|
|
69
|
-
// 通过DOM取文件数据
|
|
70
|
-
// this.file = ;
|
|
71
|
-
console.debug('file change', inputDOM.files);
|
|
72
|
-
this.putObject(inputDOM.files[0]);
|
|
73
|
-
this.multipartUpload(inputDOM.files[0]);
|
|
74
|
-
},
|
|
75
|
-
/**
|
|
76
|
-
*
|
|
77
|
-
* @param data
|
|
78
|
-
* @return {Promise<null|void>}
|
|
79
|
-
*/
|
|
80
|
-
async putObject(data) {
|
|
81
|
-
// object-key可以自定义为文件名(例如file.txt)或目录(例如abc/test/file.txt)的形式,实现将文件上传至当前Bucket或Bucket下的指定目录。
|
|
82
|
-
let objectKey = this.pathGenerate(data.name);
|
|
83
|
-
let result = await this.ossClient.put(objectKey, data);
|
|
84
|
-
console.log(result);
|
|
85
|
-
return result;
|
|
86
|
-
|
|
87
|
-
},
|
|
88
|
-
async multipartUpload(data, callback) {
|
|
89
|
-
// object-key可以自定义为文件名(例如file.txt)或目录(例如abc/test/file.txt)的形式,实现将文件上传至当前Bucket或Bucket下的指定目录。
|
|
90
|
-
let objectKey = this.pathGenerate(data.name);
|
|
91
|
-
let res = await this.ossClient.multipartUpload(objectKey, data, {
|
|
92
|
-
progress: function (p, checkpoint) {
|
|
93
|
-
console.debug('progress callback', p, checkpoint);
|
|
94
|
-
// 断点记录点。浏览器重启后无法直接继续上传,您需要手动触发上传操作。
|
|
95
|
-
if (callback && callback instanceof Function) {
|
|
96
|
-
callback(p, checkpoint);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
return res;
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
</script>
|
|
107
|
-
|
|
108
|
-
<style scoped>
|
|
109
|
-
|
|
1
|
+
<!-- TODO 暂时不使用组件,请使用js工具类 AliyunIssUtil.js -->
|
|
2
|
+
<template>
|
|
3
|
+
|
|
4
|
+
<div class="aliyun-oss-components">
|
|
5
|
+
<input type="file" v-on:change="fileChange" ref="inputer">
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
import {uid} from 'uid';
|
|
11
|
+
|
|
12
|
+
const OSS = require('ali-oss');
|
|
13
|
+
|
|
14
|
+
Date.prototype.Format = function (fmt) {
|
|
15
|
+
const o = {
|
|
16
|
+
"M+": this.getMonth() + 1, //月份
|
|
17
|
+
"d+": this.getDate(), //日
|
|
18
|
+
"h+": this.getHours(), //小时
|
|
19
|
+
"m+": this.getMinutes(), //分
|
|
20
|
+
"s+": this.getSeconds(), //秒
|
|
21
|
+
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
|
|
22
|
+
"S": this.getMilliseconds() //毫秒
|
|
23
|
+
};
|
|
24
|
+
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
|
|
25
|
+
for (const k in o)
|
|
26
|
+
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
|
|
27
|
+
return fmt;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
name: "AliyunOssComponents",
|
|
33
|
+
data() {
|
|
34
|
+
return {
|
|
35
|
+
file: null,
|
|
36
|
+
ossClient: null
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
props: {
|
|
40
|
+
// Aliyun OSS 配置
|
|
41
|
+
ossConfig: {
|
|
42
|
+
type: Object,
|
|
43
|
+
default: function () {
|
|
44
|
+
return {
|
|
45
|
+
region: "",
|
|
46
|
+
//云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,创建并使用STS方式来进行API访问
|
|
47
|
+
accessKeyId: "",
|
|
48
|
+
accessKeySecret: "",
|
|
49
|
+
bucket: ""
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
// 路径生成函数
|
|
54
|
+
pathGenerate: {
|
|
55
|
+
type: Function,
|
|
56
|
+
default: function (filename) {
|
|
57
|
+
return "front-oss/" + new Date().Format("yyyy/MM/dd/hh/mm/") + uid(32) + "/" + filename;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
data: [Blob, Buffer, File]
|
|
61
|
+
},
|
|
62
|
+
mounted() {
|
|
63
|
+
console.debug(this.ossConfig);
|
|
64
|
+
this.ossClient = new OSS(this.ossConfig);
|
|
65
|
+
},
|
|
66
|
+
methods: {
|
|
67
|
+
fileChange() {
|
|
68
|
+
let inputDOM = this.$refs.inputer;
|
|
69
|
+
// 通过DOM取文件数据
|
|
70
|
+
// this.file = ;
|
|
71
|
+
console.debug('file change', inputDOM.files);
|
|
72
|
+
this.putObject(inputDOM.files[0]);
|
|
73
|
+
this.multipartUpload(inputDOM.files[0]);
|
|
74
|
+
},
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* @param data
|
|
78
|
+
* @return {Promise<null|void>}
|
|
79
|
+
*/
|
|
80
|
+
async putObject(data) {
|
|
81
|
+
// object-key可以自定义为文件名(例如file.txt)或目录(例如abc/test/file.txt)的形式,实现将文件上传至当前Bucket或Bucket下的指定目录。
|
|
82
|
+
let objectKey = this.pathGenerate(data.name);
|
|
83
|
+
let result = await this.ossClient.put(objectKey, data);
|
|
84
|
+
console.log(result);
|
|
85
|
+
return result;
|
|
86
|
+
|
|
87
|
+
},
|
|
88
|
+
async multipartUpload(data, callback) {
|
|
89
|
+
// object-key可以自定义为文件名(例如file.txt)或目录(例如abc/test/file.txt)的形式,实现将文件上传至当前Bucket或Bucket下的指定目录。
|
|
90
|
+
let objectKey = this.pathGenerate(data.name);
|
|
91
|
+
let res = await this.ossClient.multipartUpload(objectKey, data, {
|
|
92
|
+
progress: function (p, checkpoint) {
|
|
93
|
+
console.debug('progress callback', p, checkpoint);
|
|
94
|
+
// 断点记录点。浏览器重启后无法直接继续上传,您需要手动触发上传操作。
|
|
95
|
+
if (callback && callback instanceof Function) {
|
|
96
|
+
callback(p, checkpoint);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
return res;
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
</script>
|
|
107
|
+
|
|
108
|
+
<style scoped>
|
|
109
|
+
|
|
110
110
|
</style>
|