@aochuang/client-sdk 1.0.330 → 1.0.331

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.
@@ -71,13 +71,10 @@ export default {
71
71
  },
72
72
  computed: {
73
73
  url () {
74
- return this.nextContent.url || this.nextContent.resUrl
74
+ return this.nextContent.resPath || this.nextContent.url || this.nextContent.resUrl
75
75
  },
76
76
  name () {
77
- if (!this.nextContent.title) {
78
- return this.url
79
- }
80
- return this.nextContent.title
77
+ return this.nextContent.fileName || this.nextContent.title || this.url
81
78
  },
82
79
  size () {
83
80
  return this.nextContent.totalLen
@@ -198,14 +198,14 @@ export default {
198
198
  return this.allowDownload
199
199
  },
200
200
  showDownloadBox () {
201
- return this.type === 'default' && this.innerAllowDownload && this.isDownloadContent && !this.downloaded
201
+ return this.type === 'default' && this.innerAllowDownload && this.isDownloadContent && !this.nextContent.resPath && !this.downloaded
202
202
  },
203
203
  src () {
204
204
  if (typeof this.nextContent === 'string') {
205
205
  return this.nextContent
206
206
  }
207
207
  if (this.nextContent && typeof this.nextContent === 'object') {
208
- return this.nextContent.url || this.nextContent.thumbnailPath || this.nextContent.midThumbnailPath || ''
208
+ return this.nextContent.resPath || this.nextContent.url || this.nextContent.thumbnailPath || this.nextContent.midThumbnailPath || ''
209
209
  }
210
210
  return this.content
211
211
  },
@@ -285,6 +285,12 @@ export default {
285
285
  throw new Error('不支持的更新属性' + prop)
286
286
  }
287
287
  this.$set(this.nextContent, prop, value)
288
+ },
289
+ updateContentProps: (data) => {
290
+ if (!data || typeof data !== 'object' || Array.isArray(data)) {
291
+ throw new Error('updateContentProps只支持更新数据对象')
292
+ }
293
+ this.nextContent = data
288
294
  }
289
295
  })
290
296
  if (rs && rs.finally) {
@@ -31,6 +31,21 @@
31
31
  import { Popover as UiPopover } from '@aochuang/common/components'
32
32
  import { html2Escape } from '../../../utils/string'
33
33
 
34
+ function parseTextContent (content) {
35
+ if (typeof content !== 'string') {
36
+ return content
37
+ }
38
+ try {
39
+ const data = JSON.parse(content)
40
+ if (data && typeof data === 'object') {
41
+ return data
42
+ }
43
+ } catch (e) {
44
+ return content
45
+ }
46
+ return content
47
+ }
48
+
34
49
  export default {
35
50
  name: 'SdkChatControlText',
36
51
  components: {
@@ -63,23 +78,27 @@ export default {
63
78
  },
64
79
  computed: {
65
80
  nextContent () {
66
- return this.content
81
+ return parseTextContent(this.content)
67
82
  },
68
83
  text () {
84
+ if (this.nextContent && typeof this.nextContent === 'object') {
85
+ return this.nextContent.text || ''
86
+ }
69
87
  return this.nextContent
70
88
  },
71
89
  html () {
72
- let content = this.nextContent
90
+ let content = this.text
73
91
  if (this.formatter) {
74
92
  content = this.formatter({
75
93
  content: this.nextContent
76
94
  })
77
95
  } else {
78
- content = html2Escape(content)
96
+ content = html2Escape(String(content || ''))
79
97
  }
80
98
  if (!content) {
81
99
  return ''
82
100
  }
101
+ content = String(content)
83
102
  content = content.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, item => {
84
103
  return `<a href="${item}" target='_blank'>${item}</a>`
85
104
  })
@@ -66,6 +66,14 @@ function toJson (data) {
66
66
  return data
67
67
  }
68
68
 
69
+ function getTextContent (content) {
70
+ const data = typeof content === 'string' ? toJson(content) : content
71
+ if (data && typeof data === 'object') {
72
+ return data.text || ''
73
+ }
74
+ return content
75
+ }
76
+
69
77
  /**
70
78
  * 格式化为短消息
71
79
  */
@@ -73,10 +81,8 @@ export function formatShortMessage (msgType, msgContent) {
73
81
  let shortMessage = msgContent
74
82
  switch (msgType) {
75
83
  case MESSAGE_TYPE.TEXT:
76
- shortMessage = msgContent
77
- break
78
84
  case MESSAGE_TYPE.TEXT_W:
79
- shortMessage = msgContent
85
+ shortMessage = getTextContent(msgContent)
80
86
  break
81
87
  case MESSAGE_TYPE.TEXT_WITH_AT:
82
88
  let {atId, content, text} = toJson(msgContent) || {}
@@ -224,4 +230,4 @@ export function formatShortSessionMessage (session, contextFn) {
224
230
  }
225
231
  }
226
232
  return formatShortMessage(session.lastMsgType, session.lastMsgContent)
227
- }
233
+ }
@@ -147,7 +147,9 @@ export default {
147
147
  if (typeof this.nextContent === 'string') {
148
148
  url = this.nextContent
149
149
  } else if (this.nextContent && typeof this.nextContent === 'object') {
150
- if (this.nextContent.videoPath) {
150
+ if (this.nextContent.resPath) {
151
+ url = this.nextContent.resPath
152
+ } else if (this.nextContent.videoPath) {
151
153
  url = this.nextContent.videoPath
152
154
  } else {
153
155
  url = this.nextContent.tencentUrl
@@ -163,7 +165,7 @@ export default {
163
165
  if (!this.nextContent) {
164
166
  return
165
167
  }
166
- return this.nextContent.previewImgUrl
168
+ return this.nextContent.resCoverPath || this.nextContent.previewImgUrl
167
169
  },
168
170
  innerCover () {
169
171
  return formatOssPath(this.cover)
@@ -202,6 +204,12 @@ export default {
202
204
  throw new Error('不支持的更新属性' + prop)
203
205
  }
204
206
  this.$set(this.nextContent, prop, value)
207
+ },
208
+ updateContentProps: (data) => {
209
+ if (!data || typeof data !== 'object' || Array.isArray(data)) {
210
+ throw new Error('updateContentProps只支持更新数据对象')
211
+ }
212
+ this.nextContent = data
205
213
  }
206
214
  })
207
215
  if (rs && rs.finally) {
@@ -132,7 +132,7 @@ export default {
132
132
  return parse(this.content) || {}
133
133
  },
134
134
  voiceSrc () {
135
- let url = this.nextContent.url || this.nextContent.resUrl
135
+ let url = this.nextContent.voicePath || this.nextContent.url || this.nextContent.resUrl
136
136
  return url
137
137
  },
138
138
  nextId () {
@@ -45,12 +45,17 @@ export default {
45
45
  return this.controlConfig[msgType]
46
46
  },
47
47
  getMessageConfig (msgData) {
48
+ const controlConfig = this.getControlConfig(msgData.msgType)
48
49
  if (!this.messageConfig) {
49
- return
50
+ return controlConfig
50
51
  }
51
- return this.messageConfig({
52
+ const messageConfig = this.messageConfig({
52
53
  item: msgData
53
54
  })
55
+ if (!messageConfig) {
56
+ return controlConfig
57
+ }
58
+ return Object.assign({}, controlConfig, messageConfig)
54
59
  }
55
60
  }
56
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aochuang/client-sdk",
3
- "version": "1.0.330",
3
+ "version": "1.0.331",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"