@aochuang/client-sdk 1.0.356 → 1.0.358
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/components/wework-chat-control/voice/voice.vue +59 -4
- package/package.json +1 -1
- package/components/wechat-chat-control/.DS_Store +0 -0
- package/components/wechat-chat-control/transfer/.DS_Store +0 -0
- package/components/wechat-chat-control/url/.DS_Store +0 -0
- package/components/wechat-chat-control/voice/.DS_Store +0 -0
- package/components/wework-chat-control/link/.DS_Store +0 -0
- package/components/wework-chat-control/video/.DS_Store +0 -0
|
@@ -20,10 +20,11 @@
|
|
|
20
20
|
ref="player"
|
|
21
21
|
:id="nextId"
|
|
22
22
|
:url="voiceSrc"
|
|
23
|
+
:get-url-method="getUrlMethod"
|
|
23
24
|
:enable-convert-to-wav="enableConvertToWav"
|
|
24
25
|
:update-wav-method="updateWavMethod"
|
|
25
26
|
:seconds="voiceDuration"
|
|
26
|
-
:allow-download="
|
|
27
|
+
:allow-download="canDownload"
|
|
27
28
|
></ac-voice-player>
|
|
28
29
|
</div>
|
|
29
30
|
</div>
|
|
@@ -53,6 +54,7 @@
|
|
|
53
54
|
import { parse } from '../../../utils/json'
|
|
54
55
|
import { unique } from '../../../utils/string'
|
|
55
56
|
import AcVoicePlayer from '@aochuang/common/common/voice-player'
|
|
57
|
+
import { formatOssPath } from '@aochuang/common/utils/oss'
|
|
56
58
|
|
|
57
59
|
const ConvertStatusEnum = {
|
|
58
60
|
NORMAL: -1, // 没有转换
|
|
@@ -100,6 +102,9 @@ export default {
|
|
|
100
102
|
type: Boolean,
|
|
101
103
|
default: true
|
|
102
104
|
},
|
|
105
|
+
downloadMethod: {
|
|
106
|
+
type: Function
|
|
107
|
+
},
|
|
103
108
|
transformVoiceToTextEnable: {
|
|
104
109
|
type: Boolean,
|
|
105
110
|
default: false
|
|
@@ -120,6 +125,7 @@ export default {
|
|
|
120
125
|
},
|
|
121
126
|
data () {
|
|
122
127
|
return {
|
|
128
|
+
downloadedContent: null,
|
|
123
129
|
transformStatus: typeof this.convertStatus === 'number' ? this.convertStatus : ConvertStatusEnum.NORMAL,
|
|
124
130
|
playRate: 1,
|
|
125
131
|
transforming: false,
|
|
@@ -129,11 +135,17 @@ export default {
|
|
|
129
135
|
},
|
|
130
136
|
computed: {
|
|
131
137
|
nextContent () {
|
|
132
|
-
return parse(this.content) || {}
|
|
138
|
+
return this.downloadedContent || parse(this.content) || {}
|
|
133
139
|
},
|
|
134
140
|
voiceSrc () {
|
|
135
|
-
|
|
136
|
-
|
|
141
|
+
if (typeof this.nextContent === 'string') {
|
|
142
|
+
return this.nextContent
|
|
143
|
+
}
|
|
144
|
+
const voiceSrc = this.nextContent.resPath || this.nextContent.voicePath || this.nextContent.url || ''
|
|
145
|
+
if (!voiceSrc) {
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
return formatOssPath(voiceSrc)
|
|
137
149
|
},
|
|
138
150
|
nextId () {
|
|
139
151
|
return this.id || unique()
|
|
@@ -141,6 +153,9 @@ export default {
|
|
|
141
153
|
voiceDuration () {
|
|
142
154
|
return this.nextContent.durationMs ? this.nextContent.durationMs : null
|
|
143
155
|
},
|
|
156
|
+
canDownload () {
|
|
157
|
+
return this.allowDownload && !!this.nextContent.resPath
|
|
158
|
+
},
|
|
144
159
|
isPlaying () {
|
|
145
160
|
return this.AcVoice.isPlaying(this.id)
|
|
146
161
|
},
|
|
@@ -169,6 +184,46 @@ export default {
|
|
|
169
184
|
}
|
|
170
185
|
},
|
|
171
186
|
methods: {
|
|
187
|
+
getUrlMethod () {
|
|
188
|
+
const content = this.nextContent
|
|
189
|
+
const currentUrl = typeof content === 'string'
|
|
190
|
+
? content
|
|
191
|
+
: content.resPath || content.url
|
|
192
|
+
if (currentUrl) {
|
|
193
|
+
return Promise.resolve(currentUrl)
|
|
194
|
+
}
|
|
195
|
+
if (!this.downloadMethod) {
|
|
196
|
+
return Promise.reject(new Error('未找到语音下载方法'))
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const updateContentProps = (data) => {
|
|
200
|
+
if (!data || typeof data !== 'object' || Array.isArray(data)) {
|
|
201
|
+
throw new Error('updateContentProps只支持更新数据对象')
|
|
202
|
+
}
|
|
203
|
+
this.downloadedContent = data
|
|
204
|
+
return data
|
|
205
|
+
}
|
|
206
|
+
const result = this.downloadMethod({
|
|
207
|
+
content,
|
|
208
|
+
updateContentProp: (prop, value) => updateContentProps(Object.assign({}, this.nextContent, {[prop]: value})),
|
|
209
|
+
updateContentProps
|
|
210
|
+
})
|
|
211
|
+
return Promise.resolve(result).then((data) => {
|
|
212
|
+
const resultContent = typeof data === 'string' ? {url: data} : data
|
|
213
|
+
const url = resultContent && (resultContent.resPath || resultContent.url)
|
|
214
|
+
if (url) {
|
|
215
|
+
return url
|
|
216
|
+
}
|
|
217
|
+
const nextContent = this.nextContent
|
|
218
|
+
const nextUrl = typeof nextContent === 'string'
|
|
219
|
+
? nextContent
|
|
220
|
+
: nextContent.resPath || nextContent.url
|
|
221
|
+
if (nextUrl) {
|
|
222
|
+
return nextUrl
|
|
223
|
+
}
|
|
224
|
+
throw new Error('语音下载未返回有效地址')
|
|
225
|
+
})
|
|
226
|
+
},
|
|
172
227
|
handleTransformClick () {
|
|
173
228
|
if (this.transformVoiceToTextMethod) {
|
|
174
229
|
this.transforming = true
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|