@aochuang/client-sdk 1.0.343 → 1.0.344

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.
Files changed (141) hide show
  1. package/components/index.js +6 -1
  2. package/components/session-select/session-select-item.vue +8 -9
  3. package/components/wechat-chat-control/calling/calling.vue +0 -3
  4. package/components/wechat-chat-control/voice/voice.vue +0 -4
  5. package/components/wework-chat-control/company-card/company-card.vue +1 -1
  6. package/components/wework-chat-control/file-url/file-url.vue +2 -5
  7. package/components/wework-chat-control/image/image.vue +137 -2
  8. package/components/wework-chat-control/index.js +6 -6
  9. package/components/wework-chat-control/text/text.vue +22 -3
  10. package/components/wework-chat-control/util.js +12 -6
  11. package/components/wework-chat-control/video/video.vue +10 -2
  12. package/components/wework-chat-control/voice/voice.vue +1 -1
  13. package/components/wework-chat-control/wework-chat-control-config-item.vue +24 -0
  14. package/components/wework-chat-control/wework-chat-control-config-msg.vue +25 -0
  15. package/{uni-components/chat-control/chat-control-config.vue → components/wework-chat-control/wework-chat-control-config.vue} +16 -13
  16. package/components/wework-chat-panel/chat-panel-chat-status/chat-panel-chat-status.vue +73 -0
  17. package/components/wework-chat-panel/chat-panel-item.vue +12 -35
  18. package/components/wework-chat-panel/chat-panel.vue +95 -12
  19. package/package.json +10 -3
  20. package/services/client-chat/client-chat-wechat/client-chat-session.js +3 -4
  21. package/services/client-chat/client-chat-wechat/client-chat.js +8 -20
  22. package/services/client-chat/client-chat-wework/client-chat-concats.js +81 -17
  23. package/services/client-chat/client-chat-wework/client-chat-message.js +5 -5
  24. package/services/client-chat/client-chat-wework/client-chat-session.js +50 -2
  25. package/services/client-chat/client-chat-wework/client-chat-socket.js +9 -1
  26. package/services/client-chat/client-chat-wework/client-chat.js +278 -11
  27. package/services/client-chat/client-chat-wework/utils.js +5 -5
  28. package/components/wework-chat-panel/chat-panel-controls/company-card/company-card.vue +0 -35
  29. package/components/wework-chat-panel/chat-panel-controls/expression/expression.vue +0 -36
  30. package/components/wework-chat-panel/chat-panel-controls/file-url/file-url.vue +0 -35
  31. package/components/wework-chat-panel/chat-panel-controls/image/image.vue +0 -36
  32. package/components/wework-chat-panel/chat-panel-controls/index.js +0 -35
  33. package/components/wework-chat-panel/chat-panel-controls/jx-sys-text/jx-sys-text.vue +0 -28
  34. package/components/wework-chat-panel/chat-panel-controls/link/link.vue +0 -35
  35. package/components/wework-chat-panel/chat-panel-controls/location/location.vue +0 -35
  36. package/components/wework-chat-panel/chat-panel-controls/text/text.vue +0 -43
  37. package/components/wework-chat-panel/chat-panel-controls/unkonw/unkonw.vue +0 -39
  38. package/components/wework-chat-panel/chat-panel-controls/video/video.vue +0 -37
  39. package/components/wework-chat-panel/chat-panel-controls/voice/voice.vue +0 -35
  40. package/uni-common/account-portray/account-portray.vue +0 -51
  41. package/uni-common/account-select/account-select-item.vue +0 -172
  42. package/uni-common/account-select/account-select.vue +0 -252
  43. package/uni-common/all-friend-avatar/all-friend-avatar.vue +0 -49
  44. package/uni-common/friend-avatar/default.svg +0 -1
  45. package/uni-common/friend-avatar/friend-avatar.vue +0 -27
  46. package/uni-common/friend-avatar/index.js +0 -3
  47. package/uni-common/friend-loader/friend-loader.vue +0 -53
  48. package/uni-common/friend-portray/friend-portray.vue +0 -56
  49. package/uni-common/group-avatar/default.svg +0 -1
  50. package/uni-common/group-avatar/group-avatar.vue +0 -18
  51. package/uni-common/group-avatar/index.js +0 -3
  52. package/uni-common/room-avatar/default.svg +0 -6
  53. package/uni-common/room-avatar/index.js +0 -3
  54. package/uni-common/room-avatar/room-avatar.vue +0 -27
  55. package/uni-common/room-loader/room-loader.vue +0 -53
  56. package/uni-common/room-portray/room-portray.vue +0 -56
  57. package/uni-components/chat-control/calling/calling.vue +0 -91
  58. package/uni-components/chat-control/calling/phone-fill.svg +0 -1
  59. package/uni-components/chat-control/calling/vidicon-fill.svg +0 -1
  60. package/uni-components/chat-control/channel-video/channel-video.vue +0 -89
  61. package/uni-components/chat-control/channel-video-card/channel-video-card.vue +0 -105
  62. package/uni-components/chat-control/channel-video-live/channel-video-live.vue +0 -92
  63. package/uni-components/chat-control/chat-control-config-item/chat-control-config-item.vue +0 -20
  64. package/uni-components/chat-control/chat-control-config-item/index.js +0 -3
  65. package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-app.vue +0 -25
  66. package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-h5.vue +0 -21
  67. package/uni-components/chat-control/chat-control.vue +0 -218
  68. package/uni-components/chat-control/company-card/company-card.vue +0 -123
  69. package/uni-components/chat-control/const.js +0 -28
  70. package/uni-components/chat-control/expression/expression.vue +0 -41
  71. package/uni-components/chat-control/image/image.vue +0 -68
  72. package/uni-components/chat-control/index.js +0 -89
  73. package/uni-components/chat-control/location/location.vue +0 -110
  74. package/uni-components/chat-control/member-change/member-change.vue +0 -32
  75. package/uni-components/chat-control/quote-message/quote-message.vue +0 -216
  76. package/uni-components/chat-control/real-time-position/real-time-position.vue +0 -62
  77. package/uni-components/chat-control/redpacket/red-envelope.svg +0 -1
  78. package/uni-components/chat-control/redpacket/redpacket.vue +0 -75
  79. package/uni-components/chat-control/share-card/share-card.vue +0 -101
  80. package/uni-components/chat-control/system/system.vue +0 -69
  81. package/uni-components/chat-control/system-batch-message/system-batch-message.vue +0 -30
  82. package/uni-components/chat-control/system-text/system-text.vue +0 -32
  83. package/uni-components/chat-control/text/text.vue +0 -67
  84. package/uni-components/chat-control/text-with-at/text-with-at.vue +0 -51
  85. package/uni-components/chat-control/transfer/red-transfer.svg +0 -1
  86. package/uni-components/chat-control/transfer/transfer.vue +0 -80
  87. package/uni-components/chat-control/unkonw/unkonw.vue +0 -37
  88. package/uni-components/chat-control/url/icons/file-excel-line.svg +0 -1
  89. package/uni-components/chat-control/url/icons/file-info-line.svg +0 -1
  90. package/uni-components/chat-control/url/icons/file-music-line.svg +0 -1
  91. package/uni-components/chat-control/url/icons/file-pdf-line.svg +0 -1
  92. package/uni-components/chat-control/url/icons/file-ppt-line.svg +0 -1
  93. package/uni-components/chat-control/url/icons/file-settings-line.svg +0 -1
  94. package/uni-components/chat-control/url/icons/file-text-line.svg +0 -1
  95. package/uni-components/chat-control/url/icons/file-unknow-line.svg +0 -1
  96. package/uni-components/chat-control/url/icons/file-word-line.svg +0 -1
  97. package/uni-components/chat-control/url/icons/file-zip-line.svg +0 -1
  98. package/uni-components/chat-control/url/icons/index.js +0 -24
  99. package/uni-components/chat-control/url/miniprogram.svg +0 -1
  100. package/uni-components/chat-control/url/url-miniprogram.vue +0 -116
  101. package/uni-components/chat-control/url/url.vue +0 -306
  102. package/uni-components/chat-control/url-new/icons/file-excel-line.svg +0 -1
  103. package/uni-components/chat-control/url-new/icons/file-info-line.svg +0 -1
  104. package/uni-components/chat-control/url-new/icons/file-music-line.svg +0 -1
  105. package/uni-components/chat-control/url-new/icons/file-pdf-line.svg +0 -1
  106. package/uni-components/chat-control/url-new/icons/file-ppt-line.svg +0 -1
  107. package/uni-components/chat-control/url-new/icons/file-settings-line.svg +0 -1
  108. package/uni-components/chat-control/url-new/icons/file-text-line.svg +0 -1
  109. package/uni-components/chat-control/url-new/icons/file-unknow-line.svg +0 -1
  110. package/uni-components/chat-control/url-new/icons/file-word-line.svg +0 -1
  111. package/uni-components/chat-control/url-new/icons/file-zip-line.svg +0 -1
  112. package/uni-components/chat-control/url-new/icons/index.js +0 -24
  113. package/uni-components/chat-control/url-new/url-new.vue +0 -110
  114. package/uni-components/chat-control/utils.js +0 -12
  115. package/uni-components/chat-control/video/video.vue +0 -156
  116. package/uni-components/chat-control/voice/voice.vue +0 -166
  117. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-collect.vue +0 -84
  118. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-system.vue +0 -28
  119. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet.vue +0 -85
  120. package/uni-components/chat-editor/chat-editor-func/chat-editor-func.vue +0 -157
  121. package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at-panel.vue +0 -158
  122. package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at.vue +0 -61
  123. package/uni-components/chat-editor/chat-editor-func-button/chat-editor-func-button.vue +0 -58
  124. package/uni-components/chat-editor/chat-editor-func-file/chat-editor-func-file.vue +0 -54
  125. package/uni-components/chat-editor/chat-editor-func-image/chat-editor-func-image.vue +0 -42
  126. package/uni-components/chat-editor/chat-editor-func-video/chat-editor-func-video.vue +0 -42
  127. package/uni-components/chat-editor/chat-editor-func-voice/chat-editor-func-voice.vue +0 -25
  128. package/uni-components/chat-editor/chat-editor-message-send/chat-editor-message-send.vue +0 -158
  129. package/uni-components/chat-editor/chat-editor-quote/chat-editor-quote.vue +0 -75
  130. package/uni-components/chat-editor/chat-editor.vue +0 -257
  131. package/uni-components/chat-editor/index.js +0 -10
  132. package/uni-components/chat-editor/util.js +0 -65
  133. package/uni-components/chat-panel/chat-panel-chats-box.vue +0 -238
  134. package/uni-components/chat-panel/chat-panel-chats-forward/chat-panel-chats-forward.vue +0 -273
  135. package/uni-components/chat-panel/chat-panel-chats-item.vue +0 -578
  136. package/uni-components/chat-panel/chat-panel-chats-status/chat-panel-chats-status.vue +0 -71
  137. package/uni-components/chat-panel/chat-panel-chats.vue +0 -368
  138. package/uni-components/chat-panel/chat-panel.vue +0 -227
  139. package/uni-components/contacts-group-select/contacts-group-select-item.vue +0 -85
  140. package/uni-components/contacts-group-select/contacts-group-select-panel.vue +0 -119
  141. package/uni-components/contacts-group-select/contacts-group-select.vue +0 -150
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <wechat-chat-control-config-msg
2
+ <wework-chat-control-config-msg
3
3
  :msgData="item"
4
4
  >
5
5
  <template slot-scope="{ configData }">
@@ -7,7 +7,7 @@
7
7
  <template v-if="item.msgType !== '_EMPTY_'">
8
8
  <slot name="chat-prefix" :item="item"></slot>
9
9
  </template>
10
- <template v-if="[0, 1, 2].includes(item.msgType)">
10
+ <template v-if="item.msgType === MESSAGE_TYPE.TEXT || item.msgType === MESSAGE_TYPE.TEXT_W">
11
11
  <sdk-chat-panel-box
12
12
  :dir="dir"
13
13
  :data="item"
@@ -26,7 +26,7 @@
26
26
  </template>
27
27
  </sdk-chat-panel-box>
28
28
  </template>
29
- <template v-else-if="[14, 101].includes(item.msgType)">
29
+ <template v-else-if="item.msgType === MESSAGE_TYPE.IMAGE">
30
30
  <sdk-chat-panel-box
31
31
  :dir="dir"
32
32
  :data="item"
@@ -45,7 +45,7 @@
45
45
  </template>
46
46
  </sdk-chat-panel-box>
47
47
  </template>
48
- <template v-else-if="[22, 23, 103].includes(item.msgType)">
48
+ <template v-else-if="item.msgType === MESSAGE_TYPE.VIDEO">
49
49
  <sdk-chat-panel-box
50
50
  :dir="dir"
51
51
  :data="item"
@@ -289,7 +289,7 @@
289
289
  </template>
290
290
  </sdk-chat-panel-box>
291
291
  </template>
292
- <template v-else-if="item.msgType == MESSAGE_TYPE.URL">
292
+ <template v-else-if="item.msgType == MESSAGE_TYPE.URL || item.msgType == MESSAGE_TYPE.URLNew">
293
293
  <sdk-chat-panel-box
294
294
  :dir="dir"
295
295
  :data="item"
@@ -312,29 +312,6 @@
312
312
  </template>
313
313
  </sdk-chat-panel-box>
314
314
  </template>
315
- <template v-else-if="[13, 15, 20, 102].includes(item.msgType)">
316
- <sdk-chat-panel-box
317
- :dir="dir"
318
- :data="item"
319
- :fetchUserMethod="fetchUserMethod"
320
- bg-color="#fff"
321
- br-color="#ddd"
322
- @user-avatar-click="handleUserAvatarClick"
323
- @user-avatar-contextmenu="handleUserAvatarContextmenu"
324
- >
325
- <template slot-scope="{ updateProp }">
326
- <sdk-chat-control-file-url
327
- v-bind="configData"
328
- :id="item.id"
329
- :content="msgContent"
330
- :update-chat-box-prop="updateProp"
331
- ></sdk-chat-control-file-url>
332
- </template>
333
- <template slot="append" slot-scope="{ updateProp }">
334
- <slot name="chat-append" :item="item" :update-chat-box-prop="updateProp"></slot>
335
- </template>
336
- </sdk-chat-panel-box>
337
- </template>
338
315
  <template v-else-if="item.msgType == MESSAGE_TYPE.CUSTOM_EXPRESSION">
339
316
  <sdk-chat-panel-box
340
317
  :dir="dir"
@@ -510,7 +487,7 @@
510
487
  :content="msgContent"
511
488
  ></sdk-chat-control-empty>
512
489
  </template>
513
- <!-- <template v-else>
490
+ <template v-else>
514
491
  <sdk-chat-panel-box
515
492
  :dir="dir"
516
493
  :data="item"
@@ -523,10 +500,10 @@
523
500
  :content="msgContent"
524
501
  ></sdk-chat-control-unknow>
525
502
  </sdk-chat-panel-box>
526
- </template> -->
503
+ </template>
527
504
  </div>
528
505
  </template>
529
- </wechat-chat-control-config-msg>
506
+ </wework-chat-control-config-msg>
530
507
  </template>
531
508
  <script>
532
509
  import SdkChatPanelBox from '../chat-panel/chat-panel-box'
@@ -564,10 +541,10 @@ import {
564
541
  unknow as SdkChatControlUnknow
565
542
  } from '../wework-chat-control'
566
543
  import { MESSAGE_TYPE } from '../wework-chat-control/util'
567
- import WechatChatControlConfigMsg from '../wechat-chat-control/wechat-chat-control-config-msg.vue'
544
+ import WeworkChatControlConfigMsg from '../wework-chat-control/wework-chat-control-config-msg.vue'
568
545
 
569
546
  export default {
570
- name: 'SdkWechatPanelItem',
547
+ name: 'SdkWeworkPanelItem',
571
548
  components: {
572
549
  SdkChatPanelBox,
573
550
  SdkChatControlText,
@@ -601,7 +578,7 @@ export default {
601
578
  // SdkChatControlRevokeMeMessage,
602
579
  // SdkChatControlRevokeOtherMessage,
603
580
  // SdkChatControlRevokeYouMessage,
604
- WechatChatControlConfigMsg
581
+ WeworkChatControlConfigMsg
605
582
  },
606
583
  props: {
607
584
  dir: {
@@ -647,4 +624,4 @@ export default {
647
624
  }
648
625
  }
649
626
  }
650
- </script>
627
+ </script>
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <sdk-chat-panel
3
3
  ref="panel"
4
- v-bind="$props"
4
+ v-bind="props"
5
5
  :is-sender-method="handleIsSenderMethod"
6
6
  @initloaded="handleChatsInitLoaded"
7
7
  @chat-contextmenu="handleChatContext"
@@ -17,12 +17,12 @@
17
17
  :fetch-user-method="fetchUserMethod"
18
18
  :config="config"
19
19
  >
20
- <!-- <template slot="chat-append" slot-scope="{ item, updateProp }">
20
+ <template slot="chat-append" slot-scope="{ item, updateProp }">
21
21
  <chat-panel-chat-status
22
22
  :data="item"
23
23
  :update-chat-box-prop="updateProp"
24
24
  ></chat-panel-chat-status>
25
- </template> -->
25
+ </template>
26
26
  <template slot="chat-prefix" slot-scope="{ item }">
27
27
  <template v-if="selectable && handleFilterSelectMessageMethod(item)">
28
28
  <div class="sdk-wechat-chat-panel__checkbox">
@@ -37,18 +37,23 @@
37
37
  </template>
38
38
  <template slot="main">
39
39
  <slot name="main"></slot>
40
+ <template v-if="selectable">
41
+ <slot name="selection" :total="checkTotal"></slot>
42
+ </template>
40
43
  </template>
41
44
  </sdk-chat-panel>
42
45
  </template>
43
46
  <script>
44
47
  import SdkChatPanel from '../chat-panel'
45
48
  import ChatPanelItem from './chat-panel-item.vue'
49
+ import ChatPanelChatStatus from './chat-panel-chat-status/chat-panel-chat-status.vue'
46
50
 
47
51
  export default {
48
52
  name: 'SdkWeworkChatPanel',
49
53
  components: {
50
54
  SdkChatPanel,
51
- ChatPanelItem
55
+ ChatPanelItem,
56
+ ChatPanelChatStatus
52
57
  },
53
58
  props: {
54
59
  mode: {
@@ -59,7 +64,8 @@ export default {
59
64
  }
60
65
  },
61
66
  keyField: {
62
- type: String
67
+ type: String,
68
+ default: 'id'
63
69
  },
64
70
  startDate: {
65
71
  type: Number
@@ -88,9 +94,6 @@ export default {
88
94
  type: Boolean,
89
95
  default: true
90
96
  },
91
- renderControl: {
92
- type: Function
93
- },
94
97
  fetchUserMethod: {
95
98
  type: Function
96
99
  },
@@ -126,12 +129,33 @@ export default {
126
129
  },
127
130
  contextChatId: {
128
131
  type: String
132
+ },
133
+ onBeforeSelectionChange: {
134
+ type: Function
129
135
  }
130
136
  },
131
- methods: {
132
- handleRenderControl ({ item }) {
133
- return ChatControls[item.msgType] || ChatControls.unkonw
137
+ data () {
138
+ return {
139
+ checkMsgMap: {}
140
+ }
141
+ },
142
+ computed: {
143
+ props () {
144
+ const { config, ...nextProps } = this.$props
145
+ return nextProps
134
146
  },
147
+ checkTotal () {
148
+ return Object.keys(this.checkMsgMap).length
149
+ }
150
+ },
151
+ watch: {
152
+ selectable () {
153
+ if (!this.selectable) {
154
+ this.checkMsgMap = {}
155
+ }
156
+ }
157
+ },
158
+ methods: {
135
159
  handleIsSenderMethod ({ item }) {
136
160
  return !!item.send
137
161
  },
@@ -148,8 +172,67 @@ export default {
148
172
  this.currentContextChat = null
149
173
  return this.$refs.panel && this.$refs.panel.reload()
150
174
  },
175
+ handleFilterSelectMessageMethod (msg) {
176
+ if (!this.filterSelectMessageMethod) {
177
+ return true
178
+ }
179
+ return this.filterSelectMessageMethod({
180
+ item: msg
181
+ })
182
+ },
183
+ handleMsgCheckboxChange (msg, value) {
184
+ if (value) {
185
+ this.selectChat(msg)
186
+ } else {
187
+ this.unselectChat(msg)
188
+ }
189
+ },
190
+ selectChat (chat) {
191
+ if (!chat) {
192
+ return
193
+ }
194
+ if (!this.selectable) {
195
+ console.warn('未开启选择')
196
+ return
197
+ }
198
+ if (this.onBeforeSelectionChange && this.onBeforeSelectionChange({
199
+ chat,
200
+ value: true
201
+ }) === false) {
202
+ return
203
+ }
204
+ this.$set(this.checkMsgMap, chat[this.keyField], chat)
205
+ },
206
+ unselectChat (chat) {
207
+ if (!chat) {
208
+ return
209
+ }
210
+ if (!this.selectable) {
211
+ console.warn('未开启选择')
212
+ return
213
+ }
214
+ if (this.onBeforeSelectionChange && this.onBeforeSelectionChange({
215
+ chat,
216
+ value: false
217
+ }) === false) {
218
+ return
219
+ }
220
+ this.$delete(this.checkMsgMap, chat[this.keyField])
221
+ },
222
+ unselectAllChat () {
223
+ return Object.keys(this.checkMsgMap).map(key => {
224
+ return this.unselectChat(this.checkMsgMap[key])
225
+ })
226
+ },
227
+ getSelectChats () {
228
+ return Object.keys(this.checkMsgMap).map(key => {
229
+ return this.checkMsgMap[key]
230
+ })
231
+ },
151
232
  handleChatContext (item, evt) {
152
- this.$emit('chat-contextmenu', item, evt)
233
+ this.$emit('chat-contextmenu', {
234
+ item
235
+ }, evt)
153
236
  },
154
237
  handleChatViewContext ({ item }) {
155
238
  this.$emit('chat-view-context', {
package/package.json CHANGED
@@ -1,9 +1,16 @@
1
1
  {
2
2
  "name": "@aochuang/client-sdk",
3
- "version": "1.0.343",
3
+ "version": "1.0.344",
4
4
  "description": "",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
5
+ "files": [
6
+ "common",
7
+ "components",
8
+ "services",
9
+ "utils",
10
+ "dist"
11
+ ],
12
+ "exports": {
13
+ ".": "./components/index.js"
7
14
  },
8
15
  "repository": {
9
16
  "type": "git",
@@ -229,14 +229,14 @@ export default class ClientChatSession {
229
229
  }
230
230
 
231
231
  getSession (sessionId, serializeMethod) {
232
- if (this.sessionMap[sessionId]) {
232
+ if (this.sessionMap[sessionId]) {
233
233
  return Promise.resolve({
234
234
  data: this.sessionMap[sessionId]
235
235
  })
236
236
  }
237
237
  // 这里需要轮询从后端获取会话,后端会话更新和创建是异步的,所以要多轮训请求几次
238
238
  if (this.pollRequestMap[sessionId]) {
239
- return this.pollRequestMap[sessionId].ps
239
+ this.pollRequestMap[sessionId].stop()
240
240
  }
241
241
  const pollRequest = createPollRequest(({ done, fail }) => {
242
242
  return this.getSessionMethod({
@@ -248,7 +248,7 @@ export default class ClientChatSession {
248
248
  })
249
249
  })
250
250
  this.pollRequestMap[sessionId] = pollRequest
251
- this.pollRequestMap[sessionId].ps = pollRequest.start().then(rs => {
251
+ return pollRequest.start().then(rs => {
252
252
  if (serializeMethod) {
253
253
  rs = serializeMethod(rs)
254
254
  }
@@ -263,7 +263,6 @@ export default class ClientChatSession {
263
263
  delete this.pollRequestMap[sessionId]
264
264
  }
265
265
  })
266
- return this.pollRequestMap[sessionId].ps
267
266
  }
268
267
 
269
268
  findSession (findFn) {
@@ -452,15 +452,9 @@ class ClientChat {
452
452
  }
453
453
  })
454
454
  })
455
- } else {
456
- this.session.updateSession(sessionId, ({ session }) => {
457
- // listChange/getSession may already include this message in unreadMsgCount.
458
- // Only count messages newer than the session watermark.
459
- const isNewerMessage = data.wechatTime > (session.lastMsgTime || 0)
460
- if (!isNewerMessage) {
461
- return {}
462
- }
463
- const nextSession = {
455
+ } else {
456
+ this.session.updateSession(sessionId, ({ session }) => {
457
+ const nextSession = {
464
458
  lastMsgContent: data.content,
465
459
  lastMsgType: data.msgType,
466
460
  lastMsgTime: data.wechatTime,
@@ -468,7 +462,7 @@ class ClientChat {
468
462
  lastUpdateTime: data.updateDate,
469
463
  unreadMsgCount: session.unreadMsgCount
470
464
  }
471
- if (!data.isSend && isNewerMessage) {
465
+ if (!data.isSend) {
472
466
  if (this.sessionManage.currentSession && this.sessionManage.currentSession.conversationId === sessionId && this.shouldMarkCurrentSessionRead(sessionId, data)) {
473
467
  // 标记已读
474
468
  this.session.setSessionRead(sessionId)
@@ -600,15 +594,9 @@ class ClientChat {
600
594
  }
601
595
  })
602
596
  })
603
- } else {
604
- this.session.updateSession(sessionId, ({ session }) => {
605
- // listChange/getSession may already include this message in unreadMsgCount.
606
- // Only count messages newer than the session watermark.
607
- const isNewerMessage = data.wechatTime > (session.lastMsgTime || 0)
608
- if (!isNewerMessage) {
609
- return {}
610
- }
611
- const nextSession = {
597
+ } else {
598
+ this.session.updateSession(sessionId, ({ session }) => {
599
+ const nextSession = {
612
600
  lastMsgContent: data.content,
613
601
  lastMsgType: data.msgType,
614
602
  lastMsgTime: data.wechatTime,
@@ -616,7 +604,7 @@ class ClientChat {
616
604
  lastUpdateTime: data.updateDate,
617
605
  unreadMsgCount: session.unreadMsgCount
618
606
  }
619
- if (!data.isSend && isNewerMessage) {
607
+ if (!data.isSend) {
620
608
  if (this.sessionManage.currentSession && this.sessionManage.currentSession.conversationId === sessionId && this.shouldMarkCurrentSessionRead(sessionId, data)) {
621
609
  // 标记已读
622
610
  this.session.setSessionRead(sessionId)
@@ -126,11 +126,7 @@ export default class ClientChatContacts {
126
126
  */
127
127
  roomBindMemberMap: {},
128
128
 
129
- /**
130
- * 标记通讯录是否修改了
131
- * 如果修改了,比如接收到了分配好友的会话时,一定通讯录变了,变了的时候界面需要根据这个状态刷新通讯录
132
- */
133
- isModify: false
129
+ modifiedAccountMap: {}
134
130
  })
135
131
 
136
132
  friendMap = {}
@@ -237,10 +233,6 @@ export default class ClientChatContacts {
237
233
  return this.data.roomGroupData
238
234
  }
239
235
 
240
- get isModify () {
241
- return this.data.isModify
242
- }
243
-
244
236
  setRoomGroup (data) {
245
237
  this.data.roomGroupData = []
246
238
  if (data && data.length) {
@@ -491,10 +483,10 @@ export default class ClientChatContacts {
491
483
  }
492
484
  }
493
485
  const qwAccountId = this.roomMap[id].qwAccountId
494
- if (qwAccountId && this.data.accountBindFriendMap[qwAccountId] && this.data.accountBindFriendMap[qwAccountId][groupId]) {
495
- const bindIndex = this.data.accountBindFriendMap[qwAccountId][groupId].indexOf(this.roomMap[id])
486
+ if (qwAccountId && this.data.accountBindRoomMap[qwAccountId] && this.data.accountBindRoomMap[qwAccountId][groupId]) {
487
+ const bindIndex = this.data.accountBindRoomMap[qwAccountId][groupId].indexOf(this.roomMap[id])
496
488
  if (bindIndex >= 0) {
497
- this.data.accountBindFriendMap[qwAccountId][groupId].splice(bindIndex, 1)
489
+ this.data.accountBindRoomMap[qwAccountId][groupId].splice(bindIndex, 1)
498
490
  }
499
491
  }
500
492
  })
@@ -628,6 +620,37 @@ export default class ClientChatContacts {
628
620
  return rs
629
621
  })
630
622
  }
623
+
624
+ /**
625
+ * 强制从服务端刷新好友资料,绕过本地缓存。
626
+ */
627
+ refreshFriend (friendId) {
628
+ if (!friendId) {
629
+ return Promise.reject('缺少好友id')
630
+ }
631
+ if (!this.getContactsFriendMethod) {
632
+ return Promise.reject(new Error('getContactsFriendMethod未定义'))
633
+ }
634
+ return this.getContactsFriendMethod({
635
+ id: friendId
636
+ }).then(rs => {
637
+ if (!rs || !rs.data) {
638
+ return Promise.reject('未找到好友' + friendId)
639
+ }
640
+ if (this.friendMap[friendId]) {
641
+ const nextKeys = Object.keys(rs.data)
642
+ Object.keys(this.friendMap[friendId]).forEach(key => {
643
+ if (!nextKeys.includes(key)) {
644
+ Vue.delete(this.friendMap[friendId], key)
645
+ }
646
+ })
647
+ this.updateFriend(friendId, rs.data)
648
+ } else {
649
+ this.addFriend(rs.data)
650
+ }
651
+ return rs
652
+ })
653
+ }
631
654
 
632
655
  setRoomMemberData (roomId, data) {
633
656
  if (!roomId) {
@@ -738,12 +761,52 @@ export default class ClientChatContacts {
738
761
  })
739
762
  }
740
763
 
741
- markModify () {
742
- this.data.isModify = true
764
+ refreshRoom (id) {
765
+ if (!id) {
766
+ return Promise.reject('缺少群id')
767
+ }
768
+ if (!this.getContactsRoomMethod) {
769
+ return Promise.reject(new Error('getContactsRoomMethod未定义'))
770
+ }
771
+ return this.getContactsRoomMethod({
772
+ id
773
+ }).then(rs => {
774
+ if (!rs || !rs.data) {
775
+ return Promise.reject('未找到群' + id)
776
+ }
777
+ const localRoom = this.roomMap[id]
778
+ if (localRoom) {
779
+ this.removeRoom(id)
780
+ const nextKeys = Object.keys(rs.data)
781
+ Object.keys(localRoom).forEach(key => {
782
+ if (!nextKeys.includes(key)) {
783
+ Vue.delete(localRoom, key)
784
+ }
785
+ })
786
+ Object.keys(rs.data).forEach(key => {
787
+ Vue.set(localRoom, key, rs.data[key])
788
+ })
789
+ }
790
+ this.addRoom(localRoom || rs.data)
791
+ return rs
792
+ })
793
+ }
794
+
795
+ isModify (qwAccountId) {
796
+ return !!(qwAccountId && this.data.modifiedAccountMap[qwAccountId])
797
+ }
798
+
799
+ markModify (qwAccountIds) {
800
+ const ids = Array.isArray(qwAccountIds) ? qwAccountIds : [qwAccountIds]
801
+ ids.filter(Boolean).forEach(id => {
802
+ Vue.set(this.data.modifiedAccountMap, id, true)
803
+ })
743
804
  }
744
805
 
745
- unmarkModify () {
746
- this.data.isModify = false
806
+ unmarkModify (qwAccountId) {
807
+ if (qwAccountId) {
808
+ Vue.delete(this.data.modifiedAccountMap, qwAccountId)
809
+ }
747
810
  }
748
811
 
749
812
  reset () {
@@ -758,6 +821,7 @@ export default class ClientChatContacts {
758
821
  this.data.groupBindRoomMap = {}
759
822
  this.data.accountBindFriendMap = {}
760
823
  this.data.accountBindRoomMap = {}
824
+ this.data.modifiedAccountMap = {}
761
825
  this._cacheFriendGroupCountMap = null
762
826
  this._cacheRoomGroupCountMap = null
763
827
  if (this.cancelConnectRequest) {
@@ -769,4 +833,4 @@ export default class ClientChatContacts {
769
833
  this.cancelRefreshRequest = null
770
834
  }
771
835
  }
772
- }
836
+ }
@@ -74,7 +74,7 @@ export default class ClientChatMessage {
74
74
  * "msgSvrId": "4319123759514541049",
75
75
  * "msgType": 1,
76
76
  * "origin": "0",
77
- * "sendStatus": 0,
77
+ * "status": 0,
78
78
  * "tenantId": "1761952223049924608",
79
79
  * "wechatAccountId": "ad9d9ae2a8be4f27311312cdd4af3549dc8427ef",
80
80
  * "wechatFriendId": "2089efcc7f8f40b00b7f05fa4c6dfd3bb642774d",
@@ -215,11 +215,11 @@ export default class ClientChatMessage {
215
215
  }, data, {
216
216
  cmdType: 'CmdQwSendMessage'
217
217
  })).then(({ data }) => {
218
- if (data.sendStatus === 0) {
218
+ if (data.status === 0) {
219
219
  // 发送成功
220
- } else if (data.sendStatus === 2) {
220
+ } else if (data.status === 2) {
221
221
  // 发送失败
222
- } else if (data.sendStatus === 1) {
222
+ } else if (data.status === 1) {
223
223
  // 发送中
224
224
  }
225
225
  // 如果返回的是对象,证明发送成功了
@@ -277,4 +277,4 @@ export default class ClientChatMessage {
277
277
  reset () {
278
278
  this.data.messageData = {}
279
279
  }
280
- }
280
+ }
@@ -82,7 +82,8 @@ export default class ClientChatSession {
82
82
  /**
83
83
  * 删除会话
84
84
  */
85
- deleteSessionMethod: null
85
+ deleteSessionMethod: null,
86
+ modifiedAccountMap: {}
86
87
  })
87
88
 
88
89
  accountIds = []
@@ -119,6 +120,23 @@ export default class ClientChatSession {
119
120
  return this.data.loading
120
121
  }
121
122
 
123
+ isModify (qwAccountId) {
124
+ return !!(qwAccountId && this.data.modifiedAccountMap[qwAccountId])
125
+ }
126
+
127
+ markModify (qwAccountIds) {
128
+ const ids = Array.isArray(qwAccountIds) ? qwAccountIds : [qwAccountIds]
129
+ ids.filter(Boolean).forEach(id => {
130
+ Vue.set(this.data.modifiedAccountMap, id, true)
131
+ })
132
+ }
133
+
134
+ unmarkModify (qwAccountId) {
135
+ if (qwAccountId) {
136
+ Vue.delete(this.data.modifiedAccountMap, qwAccountId)
137
+ }
138
+ }
139
+
122
140
  get loadAssignTaskSessioning () {
123
141
  return this.data.loadAssignTaskSessioning
124
142
  }
@@ -205,6 +223,35 @@ export default class ClientChatSession {
205
223
  getSessionByLocal (sessionId) {
206
224
  return this.sessionMap[sessionId]
207
225
  }
226
+
227
+ /**
228
+ * 强制从服务端刷新会话,绕过本地缓存。
229
+ */
230
+ refreshSession (sessionId) {
231
+ if (!sessionId) {
232
+ return Promise.reject('缺少会话id')
233
+ }
234
+ return this.getSessionMethod({
235
+ id: sessionId
236
+ }).then(rs => {
237
+ if (!rs || !rs.data) {
238
+ return Promise.reject('未找到会话' + sessionId)
239
+ }
240
+ // 事件计算出的 sessionId 是本地索引,始终保持与服务端返回对象一致。
241
+ const serverSession = Object.assign({}, rs.data, {
242
+ id: sessionId
243
+ })
244
+ const localSession = this.getSessionByLocal(sessionId)
245
+ if (localSession) {
246
+ this.updateSession(sessionId, serverSession)
247
+ } else {
248
+ this.addSession(serverSession)
249
+ }
250
+ return Object.assign({}, rs, {
251
+ data: serverSession
252
+ })
253
+ })
254
+ }
208
255
 
209
256
  findSession (findFn) {
210
257
  let result
@@ -915,6 +962,7 @@ export default class ClientChatSession {
915
962
  this.data.sessionData = {}
916
963
  this.data.sessionGroupData = {}
917
964
  this.data.sessionMuteMap = {}
965
+ this.data.modifiedAccountMap = {}
918
966
  // this.data.sessionUnreadCountMap = {}
919
967
  this.sessionMap = {}
920
968
  if (this.cancelLoadDataRequest) {
@@ -926,4 +974,4 @@ export default class ClientChatSession {
926
974
  this.cancelRefreshRequest = null
927
975
  }
928
976
  }
929
- }
977
+ }
@@ -15,11 +15,14 @@ export default class ClietChatSocket {
15
15
  // 执行回调事件前的方法
16
16
  beforeFireCallback: null,
17
17
  onCmdQwNewMessage: null,
18
+ onCmdQwContactInfoChanged: null,
19
+ onCmdQwRoomInfoChanged: null,
18
20
  onCmdSendMessageResult: null,
19
21
  onCmdFriendInfoChanged: null,
20
22
  onCmdDownloadVideoResult: null,
21
23
  onCmdChatroomInfoChanged: null,
22
24
  onCmdChatroomInfoChangedBatch: null,
25
+ onHeartbeatSuccess: null,
23
26
  onHeartbeatCheck: null
24
27
  }, options)
25
28
  if (!options.socket) {
@@ -27,6 +30,11 @@ export default class ClietChatSocket {
27
30
  }
28
31
  this.socket = options.socket
29
32
  this.socket.event.on('onCmdQwNewMessage', options.onCmdQwNewMessage)
33
+ this.socket.event.on('onCmdQwContactInfoChanged', options.onCmdQwContactInfoChanged)
34
+ this.socket.event.on('onCmdQwRoomInfoChanged', options.onCmdQwRoomInfoChanged)
35
+ this.socket.event.on('onHeartbeatSuccess', (evt) => {
36
+ options.onHeartbeatSuccess && options.onHeartbeatSuccess(evt)
37
+ })
30
38
  this.socket.event.on('onHeartbeatCheck', ({ mergeParams }) => {
31
39
  options.onHeartbeatCheck && options.onHeartbeatCheck({
32
40
  mergeParams
@@ -62,4 +70,4 @@ export default class ClietChatSocket {
62
70
  setUrl (url) {
63
71
  this.socket.setUrl(url)
64
72
  }
65
- }
73
+ }