@aochuang/client-sdk 1.0.346 → 1.0.348
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/index.js +6 -1
- package/components/session-select/session-select-item.vue +8 -9
- 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/company-card/company-card.vue +1 -1
- package/components/wework-chat-control/file-url/file-url.vue +2 -5
- package/components/wework-chat-control/image/image.vue +137 -2
- package/components/wework-chat-control/index.js +6 -6
- package/components/wework-chat-control/link/.DS_Store +0 -0
- package/components/wework-chat-control/text/text.vue +22 -3
- package/components/wework-chat-control/util.js +12 -6
- package/components/wework-chat-control/video/.DS_Store +0 -0
- package/components/wework-chat-control/video/video.vue +10 -2
- package/components/wework-chat-control/voice/voice.vue +1 -1
- package/components/wework-chat-control/wework-chat-control-config-item.vue +24 -0
- package/components/wework-chat-control/wework-chat-control-config-msg.vue +25 -0
- package/{uni-components/chat-control/chat-control-config.vue → components/wework-chat-control/wework-chat-control-config.vue} +16 -13
- package/components/wework-chat-panel/chat-panel-chat-status/chat-panel-chat-status.vue +73 -0
- package/components/wework-chat-panel/chat-panel-item.vue +12 -35
- package/components/wework-chat-panel/chat-panel.vue +95 -12
- package/package.json +10 -3
- package/services/client-chat/client-chat-wework/client-chat-concats.js +81 -17
- package/services/client-chat/client-chat-wework/client-chat-message.js +46 -6
- package/services/client-chat/client-chat-wework/client-chat-session.js +50 -2
- package/services/client-chat/client-chat-wework/client-chat-socket.js +9 -1
- package/services/client-chat/client-chat-wework/client-chat.js +283 -13
- package/services/client-chat/client-chat-wework/utils.js +5 -5
- package/components/wework-chat-panel/chat-panel-controls/company-card/company-card.vue +0 -35
- package/components/wework-chat-panel/chat-panel-controls/expression/expression.vue +0 -36
- package/components/wework-chat-panel/chat-panel-controls/file-url/file-url.vue +0 -35
- package/components/wework-chat-panel/chat-panel-controls/image/image.vue +0 -36
- package/components/wework-chat-panel/chat-panel-controls/index.js +0 -35
- package/components/wework-chat-panel/chat-panel-controls/jx-sys-text/jx-sys-text.vue +0 -28
- package/components/wework-chat-panel/chat-panel-controls/link/link.vue +0 -35
- package/components/wework-chat-panel/chat-panel-controls/location/location.vue +0 -35
- package/components/wework-chat-panel/chat-panel-controls/text/text.vue +0 -43
- package/components/wework-chat-panel/chat-panel-controls/unkonw/unkonw.vue +0 -39
- package/components/wework-chat-panel/chat-panel-controls/video/video.vue +0 -37
- package/components/wework-chat-panel/chat-panel-controls/voice/voice.vue +0 -35
- package/uni-common/account-portray/account-portray.vue +0 -51
- package/uni-common/account-select/account-select-item.vue +0 -172
- package/uni-common/account-select/account-select.vue +0 -252
- package/uni-common/all-friend-avatar/all-friend-avatar.vue +0 -49
- package/uni-common/friend-avatar/default.svg +0 -1
- package/uni-common/friend-avatar/friend-avatar.vue +0 -27
- package/uni-common/friend-avatar/index.js +0 -3
- package/uni-common/friend-loader/friend-loader.vue +0 -53
- package/uni-common/friend-portray/friend-portray.vue +0 -56
- package/uni-common/group-avatar/default.svg +0 -1
- package/uni-common/group-avatar/group-avatar.vue +0 -18
- package/uni-common/group-avatar/index.js +0 -3
- package/uni-common/room-avatar/default.svg +0 -6
- package/uni-common/room-avatar/index.js +0 -3
- package/uni-common/room-avatar/room-avatar.vue +0 -27
- package/uni-common/room-loader/room-loader.vue +0 -53
- package/uni-common/room-portray/room-portray.vue +0 -56
- package/uni-components/chat-control/calling/calling.vue +0 -91
- package/uni-components/chat-control/calling/phone-fill.svg +0 -1
- package/uni-components/chat-control/calling/vidicon-fill.svg +0 -1
- package/uni-components/chat-control/channel-video/channel-video.vue +0 -89
- package/uni-components/chat-control/channel-video-card/channel-video-card.vue +0 -105
- package/uni-components/chat-control/channel-video-live/channel-video-live.vue +0 -92
- package/uni-components/chat-control/chat-control-config-item/chat-control-config-item.vue +0 -20
- package/uni-components/chat-control/chat-control-config-item/index.js +0 -3
- package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-app.vue +0 -25
- package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-h5.vue +0 -21
- package/uni-components/chat-control/chat-control.vue +0 -218
- package/uni-components/chat-control/company-card/company-card.vue +0 -123
- package/uni-components/chat-control/const.js +0 -28
- package/uni-components/chat-control/expression/expression.vue +0 -41
- package/uni-components/chat-control/image/image.vue +0 -68
- package/uni-components/chat-control/index.js +0 -89
- package/uni-components/chat-control/location/location.vue +0 -110
- package/uni-components/chat-control/member-change/member-change.vue +0 -32
- package/uni-components/chat-control/quote-message/quote-message.vue +0 -216
- package/uni-components/chat-control/real-time-position/real-time-position.vue +0 -62
- package/uni-components/chat-control/redpacket/red-envelope.svg +0 -1
- package/uni-components/chat-control/redpacket/redpacket.vue +0 -75
- package/uni-components/chat-control/share-card/share-card.vue +0 -101
- package/uni-components/chat-control/system/system.vue +0 -69
- package/uni-components/chat-control/system-batch-message/system-batch-message.vue +0 -30
- package/uni-components/chat-control/system-text/system-text.vue +0 -32
- package/uni-components/chat-control/text/text.vue +0 -67
- package/uni-components/chat-control/text-with-at/text-with-at.vue +0 -51
- package/uni-components/chat-control/transfer/red-transfer.svg +0 -1
- package/uni-components/chat-control/transfer/transfer.vue +0 -80
- package/uni-components/chat-control/unkonw/unkonw.vue +0 -37
- package/uni-components/chat-control/url/icons/file-excel-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-info-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-music-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-pdf-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-ppt-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-settings-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-text-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-unknow-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-word-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-zip-line.svg +0 -1
- package/uni-components/chat-control/url/icons/index.js +0 -24
- package/uni-components/chat-control/url/miniprogram.svg +0 -1
- package/uni-components/chat-control/url/url-miniprogram.vue +0 -116
- package/uni-components/chat-control/url/url.vue +0 -306
- package/uni-components/chat-control/url-new/icons/file-excel-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-info-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-music-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-pdf-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-ppt-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-settings-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-text-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-unknow-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-word-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-zip-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/index.js +0 -24
- package/uni-components/chat-control/url-new/url-new.vue +0 -110
- package/uni-components/chat-control/utils.js +0 -12
- package/uni-components/chat-control/video/video.vue +0 -156
- package/uni-components/chat-control/voice/voice.vue +0 -166
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-collect.vue +0 -84
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-system.vue +0 -28
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet.vue +0 -85
- package/uni-components/chat-editor/chat-editor-func/chat-editor-func.vue +0 -157
- package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at-panel.vue +0 -158
- package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at.vue +0 -61
- package/uni-components/chat-editor/chat-editor-func-button/chat-editor-func-button.vue +0 -58
- package/uni-components/chat-editor/chat-editor-func-file/chat-editor-func-file.vue +0 -54
- package/uni-components/chat-editor/chat-editor-func-image/chat-editor-func-image.vue +0 -42
- package/uni-components/chat-editor/chat-editor-func-video/chat-editor-func-video.vue +0 -42
- package/uni-components/chat-editor/chat-editor-func-voice/chat-editor-func-voice.vue +0 -25
- package/uni-components/chat-editor/chat-editor-message-send/chat-editor-message-send.vue +0 -158
- package/uni-components/chat-editor/chat-editor-quote/chat-editor-quote.vue +0 -75
- package/uni-components/chat-editor/chat-editor.vue +0 -257
- package/uni-components/chat-editor/index.js +0 -10
- package/uni-components/chat-editor/util.js +0 -65
- package/uni-components/chat-panel/chat-panel-chats-box.vue +0 -238
- package/uni-components/chat-panel/chat-panel-chats-forward/chat-panel-chats-forward.vue +0 -273
- package/uni-components/chat-panel/chat-panel-chats-item.vue +0 -578
- package/uni-components/chat-panel/chat-panel-chats-status/chat-panel-chats-status.vue +0 -71
- package/uni-components/chat-panel/chat-panel-chats.vue +0 -368
- package/uni-components/chat-panel/chat-panel.vue +0 -227
- package/uni-components/contacts-group-select/contacts-group-select-item.vue +0 -85
- package/uni-components/contacts-group-select/contacts-group-select-panel.vue +0 -119
- package/uni-components/contacts-group-select/contacts-group-select.vue +0 -150
|
@@ -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
|
+
}
|
|
@@ -32,6 +32,7 @@ class ClientChat {
|
|
|
32
32
|
getLoginUserIdMethod: null,
|
|
33
33
|
getLoginUserTokenMethod: null,
|
|
34
34
|
loadAccountDataMethod: null,
|
|
35
|
+
getLoginAccountIdMethod: null, // 因为1.0有帮聊逻辑,帮聊消息以及通讯录的accountId不是登录用户的accountId,会导致找到的会话出现问题,所以这里提供一个方法让外部传入
|
|
35
36
|
loadSessionDataMethod: null,
|
|
36
37
|
updateSessionReadMethod: null,
|
|
37
38
|
getSessionMethod: null,
|
|
@@ -50,6 +51,7 @@ class ClientChat {
|
|
|
50
51
|
getContactsRoomMethod: null,
|
|
51
52
|
loadFriendMessageDataMethod: null,
|
|
52
53
|
loadRoomMessageDataMethod: null,
|
|
54
|
+
checkMessageSendResultMethod: null,
|
|
53
55
|
onOverwriteFriendInfoChange: null // 为了兼容1.0拉取会话逻辑加的,1.0暂时不支持根据taskId拉取
|
|
54
56
|
}, options)
|
|
55
57
|
if (!options.loadFriendMessageDataMethod) {
|
|
@@ -57,8 +59,9 @@ class ClientChat {
|
|
|
57
59
|
}
|
|
58
60
|
if (!options.loadRoomMessageDataMethod) {
|
|
59
61
|
throw new Error('loadRoomMessageDataMethod不能为空')
|
|
60
|
-
}
|
|
62
|
+
}
|
|
61
63
|
this.onOverwriteFriendInfoChange = options.onOverwriteFriendInfoChange
|
|
64
|
+
this.getLoginAccountIdMethod = options.getLoginAccountIdMethod
|
|
62
65
|
this.event = new Event({
|
|
63
66
|
checkOnMethod: (name) => {
|
|
64
67
|
if (name === 'ready') {
|
|
@@ -85,8 +88,10 @@ class ClientChat {
|
|
|
85
88
|
groupField: 'contactId',
|
|
86
89
|
sortField: 'sendTime',
|
|
87
90
|
clientChat: this,
|
|
91
|
+
checkMessageSendResultMethod: options.checkMessageSendResultMethod,
|
|
88
92
|
onAddMessageSuccess: ({ data }) => {
|
|
89
|
-
|
|
93
|
+
const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : data.qwAccountId
|
|
94
|
+
let sessionId = createSessionId(accountId, data.contactId)
|
|
90
95
|
// 更新会话
|
|
91
96
|
if (!sessionId) {
|
|
92
97
|
return
|
|
@@ -100,6 +105,15 @@ class ClientChat {
|
|
|
100
105
|
return this.session.getSession(sessionId).then(done)
|
|
101
106
|
})
|
|
102
107
|
this._sessionPollRequestMap[sessionId].start().then((rs) => {
|
|
108
|
+
// 后端更新会话是异步过程,返回的会话信息可能还未包含当前消息
|
|
109
|
+
if (rs && rs.data && !rs.data.unreadMsgCount) {
|
|
110
|
+
rs.data.unreadMsgCount = data.send ? 0 : 1
|
|
111
|
+
rs.data.lastMsgContent = data.content
|
|
112
|
+
rs.data.lastMsgType = data.msgType
|
|
113
|
+
rs.data.lastMsgTime = data.sendTime
|
|
114
|
+
rs.data.lastMsgId = data.id
|
|
115
|
+
rs.data.lastUpdateTime = data.updateDate
|
|
116
|
+
}
|
|
103
117
|
// 更新账号未读消息数量
|
|
104
118
|
this.account.updateAccountUnreadMessageNum(rs.data.qwAccountId, ({ unreadMesasgeNum }) => {
|
|
105
119
|
return unreadMesasgeNum += (rs.data.unreadMsgCount || 0)
|
|
@@ -110,7 +124,7 @@ class ClientChat {
|
|
|
110
124
|
} else {
|
|
111
125
|
this.session.updateSession(sessionId, ({ session }) => {
|
|
112
126
|
let unreadMsgCount = session.unreadMsgCount
|
|
113
|
-
if (!data.
|
|
127
|
+
if (!data.send) {
|
|
114
128
|
unreadMsgCount = unreadMsgCount + 1
|
|
115
129
|
}
|
|
116
130
|
// 如果是当前会话,那么未读消息需要设置为0
|
|
@@ -144,7 +158,7 @@ class ClientChat {
|
|
|
144
158
|
groupField: 'contactId',
|
|
145
159
|
sortField: 'sendTime',
|
|
146
160
|
clientChat: this,
|
|
147
|
-
|
|
161
|
+
checkMessageSendResultMethod: options.checkMessageSendResultMethod,
|
|
148
162
|
// loadLossMessageDataMethod: options.loadLossFriendMessageDataMethod,
|
|
149
163
|
queryMethod: (params) => {
|
|
150
164
|
return options.loadFriendMessageDataMethod(params)
|
|
@@ -154,8 +168,10 @@ class ClientChat {
|
|
|
154
168
|
groupField: 'roomId',
|
|
155
169
|
sortField: 'sendTime',
|
|
156
170
|
clientChat: this,
|
|
171
|
+
checkMessageSendResultMethod: options.checkMessageSendResultMethod,
|
|
157
172
|
onAddMessageSuccess: ({ data }) => {
|
|
158
|
-
|
|
173
|
+
const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : data.qwAccountId
|
|
174
|
+
let sessionId = createSessionId(accountId, data.roomId)
|
|
159
175
|
// 更新会话
|
|
160
176
|
if (!sessionId) {
|
|
161
177
|
return
|
|
@@ -170,6 +186,15 @@ class ClientChat {
|
|
|
170
186
|
return this.session.getSession(sessionId).then(done)
|
|
171
187
|
})
|
|
172
188
|
this._sessionPollRequestMap[sessionId].start().then((rs) => {
|
|
189
|
+
// 后端更新会话是异步过程,返回的会话信息可能还未包含当前消息
|
|
190
|
+
if (rs && rs.data && !rs.data.unreadMsgCount) {
|
|
191
|
+
rs.data.unreadMsgCount = data.send ? 0 : 1
|
|
192
|
+
rs.data.lastMsgContent = data.content
|
|
193
|
+
rs.data.lastMsgType = data.msgType
|
|
194
|
+
rs.data.lastMsgTime = data.sendTime
|
|
195
|
+
rs.data.lastMsgId = data.id
|
|
196
|
+
rs.data.lastUpdateTime = data.updateDate
|
|
197
|
+
}
|
|
173
198
|
// 更新账号未读消息数量
|
|
174
199
|
this.account.updateAccountUnreadMessageNum(rs.data.qwAccountId, ({ unreadMesasgeNum }) => {
|
|
175
200
|
return unreadMesasgeNum += (rs.data.unreadMsgCount || 0)
|
|
@@ -180,7 +205,7 @@ class ClientChat {
|
|
|
180
205
|
} else {
|
|
181
206
|
this.session.updateSession(sessionId, ({ session }) => {
|
|
182
207
|
let unreadMsgCount = session.unreadMsgCount
|
|
183
|
-
if (!data.
|
|
208
|
+
if (!data.send) {
|
|
184
209
|
unreadMsgCount = unreadMsgCount + 1
|
|
185
210
|
}
|
|
186
211
|
// 如果是当前会话,那么未读消息需要设置为0
|
|
@@ -214,7 +239,7 @@ class ClientChat {
|
|
|
214
239
|
groupField: 'roomId',
|
|
215
240
|
sortField: 'sendTime',
|
|
216
241
|
clientChat: this,
|
|
217
|
-
|
|
242
|
+
checkMessageSendResultMethod: options.checkMessageSendResultMethod,
|
|
218
243
|
// loadLossMessageDataMethod: options.loadLossRoomMessageDataMethod,
|
|
219
244
|
queryMethod: (params) => {
|
|
220
245
|
return options.loadRoomMessageDataMethod(params)
|
|
@@ -258,6 +283,77 @@ class ClientChat {
|
|
|
258
283
|
})
|
|
259
284
|
this.socket = new ClientChatSocket({
|
|
260
285
|
socket: options.socket,
|
|
286
|
+
onCmdQwContactInfoChanged: ({ data }) => {
|
|
287
|
+
const contacts = data && (Array.isArray(data.contacts)
|
|
288
|
+
? data.contacts
|
|
289
|
+
: (data.contactId ? [data] : []))
|
|
290
|
+
if (!contacts || !contacts.length) {
|
|
291
|
+
this.markAccountsModified(data && data.qwAccountIds)
|
|
292
|
+
return
|
|
293
|
+
}
|
|
294
|
+
const tasks = []
|
|
295
|
+
const removedTasks = []
|
|
296
|
+
contacts.forEach(contact => {
|
|
297
|
+
if (!contact) {
|
|
298
|
+
return
|
|
299
|
+
}
|
|
300
|
+
const changeType = Number(contact.changeType)
|
|
301
|
+
if (changeType === 1) {
|
|
302
|
+
tasks.push(this.handleQwContactAdded(contact, data))
|
|
303
|
+
} else if (changeType === 2) {
|
|
304
|
+
tasks.push(this.handleQwContactUpdated(contact))
|
|
305
|
+
} else if (changeType === 3) {
|
|
306
|
+
removedTasks.push(this.handleQwContactRemoved(contact, data))
|
|
307
|
+
}
|
|
308
|
+
})
|
|
309
|
+
return Promise.all(tasks.concat(removedTasks)).then(results => {
|
|
310
|
+
const accountUnreadCountMap = {}
|
|
311
|
+
removedTasks.forEach((task, index) => {
|
|
312
|
+
const result = results[tasks.length + index]
|
|
313
|
+
if (!result || !result.accountId || !result.unreadCount) {
|
|
314
|
+
return
|
|
315
|
+
}
|
|
316
|
+
accountUnreadCountMap[result.accountId] = (accountUnreadCountMap[result.accountId] || 0) + result.unreadCount
|
|
317
|
+
})
|
|
318
|
+
return Promise.all(Object.keys(accountUnreadCountMap).map(accountId => {
|
|
319
|
+
const removedUnreadCount = accountUnreadCountMap[accountId]
|
|
320
|
+
return this.account.updateAccountUnreadMessageNum(accountId, ({ unreadMesasgeNum }) => {
|
|
321
|
+
return Math.max(0, unreadMesasgeNum - removedUnreadCount)
|
|
322
|
+
}).catch(error => {
|
|
323
|
+
console.warn('[client-chat] update account unread count failed', error)
|
|
324
|
+
})
|
|
325
|
+
}))
|
|
326
|
+
})
|
|
327
|
+
},
|
|
328
|
+
onCmdQwRoomInfoChanged: ({ data }) => {
|
|
329
|
+
const rooms = data && (Array.isArray(data.rooms)
|
|
330
|
+
? data.rooms
|
|
331
|
+
: (data.roomId ? [data] : []))
|
|
332
|
+
if (!rooms || !rooms.length) {
|
|
333
|
+
this.markAccountsModified(data && data.qwAccountIds)
|
|
334
|
+
return
|
|
335
|
+
}
|
|
336
|
+
const tasks = []
|
|
337
|
+
const removedTasks = []
|
|
338
|
+
rooms.forEach(room => {
|
|
339
|
+
if (!room) {
|
|
340
|
+
return
|
|
341
|
+
}
|
|
342
|
+
const changeType = Number(room.changeType)
|
|
343
|
+
if (changeType === 1) {
|
|
344
|
+
tasks.push(this.handleQwRoomAdded(room, data))
|
|
345
|
+
} else if (changeType === 2) {
|
|
346
|
+
tasks.push(this.handleQwRoomUpdated(room))
|
|
347
|
+
} else if (changeType === 3) {
|
|
348
|
+
removedTasks.push(this.handleQwRoomRemoved(room, data))
|
|
349
|
+
}
|
|
350
|
+
})
|
|
351
|
+
return Promise.all(tasks.concat(removedTasks)).then(results => {
|
|
352
|
+
return this.updateRemovedSessionUnreadCounts(
|
|
353
|
+
results.slice(tasks.length)
|
|
354
|
+
)
|
|
355
|
+
})
|
|
356
|
+
},
|
|
261
357
|
// 接受新消息
|
|
262
358
|
onCmdQwNewMessage: ({ data }) => {
|
|
263
359
|
// 插入消息
|
|
@@ -279,19 +375,193 @@ class ClientChat {
|
|
|
279
375
|
})
|
|
280
376
|
},
|
|
281
377
|
onHeartbeatSuccess: ({ data }) => {
|
|
282
|
-
|
|
283
|
-
return
|
|
284
|
-
}
|
|
285
|
-
const onlineMap = data.wq || {}
|
|
378
|
+
const onlineMap = data || {}
|
|
286
379
|
Object.keys(onlineMap).forEach(k => {
|
|
287
380
|
this.account.updateAccount(k, {
|
|
288
381
|
alive: onlineMap[k]
|
|
289
|
-
})
|
|
382
|
+
})
|
|
383
|
+
})
|
|
384
|
+
}
|
|
385
|
+
})
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
getQwAccountCorpId (qwAccountId, corpId) {
|
|
389
|
+
if (corpId || !qwAccountId || !this.account) {
|
|
390
|
+
return corpId
|
|
391
|
+
}
|
|
392
|
+
const account = this.account.getAccountData().find(item => item.id === qwAccountId)
|
|
393
|
+
return account && account.corpId
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
markAccountsModified (qwAccountIds) {
|
|
397
|
+
if (!Array.isArray(qwAccountIds) || !qwAccountIds.length) {
|
|
398
|
+
return
|
|
399
|
+
}
|
|
400
|
+
this.session.markModify(qwAccountIds)
|
|
401
|
+
this.contacts.markModify(qwAccountIds)
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
updateRemovedSessionUnreadCounts (results) {
|
|
405
|
+
const accountUnreadCountMap = {}
|
|
406
|
+
;(results || []).forEach(result => {
|
|
407
|
+
if (!result || !result.accountId || !result.unreadCount) {
|
|
408
|
+
return
|
|
409
|
+
}
|
|
410
|
+
accountUnreadCountMap[result.accountId] = (accountUnreadCountMap[result.accountId] || 0) + result.unreadCount
|
|
411
|
+
})
|
|
412
|
+
return Promise.all(Object.keys(accountUnreadCountMap).map(accountId => {
|
|
413
|
+
const removedUnreadCount = accountUnreadCountMap[accountId]
|
|
414
|
+
return this.account.updateAccountUnreadMessageNum(accountId, ({ unreadMesasgeNum }) => {
|
|
415
|
+
return Math.max(0, unreadMesasgeNum - removedUnreadCount)
|
|
416
|
+
}).catch(error => {
|
|
417
|
+
console.warn('[client-chat] update account unread count failed', error)
|
|
418
|
+
})
|
|
419
|
+
}))
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
handleQwContactAdded (contact, eventData) {
|
|
423
|
+
const qwAccountId = contact.qwAccountId || (eventData && eventData.qwAccountId)
|
|
424
|
+
const corpId = this.getQwAccountCorpId(
|
|
425
|
+
qwAccountId,
|
|
426
|
+
contact.corpId || (eventData && eventData.corpId)
|
|
427
|
+
)
|
|
428
|
+
const contactId = contact.contactId
|
|
429
|
+
const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
|
|
430
|
+
const sessionId = createSessionId(accountId, contactId)
|
|
431
|
+
if (!sessionId) {
|
|
432
|
+
return Promise.resolve()
|
|
433
|
+
}
|
|
434
|
+
const localSession = this.session.getSessionByLocal(sessionId)
|
|
435
|
+
const oldUnread = localSession ? (localSession.unreadMsgCount || 0) : 0
|
|
436
|
+
return this.session.refreshSession(sessionId).then(rs => {
|
|
437
|
+
const serverSession = rs && rs.data
|
|
438
|
+
const newUnread = serverSession ? (serverSession.unreadMsgCount || 0) : 0
|
|
439
|
+
const accountId = (serverSession && serverSession.qwAccountId) || qwAccountId
|
|
440
|
+
const unreadDiff = newUnread - oldUnread
|
|
441
|
+
if (accountId && unreadDiff) {
|
|
442
|
+
return this.account.updateAccountUnreadMessageNum(accountId, ({ unreadMesasgeNum }) => {
|
|
443
|
+
return Math.max(0, unreadMesasgeNum + unreadDiff)
|
|
290
444
|
})
|
|
291
445
|
}
|
|
446
|
+
}).catch(error => {
|
|
447
|
+
console.warn('[client-chat] refresh added contact session failed', error)
|
|
448
|
+
})
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
handleQwContactUpdated (contact) {
|
|
452
|
+
if (!contact.contactId) {
|
|
453
|
+
return Promise.resolve()
|
|
454
|
+
}
|
|
455
|
+
return this.contacts.refreshFriend(contact.contactId).catch(error => {
|
|
456
|
+
console.warn('[client-chat] refresh contact failed', error)
|
|
457
|
+
})
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
handleQwContactRemoved (contact, eventData) {
|
|
461
|
+
if (!contact.contactId) {
|
|
462
|
+
return Promise.resolve()
|
|
463
|
+
}
|
|
464
|
+
this.contacts.removeFriend(contact.contactId)
|
|
465
|
+
let session = this.session.findSession(({ session }) => {
|
|
466
|
+
return String(session.type) === '0' &&
|
|
467
|
+
session.targetId === contact.contactId &&
|
|
468
|
+
(!contact.qwAccountId || session.qwAccountId === contact.qwAccountId)
|
|
469
|
+
})
|
|
470
|
+
if (!session) {
|
|
471
|
+
const qwAccountId = contact.qwAccountId || (eventData && eventData.qwAccountId)
|
|
472
|
+
const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
|
|
473
|
+
const sessionId = createSessionId(
|
|
474
|
+
accountId,
|
|
475
|
+
contact.contactId
|
|
476
|
+
)
|
|
477
|
+
session = sessionId && this.session.getSessionByLocal(sessionId)
|
|
478
|
+
}
|
|
479
|
+
if (!session) {
|
|
480
|
+
return Promise.resolve()
|
|
481
|
+
}
|
|
482
|
+
if (this.session.currentSession && this.session.currentSession.id === session.id) {
|
|
483
|
+
this.session.setCurrentSession(null)
|
|
484
|
+
}
|
|
485
|
+
const accountId = session.qwAccountId || contact.qwAccountId
|
|
486
|
+
const unreadCount = session.unreadMsgCount || 0
|
|
487
|
+
this.session.removeSession(session.id)
|
|
488
|
+
return Promise.resolve({
|
|
489
|
+
accountId,
|
|
490
|
+
unreadCount
|
|
292
491
|
})
|
|
293
492
|
}
|
|
294
493
|
|
|
494
|
+
handleQwRoomAdded (room, eventData) {
|
|
495
|
+
if (!room.roomId) {
|
|
496
|
+
return Promise.resolve()
|
|
497
|
+
}
|
|
498
|
+
const qwAccountId = room.qwAccountId || (eventData && eventData.qwAccountId)
|
|
499
|
+
const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
|
|
500
|
+
const sessionId = createSessionId(accountId, room.roomId)
|
|
501
|
+
const localSession = sessionId && this.session.getSessionByLocal(sessionId)
|
|
502
|
+
const oldUnread = localSession ? (localSession.unreadMsgCount || 0) : 0
|
|
503
|
+
const tasks = [this.contacts.refreshRoom(room.roomId).catch(error => {
|
|
504
|
+
console.warn('[client-chat] refresh added room failed', error)
|
|
505
|
+
})]
|
|
506
|
+
if (sessionId) {
|
|
507
|
+
tasks.push(this.session.refreshSession(sessionId).then(rs => {
|
|
508
|
+
const serverSession = rs && rs.data
|
|
509
|
+
const unreadDiff = (serverSession ? (serverSession.unreadMsgCount || 0) : 0) - oldUnread
|
|
510
|
+
const changedAccountId = (serverSession && serverSession.qwAccountId) || qwAccountId
|
|
511
|
+
if (changedAccountId && unreadDiff) {
|
|
512
|
+
return this.account.updateAccountUnreadMessageNum(changedAccountId, ({ unreadMesasgeNum }) => {
|
|
513
|
+
return Math.max(0, unreadMesasgeNum + unreadDiff)
|
|
514
|
+
})
|
|
515
|
+
}
|
|
516
|
+
}).catch(error => {
|
|
517
|
+
console.warn('[client-chat] refresh added room session failed', error)
|
|
518
|
+
}))
|
|
519
|
+
}
|
|
520
|
+
return Promise.all(tasks)
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
handleQwRoomUpdated (room) {
|
|
524
|
+
if (!room.roomId) {
|
|
525
|
+
return Promise.resolve()
|
|
526
|
+
}
|
|
527
|
+
return this.contacts.refreshRoom(room.roomId).catch(error => {
|
|
528
|
+
console.warn('[client-chat] refresh room failed', error)
|
|
529
|
+
})
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
handleQwRoomRemoved (room, eventData) {
|
|
533
|
+
if (!room.roomId) {
|
|
534
|
+
return Promise.resolve()
|
|
535
|
+
}
|
|
536
|
+
this.contacts.removeRoom(room.roomId)
|
|
537
|
+
this.event.emit('roomRemoved', {
|
|
538
|
+
roomId: room.roomId
|
|
539
|
+
})
|
|
540
|
+
const qwAccountId = room.qwAccountId || (eventData && eventData.qwAccountId)
|
|
541
|
+
let session = this.session.findSession(({ session }) => {
|
|
542
|
+
return String(session.type) === '1' &&
|
|
543
|
+
session.targetId === room.roomId &&
|
|
544
|
+
(!qwAccountId || session.qwAccountId === qwAccountId)
|
|
545
|
+
})
|
|
546
|
+
if (!session) {
|
|
547
|
+
const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
|
|
548
|
+
const sessionId = createSessionId(accountId, room.roomId)
|
|
549
|
+
session = sessionId && this.session.getSessionByLocal(sessionId)
|
|
550
|
+
}
|
|
551
|
+
if (!session) {
|
|
552
|
+
return Promise.resolve()
|
|
553
|
+
}
|
|
554
|
+
if (this.session.currentSession && this.session.currentSession.id === session.id) {
|
|
555
|
+
this.session.setCurrentSession(null)
|
|
556
|
+
}
|
|
557
|
+
const unreadCount = session.unreadMsgCount || 0
|
|
558
|
+
this.session.removeSession(session.id)
|
|
559
|
+
return Promise.resolve({
|
|
560
|
+
accountId: session.qwAccountId || qwAccountId,
|
|
561
|
+
unreadCount
|
|
562
|
+
})
|
|
563
|
+
}
|
|
564
|
+
|
|
295
565
|
connect () {
|
|
296
566
|
if (this.data.connectStatus === CONNECT_STATUS.Complete) {
|
|
297
567
|
return Promise.resolve()
|
|
@@ -328,4 +598,4 @@ class ClientChat {
|
|
|
328
598
|
}
|
|
329
599
|
}
|
|
330
600
|
|
|
331
|
-
export default ClientChat
|
|
601
|
+
export default ClientChat
|
|
@@ -13,11 +13,11 @@ export function isUni () {
|
|
|
13
13
|
* @param accountId - 客服id
|
|
14
14
|
* @param targetId - wechatFriendId | wechatChatroomId
|
|
15
15
|
*/
|
|
16
|
-
export function createSessionId (
|
|
17
|
-
if (!
|
|
16
|
+
export function createSessionId (accountId, targetId) {
|
|
17
|
+
if (!accountId || !targetId) {
|
|
18
18
|
return
|
|
19
19
|
}
|
|
20
|
-
return shajs('sha1').update(`${
|
|
20
|
+
return shajs('sha1').update(`${accountId}${targetId}`).digest('hex')
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -54,7 +54,7 @@ export function createSessionId (corpId, accountId, targetId) {
|
|
|
54
54
|
* "msgSvrId": "4319123759514541049",
|
|
55
55
|
* "msgType": 1,
|
|
56
56
|
* "origin": "0",
|
|
57
|
-
* "
|
|
57
|
+
* "status": 0,
|
|
58
58
|
* "tenantId": "1761952223049924608",
|
|
59
59
|
* "wechatAccountId": "ad9d9ae2a8be4f27311312cdd4af3549dc8427ef",
|
|
60
60
|
* "wechatFriendId": "2089efcc7f8f40b00b7f05fa4c6dfd3bb642774d",
|
|
@@ -79,4 +79,4 @@ export function createSessionData (message) {
|
|
|
79
79
|
wechatAccountId: message.wechatAccountId
|
|
80
80
|
}
|
|
81
81
|
return nextSession
|
|
82
|
-
}
|
|
82
|
+
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import SdkChatPanelBox from '../../../chat-panel/chat-panel-box'
|
|
3
|
-
import { companyCard } from '../../../wework-chat-control'
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
name: 'SdkWeworkChatPanelControlsCompanyCard',
|
|
7
|
-
functional: true,
|
|
8
|
-
props: {
|
|
9
|
-
dir: {
|
|
10
|
-
type: String
|
|
11
|
-
},
|
|
12
|
-
data: {
|
|
13
|
-
type: Object,
|
|
14
|
-
required: true
|
|
15
|
-
},
|
|
16
|
-
fetchUserMethod: {
|
|
17
|
-
type: Function
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
render (h, c) {
|
|
21
|
-
const { props } = c
|
|
22
|
-
return h(SdkChatPanelBox, {
|
|
23
|
-
props: {
|
|
24
|
-
dir: props.dir,
|
|
25
|
-
data: props.data,
|
|
26
|
-
fetchUserMethod: props.fetchUserMethod
|
|
27
|
-
}
|
|
28
|
-
}, [h(companyCard, {
|
|
29
|
-
props: {
|
|
30
|
-
data: props.data
|
|
31
|
-
}
|
|
32
|
-
})])
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
</script>
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { expression } from '../../../wework-chat-control'
|
|
3
|
-
import SdkChatPanelBox from '../../../chat-panel/chat-panel-box'
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
name: 'SdkWeworkChatPanelControlsExpression',
|
|
7
|
-
functional: true,
|
|
8
|
-
props: {
|
|
9
|
-
dir: {
|
|
10
|
-
type: String
|
|
11
|
-
},
|
|
12
|
-
data: {
|
|
13
|
-
type: Object,
|
|
14
|
-
default: () => ({})
|
|
15
|
-
},
|
|
16
|
-
fetchUserMethod: {
|
|
17
|
-
type: Function
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
render (h, c) {
|
|
21
|
-
const { props } = c
|
|
22
|
-
return h(SdkChatPanelBox, {
|
|
23
|
-
props: {
|
|
24
|
-
dir: props.dir,
|
|
25
|
-
data: props.data,
|
|
26
|
-
fetchUserMethod: props.fetchUserMethod
|
|
27
|
-
}
|
|
28
|
-
}, [h(expression, {
|
|
29
|
-
props: {
|
|
30
|
-
data: props.data
|
|
31
|
-
},
|
|
32
|
-
key: c.data.key
|
|
33
|
-
})])
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
</script>
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import SdkChatPanelBox from '../../../chat-panel/chat-panel-box'
|
|
3
|
-
import { fileUrl } from '../../../wework-chat-control'
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
name: 'SdkWeworkChatPanelControlsFileUrl',
|
|
7
|
-
functional: true,
|
|
8
|
-
props: {
|
|
9
|
-
dir: {
|
|
10
|
-
type: String
|
|
11
|
-
},
|
|
12
|
-
data: {
|
|
13
|
-
type: Object,
|
|
14
|
-
required: true
|
|
15
|
-
},
|
|
16
|
-
fetchUserMethod: {
|
|
17
|
-
type: Function
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
render (h, c) {
|
|
21
|
-
const { props } = c
|
|
22
|
-
return h(SdkChatPanelBox, {
|
|
23
|
-
props: {
|
|
24
|
-
dir: props.dir,
|
|
25
|
-
data: props.data,
|
|
26
|
-
fetchUserMethod: props.fetchUserMethod
|
|
27
|
-
}
|
|
28
|
-
}, [h(fileUrl, {
|
|
29
|
-
props: {
|
|
30
|
-
content: props.data.content
|
|
31
|
-
}
|
|
32
|
-
})])
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
</script>
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { image } from '../../../wework-chat-control'
|
|
3
|
-
import SdkChatPanelBox from '../../../chat-panel/chat-panel-box'
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
name: 'SdkWeworkChatPanelControlsImage',
|
|
7
|
-
functional: true,
|
|
8
|
-
props: {
|
|
9
|
-
dir: {
|
|
10
|
-
type: String
|
|
11
|
-
},
|
|
12
|
-
data: {
|
|
13
|
-
type: Object,
|
|
14
|
-
default: () => ({})
|
|
15
|
-
},
|
|
16
|
-
fetchUserMethod: {
|
|
17
|
-
type: Function
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
render (h, c) {
|
|
21
|
-
const { props } = c
|
|
22
|
-
return h(SdkChatPanelBox, {
|
|
23
|
-
props: {
|
|
24
|
-
dir: props.dir,
|
|
25
|
-
data: props.data,
|
|
26
|
-
fetchUserMethod: props.fetchUserMethod
|
|
27
|
-
}
|
|
28
|
-
}, [h(image, {
|
|
29
|
-
props: {
|
|
30
|
-
data: props.data
|
|
31
|
-
},
|
|
32
|
-
key: c.data.key
|
|
33
|
-
})])
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
</script>
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import text from './text/text.vue'
|
|
2
|
-
import link from './link/link.vue'
|
|
3
|
-
import companyCard from './company-card/company-card.vue'
|
|
4
|
-
import video from './video/video.vue'
|
|
5
|
-
import image from './image/image.vue'
|
|
6
|
-
import unkonw from './unkonw/unkonw.vue'
|
|
7
|
-
import expression from './expression/expression.vue'
|
|
8
|
-
import voice from './voice/voice.vue'
|
|
9
|
-
import jxSysText from './jx-sys-text/jx-sys-text.vue'
|
|
10
|
-
import fileUrl from './file-url/file-url.vue'
|
|
11
|
-
import location from './location/location.vue'
|
|
12
|
-
|
|
13
|
-
export default {
|
|
14
|
-
0: text,
|
|
15
|
-
2: text,
|
|
16
|
-
14: image,
|
|
17
|
-
101: image,
|
|
18
|
-
// '49': link,
|
|
19
|
-
22: video,
|
|
20
|
-
23: video,
|
|
21
|
-
103: video,
|
|
22
|
-
29: expression,
|
|
23
|
-
104: expression,
|
|
24
|
-
16: voice,
|
|
25
|
-
40: voice,
|
|
26
|
-
1011: jxSysText,
|
|
27
|
-
1022: jxSysText,
|
|
28
|
-
41: companyCard,
|
|
29
|
-
13: fileUrl,
|
|
30
|
-
15: fileUrl,
|
|
31
|
-
20: fileUrl,
|
|
32
|
-
102: fileUrl,
|
|
33
|
-
6: location,
|
|
34
|
-
unkonw
|
|
35
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { jxSysText } from '../../../wework-chat-control'
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
name: 'SdkWeworkChatPanelControlsJxSysText',
|
|
6
|
-
functional: true,
|
|
7
|
-
props: {
|
|
8
|
-
dir: {
|
|
9
|
-
type: String
|
|
10
|
-
},
|
|
11
|
-
data: {
|
|
12
|
-
type: Object,
|
|
13
|
-
required: true
|
|
14
|
-
},
|
|
15
|
-
fetchUserMethod: {
|
|
16
|
-
type: Function
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
render (h, c) {
|
|
20
|
-
const { props } = c
|
|
21
|
-
return h(jxSysText, {
|
|
22
|
-
props: {
|
|
23
|
-
content: props.data.content
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
</script>
|