@aochuang/client-sdk 1.0.354 → 1.0.355
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.
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
</div>
|
|
8
8
|
<div class="sdk-chat-wework-control-file-url__toolbar">
|
|
9
9
|
<span class="sdk-chat-wework-control-file-url__size" v-if="fileSize">{{fileSize}}</span>
|
|
10
|
-
|
|
11
|
-
<ui-button type="primary" link :click="handleDownloadClick"
|
|
12
|
-
|
|
10
|
+
<span class="sdk-chat-wework-control-file-url__download" v-if="canDownload" @click.stop.prevent>
|
|
11
|
+
<ui-button type="primary" link :loading="downloading" icon="download-line" :click="handleDownloadClick">
|
|
12
|
+
下载
|
|
13
|
+
</ui-button>
|
|
14
|
+
</span>
|
|
13
15
|
</div>
|
|
14
16
|
</span>
|
|
15
17
|
<span v-if="fileIcon" class="sdk-chat-wework-control-file-url__icon">
|
|
@@ -67,7 +69,8 @@ export default {
|
|
|
67
69
|
},
|
|
68
70
|
data () {
|
|
69
71
|
return {
|
|
70
|
-
nextContent: {}
|
|
72
|
+
nextContent: {},
|
|
73
|
+
downloading: false
|
|
71
74
|
}
|
|
72
75
|
},
|
|
73
76
|
computed: {
|
|
@@ -105,6 +108,9 @@ export default {
|
|
|
105
108
|
}
|
|
106
109
|
return this.allowDownload
|
|
107
110
|
},
|
|
111
|
+
canDownload () {
|
|
112
|
+
return this.type !== 'quote' && this.innerAllowDownload && typeof this.downloadMethod === 'function'
|
|
113
|
+
},
|
|
108
114
|
border () {
|
|
109
115
|
if (this.type === 'quote') {
|
|
110
116
|
return false
|
|
@@ -114,24 +120,37 @@ export default {
|
|
|
114
120
|
},
|
|
115
121
|
created () {
|
|
116
122
|
this.nextContent = parse(this.content) || {}
|
|
117
|
-
if (this.url && this.updateChatBoxProp) {
|
|
118
|
-
this.updateChatBoxProp('href', this.url)
|
|
119
|
-
}
|
|
120
123
|
},
|
|
121
124
|
methods: {
|
|
122
125
|
handleDownloadClick () {
|
|
123
|
-
if (!this.
|
|
126
|
+
if (!this.canDownload || this.downloading) {
|
|
124
127
|
return
|
|
125
128
|
}
|
|
126
|
-
|
|
129
|
+
const updateContent = data => {
|
|
130
|
+
if (!data || typeof data !== 'object' || Array.isArray(data)) {
|
|
131
|
+
throw new Error('updateContentProps只支持更新数据对象')
|
|
132
|
+
}
|
|
133
|
+
this.nextContent = data
|
|
134
|
+
this.$emit('content-update', data)
|
|
135
|
+
}
|
|
136
|
+
const result = this.downloadMethod({
|
|
127
137
|
content: this.nextContent,
|
|
128
138
|
updateContentProp: (prop, value) => {
|
|
129
|
-
if (!['url'].includes(prop)) {
|
|
139
|
+
if (!['resPath', 'url'].includes(prop)) {
|
|
130
140
|
throw new Error('不支持的更新属性' + prop)
|
|
131
141
|
}
|
|
132
142
|
this.$set(this.nextContent, prop, value)
|
|
133
|
-
|
|
143
|
+
this.$emit('content-update', this.nextContent)
|
|
144
|
+
},
|
|
145
|
+
updateContentProps: updateContent
|
|
134
146
|
})
|
|
147
|
+
if (result && result.finally) {
|
|
148
|
+
this.downloading = true
|
|
149
|
+
result.finally(() => {
|
|
150
|
+
this.downloading = false
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
return result
|
|
135
154
|
}
|
|
136
155
|
},
|
|
137
156
|
beforeDestroy () {
|
|
@@ -112,23 +112,15 @@ export function formatShortMessage (msgType, msgContent) {
|
|
|
112
112
|
case MESSAGE_TYPE.SYSTEM:
|
|
113
113
|
shortMessage = formatSystemMessage(msgContent)
|
|
114
114
|
break
|
|
115
|
-
case MESSAGE_TYPE.URL:
|
|
116
115
|
case MESSAGE_TYPE.URLFile:
|
|
116
|
+
shortMessage = '[文件消息]'
|
|
117
|
+
break
|
|
118
|
+
case MESSAGE_TYPE.URL:
|
|
117
119
|
case MESSAGE_TYPE.URLNew:
|
|
118
120
|
const jsonObj = toJson(msgContent)
|
|
119
121
|
if (typeof jsonObj === 'object') {
|
|
120
|
-
if(jsonObj.
|
|
121
|
-
shortMessage = '[文件消息]'
|
|
122
|
-
} else if(jsonObj.type === 'link') {
|
|
123
|
-
shortMessage = '[链接消息]'
|
|
124
|
-
} else if(jsonObj.type === 'miniprogram') {
|
|
122
|
+
if(jsonObj.contentType === 78) {
|
|
125
123
|
shortMessage = '[小程序消息]'
|
|
126
|
-
} else if (jsonObj.type === 'music') {
|
|
127
|
-
shortMessage = '[音乐消息]'
|
|
128
|
-
} else if (jsonObj.type === 'merged') {
|
|
129
|
-
shortMessage = '[合并消息]'
|
|
130
|
-
} else {
|
|
131
|
-
shortMessage = '[链接消息]'
|
|
132
124
|
}
|
|
133
125
|
} else {
|
|
134
126
|
shortMessage = '[链接消息]'
|