@aochuang/client-sdk 1.0.353 → 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
- <!-- <span class="sdk-chat-wework-control-file-url__download" v-if="innerAllowDownload" @click.stop.prevent>
11
- <ui-button type="primary" link :click="handleDownloadClick">下载</ui-button>
12
- </span> -->
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">
@@ -28,6 +30,7 @@
28
30
  import FileIcon from './icons'
29
31
  import { parse } from '../../../utils/json'
30
32
  import { formatFileSize } from '../../../utils/file'
33
+ import { formatOssPath } from '@aochuang/common/utils/oss'
31
34
 
32
35
  export default {
33
36
  name: 'SdkChatControlFileUrl',
@@ -66,12 +69,14 @@ export default {
66
69
  },
67
70
  data () {
68
71
  return {
69
- nextContent: {}
72
+ nextContent: {},
73
+ downloading: false
70
74
  }
71
75
  },
72
76
  computed: {
73
77
  url () {
74
- return this.nextContent.resPath || this.nextContent.url || this.nextContent.resUrl
78
+ const url = this.nextContent.resPath || this.nextContent.url || this.nextContent.resUrl
79
+ return url ? formatOssPath(url) : url
75
80
  },
76
81
  name () {
77
82
  return this.nextContent.fileName || this.nextContent.title || this.url
@@ -103,6 +108,9 @@ export default {
103
108
  }
104
109
  return this.allowDownload
105
110
  },
111
+ canDownload () {
112
+ return this.type !== 'quote' && this.innerAllowDownload && typeof this.downloadMethod === 'function'
113
+ },
106
114
  border () {
107
115
  if (this.type === 'quote') {
108
116
  return false
@@ -112,24 +120,37 @@ export default {
112
120
  },
113
121
  created () {
114
122
  this.nextContent = parse(this.content) || {}
115
- if (this.url && this.updateChatBoxProp) {
116
- this.updateChatBoxProp('href', this.url)
117
- }
118
123
  },
119
124
  methods: {
120
125
  handleDownloadClick () {
121
- if (!this.downloadMethod) {
126
+ if (!this.canDownload || this.downloading) {
122
127
  return
123
128
  }
124
- return this.downloadMethod({
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({
125
137
  content: this.nextContent,
126
138
  updateContentProp: (prop, value) => {
127
- if (!['url'].includes(prop)) {
139
+ if (!['resPath', 'url'].includes(prop)) {
128
140
  throw new Error('不支持的更新属性' + prop)
129
141
  }
130
142
  this.$set(this.nextContent, prop, value)
131
- }
143
+ this.$emit('content-update', this.nextContent)
144
+ },
145
+ updateContentProps: updateContent
132
146
  })
147
+ if (result && result.finally) {
148
+ this.downloading = true
149
+ result.finally(() => {
150
+ this.downloading = false
151
+ })
152
+ }
153
+ return result
133
154
  }
134
155
  },
135
156
  beforeDestroy () {
@@ -47,6 +47,7 @@ export const chatControls = {
47
47
  [MESSAGE_TYPE.VIDEO]: video,
48
48
  [MESSAGE_TYPE.CUSTOM_EXPRESSION]: customExpression,
49
49
  [MESSAGE_TYPE.LOCATION]: location,
50
+ [MESSAGE_TYPE.URLFile]: fileUrl,
50
51
  [MESSAGE_TYPE.URL]: url,
51
52
  [MESSAGE_TYPE.URLNew]: fileUrl,
52
53
  // [MESSAGE_TYPE.CALLING]: calling,
@@ -2,6 +2,7 @@ export const MESSAGE_TYPE = {
2
2
  TEXT: 0,
3
3
  TEXT_W: 1,
4
4
  IMAGE: 14,
5
+ URLFile: 15,
5
6
  VOICE: 16,
6
7
  VIDEO: 22,
7
8
  CUSTOM_EXPRESSION: 29,
@@ -111,22 +112,15 @@ export function formatShortMessage (msgType, msgContent) {
111
112
  case MESSAGE_TYPE.SYSTEM:
112
113
  shortMessage = formatSystemMessage(msgContent)
113
114
  break
115
+ case MESSAGE_TYPE.URLFile:
116
+ shortMessage = '[文件消息]'
117
+ break
114
118
  case MESSAGE_TYPE.URL:
115
119
  case MESSAGE_TYPE.URLNew:
116
120
  const jsonObj = toJson(msgContent)
117
121
  if (typeof jsonObj === 'object') {
118
- if(jsonObj.type === 'file') {
119
- shortMessage = '[文件消息]'
120
- } else if(jsonObj.type === 'link') {
121
- shortMessage = '[链接消息]'
122
- } else if(jsonObj.type === 'miniprogram') {
122
+ if(jsonObj.contentType === 78) {
123
123
  shortMessage = '[小程序消息]'
124
- } else if (jsonObj.type === 'music') {
125
- shortMessage = '[音乐消息]'
126
- } else if (jsonObj.type === 'merged') {
127
- shortMessage = '[合并消息]'
128
- } else {
129
- shortMessage = '[链接消息]'
130
124
  }
131
125
  } else {
132
126
  shortMessage = '[链接消息]'
@@ -289,6 +289,29 @@
289
289
  </template>
290
290
  </sdk-chat-panel-box>
291
291
  </template>
292
+ <template v-else-if="item.msgType == MESSAGE_TYPE.URLFile">
293
+ <sdk-chat-panel-box
294
+ :dir="dir"
295
+ :data="item"
296
+ :fetchUserMethod="fetchUserMethod"
297
+ bg-color="#fff"
298
+ br-color="#ddd"
299
+ @user-avatar-click="handleUserAvatarClick"
300
+ @user-avatar-contextmenu="handleUserAvatarContextmenu"
301
+ >
302
+ <template slot-scope="{ updateProp }">
303
+ <sdk-chat-control-file-url
304
+ v-bind="configData"
305
+ :id="item.id"
306
+ :content="msgContent"
307
+ :update-chat-box-prop="updateProp"
308
+ ></sdk-chat-control-file-url>
309
+ </template>
310
+ <template slot="append" slot-scope="{ updateProp }">
311
+ <slot name="chat-append" :item="item" :update-chat-box-prop="updateProp"></slot>
312
+ </template>
313
+ </sdk-chat-panel-box>
314
+ </template>
292
315
  <template v-else-if="item.msgType == MESSAGE_TYPE.URL || item.msgType == MESSAGE_TYPE.URLNew">
293
316
  <sdk-chat-panel-box
294
317
  :dir="dir"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aochuang/client-sdk",
3
- "version": "1.0.353",
3
+ "version": "1.0.355",
4
4
  "description": "",
5
5
  "files": [
6
6
  "common",