@aochuang/client-sdk 1.0.382 → 1.0.401
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/chat-editor/chat-editor-suggestions/chat-editor-suggestions.vue +4 -40
- package/components/chat-editor/chat-editor.vue +5 -75
- package/components/index.js +6 -1
- package/components/session-select/session-select-item.vue +8 -9
- package/components/wechat-chat-control/location/location.vue +3 -3
- package/components/wework-chat-control/channel-card/channel-card.vue +144 -0
- package/components/wework-chat-control/channel-live/channel-live.vue +7 -2
- package/components/wework-chat-control/company-card/company-card.vue +1 -1
- package/components/wework-chat-control/custom-expression/custom-expression.vue +2 -1
- package/components/wework-chat-control/file-url/file-url.vue +34 -16
- package/components/wework-chat-control/image/image.vue +137 -2
- package/components/wework-chat-control/index.js +15 -7
- package/components/wework-chat-control/location/location.vue +3 -3
- package/components/wework-chat-control/merge-message/merge-message-panel.vue +63 -0
- package/components/wework-chat-control/merge-message/merge-message.vue +84 -0
- package/components/wework-chat-control/merge-message/util.js +59 -0
- package/components/wework-chat-control/metting/enterprise-wechat.png +0 -0
- package/components/wework-chat-control/metting/meeting-video.svg +4 -0
- package/components/wework-chat-control/metting/metting.vue +181 -0
- package/components/wework-chat-control/red-envelopes/red-envelopes.vue +3 -2
- package/components/wework-chat-control/text/text-default.vue +99 -0
- package/components/wework-chat-control/text/text-quote.vue +138 -0
- package/components/wework-chat-control/text/text.vue +27 -143
- package/components/wework-chat-control/url/url-channel-live.vue +53 -0
- package/components/wework-chat-control/url/url-miniprogram.vue +6 -7
- package/components/wework-chat-control/url/url.vue +26 -2
- package/components/wework-chat-control/util.js +30 -17
- package/components/wework-chat-control/video/video.vue +11 -3
- package/components/wework-chat-control/voice/voice.vue +14 -3
- 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 +120 -0
- package/components/wework-chat-panel/chat-panel-item.vue +70 -39
- package/components/wework-chat-panel/chat-panel.vue +96 -13
- package/package.json +10 -3
- package/services/client-chat/client-chat-wechat/client-chat-account.js +37 -7
- package/services/client-chat/client-chat-wechat/client-chat-message.js +175 -18
- package/services/client-chat/client-chat-wechat/client-chat-session.js +83 -10
- package/services/client-chat/client-chat-wechat/client-chat-socket.js +80 -22
- package/services/client-chat/client-chat-wechat/client-chat.js +59 -11
- package/services/client-chat/client-chat-wework/client-chat-account.js +93 -1
- package/services/client-chat/client-chat-wework/client-chat-concats.js +104 -18
- package/services/client-chat/client-chat-wework/client-chat-message.js +268 -11
- package/services/client-chat/client-chat-wework/client-chat-session.js +271 -191
- package/services/client-chat/client-chat-wework/client-chat-socket.js +18 -2
- package/services/client-chat/client-chat-wework/client-chat.js +470 -85
- package/services/client-chat/client-chat-wework/docs/README.md +308 -0
- package/services/client-chat/client-chat-wework/utils.js +5 -5
- package/services/socket/socket.js +56 -7
- package/utils/log/constants.js +13 -0
- package/utils/log/export.js +88 -0
- package/utils/log/findings.md +141 -0
- package/utils/log/index.js +331 -0
- package/utils/log/indexed-db.js +228 -0
- package/utils/log/progress.md +267 -0
- package/utils/log/serialize.js +146 -0
- package/utils/log/task_plan.md +149 -0
- package/utils/log//345/210/206/346/236/220/344/270/216/344/274/230/345/214/226/346/226/271/346/241/210.md +303 -0
- package/utils/log//346/212/200/346/234/257/346/226/271/346/241/210/346/226/207/346/241/243.md +201 -0
- package/utils/log//346/236/266/346/236/204/346/226/207/346/241/243.md +169 -0
- package/utils/log//351/234/200/346/261/202/346/226/207/346/241/243.md +124 -0
- package/utils/log.js +2 -626
- 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
|
@@ -232,20 +232,21 @@ export default class ClientChatSession {
|
|
|
232
232
|
})
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
_addGetSessionLog (
|
|
235
|
+
_addGetSessionLog (event, data) {
|
|
236
236
|
if (this.onGetSessionLog) {
|
|
237
237
|
this.onGetSessionLog({
|
|
238
|
-
group:
|
|
239
|
-
content: {
|
|
240
|
-
title,
|
|
241
|
-
data
|
|
242
|
-
}
|
|
238
|
+
group: `diagnostic:${event}`,
|
|
239
|
+
content: Object.assign({ event }, data)
|
|
243
240
|
})
|
|
244
241
|
}
|
|
245
242
|
}
|
|
246
243
|
|
|
247
244
|
getSession (sessionId, serializeMethod) {
|
|
248
245
|
if (this.sessionMap[sessionId]) {
|
|
246
|
+
this._addGetSessionLog('session_resolved', {
|
|
247
|
+
sessionId,
|
|
248
|
+
source: 'memory'
|
|
249
|
+
})
|
|
249
250
|
return Promise.resolve({
|
|
250
251
|
data: this.sessionMap[sessionId]
|
|
251
252
|
})
|
|
@@ -257,6 +258,10 @@ export default class ClientChatSession {
|
|
|
257
258
|
if (serializeMethod) {
|
|
258
259
|
pollRequest.serializeMethods.push(serializeMethod)
|
|
259
260
|
}
|
|
261
|
+
this._addGetSessionLog('session_poll_joined', {
|
|
262
|
+
sessionId,
|
|
263
|
+
mergedCount: pollRequest.serializeMethods.length
|
|
264
|
+
})
|
|
260
265
|
return pollRequest.ps
|
|
261
266
|
}
|
|
262
267
|
|
|
@@ -283,7 +288,7 @@ export default class ClientChatSession {
|
|
|
283
288
|
pollRequest.lastRequestError = null
|
|
284
289
|
pollRequest.startedAt = Date.now()
|
|
285
290
|
this.pollRequestMap[sessionId] = pollRequest
|
|
286
|
-
this._addGetSessionLog('
|
|
291
|
+
this._addGetSessionLog('session_poll_started', {
|
|
287
292
|
sessionId,
|
|
288
293
|
spanTime: GET_SESSION_POLL_SPAN_TIME,
|
|
289
294
|
timeout: GET_SESSION_POLL_TIMEOUT
|
|
@@ -312,7 +317,7 @@ export default class ClientChatSession {
|
|
|
312
317
|
unreadDelta: context.accountUnreadDelta
|
|
313
318
|
})
|
|
314
319
|
const wechatAccountId = rs.data.wechatAccountId
|
|
315
|
-
this._addGetSessionLog('
|
|
320
|
+
this._addGetSessionLog('session_poll_completed', {
|
|
316
321
|
sessionId,
|
|
317
322
|
requestCount: pollRequest.requestCount,
|
|
318
323
|
emptyResponseCount: pollRequest.emptyResponseCount,
|
|
@@ -330,7 +335,7 @@ export default class ClientChatSession {
|
|
|
330
335
|
})
|
|
331
336
|
return rs
|
|
332
337
|
}).catch((error) => {
|
|
333
|
-
this._addGetSessionLog('
|
|
338
|
+
this._addGetSessionLog('session_poll_failed', {
|
|
334
339
|
sessionId,
|
|
335
340
|
isTimeout: error === 'timeout',
|
|
336
341
|
timeout: GET_SESSION_POLL_TIMEOUT,
|
|
@@ -930,6 +935,16 @@ export default class ClientChatSession {
|
|
|
930
935
|
}
|
|
931
936
|
}
|
|
932
937
|
if (changeProps && Object.keys(changeProps).length) {
|
|
938
|
+
if (changeProps.unreadMsgCount) {
|
|
939
|
+
this._addGetSessionLog('session_unread_changed', {
|
|
940
|
+
sessionId,
|
|
941
|
+
wechatAccountId: session.wechatAccountId,
|
|
942
|
+
source: 'updateSession',
|
|
943
|
+
before: changeProps.unreadMsgCount.before,
|
|
944
|
+
after: changeProps.unreadMsgCount.after,
|
|
945
|
+
delta: (changeProps.unreadMsgCount.after || 0) - (changeProps.unreadMsgCount.before || 0)
|
|
946
|
+
})
|
|
947
|
+
}
|
|
933
948
|
this.onUpdateSession && this.onUpdateSession({
|
|
934
949
|
session,
|
|
935
950
|
changeProps,
|
|
@@ -949,10 +964,30 @@ export default class ClientChatSession {
|
|
|
949
964
|
if (!session) {
|
|
950
965
|
return
|
|
951
966
|
}
|
|
967
|
+
const oldUnreadMsgCount = session.unreadMsgCount || 0
|
|
968
|
+
this._addGetSessionLog('session_read_requested', {
|
|
969
|
+
sessionId,
|
|
970
|
+
wechatAccountId: session.wechatAccountId,
|
|
971
|
+
oldUnreadMsgCount
|
|
972
|
+
})
|
|
952
973
|
return this.updateSessionRead({
|
|
953
974
|
conversationId: sessionId
|
|
954
975
|
}).then(() => {
|
|
955
976
|
this.markSessionRead(sessionId)
|
|
977
|
+
this._addGetSessionLog('session_read_applied', {
|
|
978
|
+
sessionId,
|
|
979
|
+
wechatAccountId: session.wechatAccountId,
|
|
980
|
+
oldUnreadMsgCount,
|
|
981
|
+
unreadMsgCount: 0
|
|
982
|
+
})
|
|
983
|
+
}).catch(error => {
|
|
984
|
+
this._addGetSessionLog('session_read_failed', {
|
|
985
|
+
sessionId,
|
|
986
|
+
wechatAccountId: session.wechatAccountId,
|
|
987
|
+
oldUnreadMsgCount,
|
|
988
|
+
error: error && (error.message || error.errMsg || error.toString && error.toString()) || error
|
|
989
|
+
})
|
|
990
|
+
return Promise.reject(error)
|
|
956
991
|
})
|
|
957
992
|
}
|
|
958
993
|
|
|
@@ -1143,6 +1178,13 @@ export default class ClientChatSession {
|
|
|
1143
1178
|
lastUpdateTime: null // 最后更新时间
|
|
1144
1179
|
})
|
|
1145
1180
|
this.data.loading = true
|
|
1181
|
+
const startedAt = Date.now()
|
|
1182
|
+
this._addGetSessionLog('session_list_requested', {
|
|
1183
|
+
mode: 'reload',
|
|
1184
|
+
wechatAccountId: params.wechatAccountId,
|
|
1185
|
+
lastUpdateTime: params.lastUpdateTime,
|
|
1186
|
+
size: params.size
|
|
1187
|
+
})
|
|
1146
1188
|
const ps1 = this.loadSessionData(params, {
|
|
1147
1189
|
lastSession: null,
|
|
1148
1190
|
lastUpdateSession: null,
|
|
@@ -1150,7 +1192,7 @@ export default class ClientChatSession {
|
|
|
1150
1192
|
})
|
|
1151
1193
|
ps1.then((rs) => {
|
|
1152
1194
|
this.setSessionData(rs.data, params.wechatAccountId || ALL_WECHAT_ACCOUNT_ID)
|
|
1153
|
-
})
|
|
1195
|
+
}, () => {})
|
|
1154
1196
|
if (this.cancelLoadDataRequest) {
|
|
1155
1197
|
this.cancelLoadDataRequest()
|
|
1156
1198
|
}
|
|
@@ -1159,9 +1201,21 @@ export default class ClientChatSession {
|
|
|
1159
1201
|
}
|
|
1160
1202
|
return Promise.all([ps1]).then((rs) => {
|
|
1161
1203
|
this.data.loading = false
|
|
1204
|
+
this._addGetSessionLog('session_list_applied', {
|
|
1205
|
+
mode: 'reload',
|
|
1206
|
+
wechatAccountId: params.wechatAccountId,
|
|
1207
|
+
count: rs[0] && rs[0].data && rs[0].data.length || 0,
|
|
1208
|
+
duration: Date.now() - startedAt
|
|
1209
|
+
})
|
|
1162
1210
|
return rs[0]
|
|
1163
1211
|
}, err => {
|
|
1164
1212
|
this.data.loading = false
|
|
1213
|
+
this._addGetSessionLog('session_list_failed', {
|
|
1214
|
+
mode: 'reload',
|
|
1215
|
+
wechatAccountId: params.wechatAccountId,
|
|
1216
|
+
duration: Date.now() - startedAt,
|
|
1217
|
+
error: err && (err.message || err.errMsg || err.toString && err.toString()) || err
|
|
1218
|
+
})
|
|
1165
1219
|
return Promise.reject(err)
|
|
1166
1220
|
})
|
|
1167
1221
|
}
|
|
@@ -1173,6 +1227,13 @@ export default class ClientChatSession {
|
|
|
1173
1227
|
size: 20 // 本次要获取的会话条数
|
|
1174
1228
|
}, params)
|
|
1175
1229
|
this.data.loading = true
|
|
1230
|
+
const startedAt = Date.now()
|
|
1231
|
+
this._addGetSessionLog('session_list_requested', {
|
|
1232
|
+
mode: 'load_more',
|
|
1233
|
+
wechatAccountId: params.wechatAccountId,
|
|
1234
|
+
lastUpdateTime: params.lastUpdateTime,
|
|
1235
|
+
size: params.size
|
|
1236
|
+
})
|
|
1176
1237
|
let lastSession = this._getLastSessionBySessionGroup(params.wechatAccountId || ALL_WECHAT_ACCOUNT_ID)
|
|
1177
1238
|
const ps1 = this.loadSessionData(params, {
|
|
1178
1239
|
lastSession,
|
|
@@ -1190,9 +1251,21 @@ export default class ClientChatSession {
|
|
|
1190
1251
|
}
|
|
1191
1252
|
return Promise.all([ps1]).then((rs) => {
|
|
1192
1253
|
this.data.loading = false
|
|
1254
|
+
this._addGetSessionLog('session_list_applied', {
|
|
1255
|
+
mode: 'load_more',
|
|
1256
|
+
wechatAccountId: params.wechatAccountId,
|
|
1257
|
+
count: rs[0] && rs[0].data && rs[0].data.length || 0,
|
|
1258
|
+
duration: Date.now() - startedAt
|
|
1259
|
+
})
|
|
1193
1260
|
return rs[0]
|
|
1194
1261
|
}, err => {
|
|
1195
1262
|
this.data.loading = false
|
|
1263
|
+
this._addGetSessionLog('session_list_failed', {
|
|
1264
|
+
mode: 'load_more',
|
|
1265
|
+
wechatAccountId: params.wechatAccountId,
|
|
1266
|
+
duration: Date.now() - startedAt,
|
|
1267
|
+
error: err && (err.message || err.errMsg || err.toString && err.toString()) || err
|
|
1268
|
+
})
|
|
1196
1269
|
return Promise.reject(err)
|
|
1197
1270
|
})
|
|
1198
1271
|
}
|
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
import Socket from '../../socket'
|
|
2
2
|
|
|
3
|
+
const LOG_CONTENT_MAX_LENGTH = 100
|
|
4
|
+
|
|
5
|
+
function cloneLogData (data) {
|
|
6
|
+
const cloneData = Object.assign({}, data)
|
|
7
|
+
;['content', 'contBody'].forEach(field => {
|
|
8
|
+
if (typeof cloneData[field] === 'string') {
|
|
9
|
+
const contentLength = cloneData[field].length
|
|
10
|
+
if (contentLength > LOG_CONTENT_MAX_LENGTH) {
|
|
11
|
+
cloneData[field] = `${cloneData[field].substr(0, LOG_CONTENT_MAX_LENGTH)}...+${contentLength - LOG_CONTENT_MAX_LENGTH}`
|
|
12
|
+
}
|
|
13
|
+
} else if (cloneData[field] !== undefined) {
|
|
14
|
+
cloneData[`${field}Type`] = typeof cloneData[field]
|
|
15
|
+
delete cloneData[field]
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
delete cloneData.accessToken
|
|
19
|
+
delete cloneData.token
|
|
20
|
+
return cloneData
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getMessageDiagnosticData (data) {
|
|
24
|
+
const message = data && (data.friendMessage || data.chatroomMessage) || {}
|
|
25
|
+
return {
|
|
26
|
+
messageId: message.id || data && data.id,
|
|
27
|
+
msgSvrId: message.msgSvrId || data && data.msgSvrId
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function getSocketMessageLogData (data) {
|
|
32
|
+
const cloneData = Object.assign({}, data)
|
|
33
|
+
;['friendMessage', 'chatroomMessage'].forEach(field => {
|
|
34
|
+
if (!cloneData[field] || typeof cloneData[field] !== 'object') {
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
cloneData[field] = Object.assign({}, cloneData[field])
|
|
38
|
+
delete cloneData[field].accessToken
|
|
39
|
+
delete cloneData[field].token
|
|
40
|
+
})
|
|
41
|
+
delete cloneData.accessToken
|
|
42
|
+
delete cloneData.token
|
|
43
|
+
return cloneData
|
|
44
|
+
}
|
|
45
|
+
|
|
3
46
|
export default class Websocket {
|
|
4
47
|
get connectStatus () {
|
|
5
48
|
return this.socket.connectStatus
|
|
@@ -12,6 +55,7 @@ export default class Websocket {
|
|
|
12
55
|
constructor (options) {
|
|
13
56
|
options = Object.assign({
|
|
14
57
|
socket: null,
|
|
58
|
+
log: null,
|
|
15
59
|
// 检查socket事件通知方法,有些场景不需要后端推送的命令执行,比如管理后台
|
|
16
60
|
checkSocketEventNotifyMethod: null,
|
|
17
61
|
// 执行回调事件前的方法
|
|
@@ -40,7 +84,8 @@ export default class Websocket {
|
|
|
40
84
|
throw new Error('socket实例不能为空')
|
|
41
85
|
}
|
|
42
86
|
this.socket = options.socket
|
|
43
|
-
this.
|
|
87
|
+
this.log = options.log || this.socket.log || null
|
|
88
|
+
this.log && this.log.onBeforeAdd && this.log.onBeforeAdd(({ data }) => {
|
|
44
89
|
// 收消息需要拦截一些,因为下面有了
|
|
45
90
|
if (data && ['socket:sendMessage'].includes(data.group)) {
|
|
46
91
|
return false
|
|
@@ -55,23 +100,35 @@ export default class Websocket {
|
|
|
55
100
|
}
|
|
56
101
|
})
|
|
57
102
|
this.socket.event.on('onCmdNewMessage', (evt) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
103
|
+
const messageLogData = getSocketMessageLogData(evt && evt.data)
|
|
104
|
+
if (options.checkSocketEventNotifyMethod && options.checkSocketEventNotifyMethod(evt) === false) {
|
|
105
|
+
this.addLog({
|
|
106
|
+
group: 'diagnostic:message_received_suppressed',
|
|
107
|
+
content: Object.assign({
|
|
108
|
+
event: 'message_received_suppressed',
|
|
109
|
+
reason: 'notify_filter',
|
|
110
|
+
data: messageLogData
|
|
111
|
+
}, getMessageDiagnosticData(evt && evt.data))
|
|
112
|
+
})
|
|
113
|
+
} else {
|
|
114
|
+
let processingError
|
|
115
|
+
try {
|
|
116
|
+
options.onCmdNewMessage(evt)
|
|
117
|
+
} catch (error) {
|
|
118
|
+
processingError = error
|
|
63
119
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
120
|
+
this.addLog({
|
|
121
|
+
group: 'diagnostic:message_received',
|
|
122
|
+
content: Object.assign({
|
|
123
|
+
event: 'message_received',
|
|
124
|
+
result: processingError ? 'failed' : 'success',
|
|
125
|
+
errorType: processingError && (processingError.name || processingError.code) || undefined,
|
|
126
|
+
data: messageLogData
|
|
127
|
+
}, getMessageDiagnosticData(evt && evt.data))
|
|
73
128
|
})
|
|
74
|
-
|
|
129
|
+
if (processingError) {
|
|
130
|
+
throw processingError
|
|
131
|
+
}
|
|
75
132
|
}
|
|
76
133
|
})
|
|
77
134
|
this.socket.event.on('onCmdSendMessageResult', (evt) => {
|
|
@@ -134,14 +191,11 @@ export default class Websocket {
|
|
|
134
191
|
options.onHeartbeatSuccess && options.onHeartbeatSuccess(evt)
|
|
135
192
|
})
|
|
136
193
|
this.socket.event.on('onSendMessage', (evt) => {
|
|
137
|
-
const cloneData =
|
|
138
|
-
if (cloneData && typeof cloneData.content === 'string') {
|
|
139
|
-
cloneData.content = cloneData.content.substr(0, 100)
|
|
140
|
-
}
|
|
194
|
+
const cloneData = cloneLogData(evt.data)
|
|
141
195
|
if (evt.data.cmdType === 'CmdRequestWechatAccountsAliveStatus') {
|
|
142
196
|
delete cloneData.wechatAccountIds
|
|
143
197
|
}
|
|
144
|
-
this.
|
|
198
|
+
this.addLog({
|
|
145
199
|
group: 'client-chat-socket:sendMessage',
|
|
146
200
|
content: {
|
|
147
201
|
title: '发送消息',
|
|
@@ -222,13 +276,17 @@ export default class Websocket {
|
|
|
222
276
|
}
|
|
223
277
|
|
|
224
278
|
addLog (data) {
|
|
225
|
-
this.socket.logEnable && this.
|
|
279
|
+
this.socket.logEnable && this.log && this.log.addLog(data)
|
|
226
280
|
}
|
|
227
281
|
|
|
228
282
|
exportLogData () {
|
|
229
283
|
return this.socket.exportLogData()
|
|
230
284
|
}
|
|
231
285
|
|
|
286
|
+
exportLogFiles () {
|
|
287
|
+
return this.socket.exportLogFiles()
|
|
288
|
+
}
|
|
289
|
+
|
|
232
290
|
checkAndSync () {
|
|
233
291
|
return this.socket.checkAndSync()
|
|
234
292
|
}
|
|
@@ -55,6 +55,7 @@ class ClientChat {
|
|
|
55
55
|
constructor (options) {
|
|
56
56
|
options = Object.assign({
|
|
57
57
|
socket: null,
|
|
58
|
+
log: null,
|
|
58
59
|
checkSocketEventNotifyMethod: null,
|
|
59
60
|
getLoginUserIdMethod: null,
|
|
60
61
|
getLoginUserTokenMethod: null,
|
|
@@ -101,6 +102,7 @@ class ClientChat {
|
|
|
101
102
|
if (!options.loadRoomMessageDataMethod) {
|
|
102
103
|
throw new Error('loadRoomMessageDataMethod不能为空')
|
|
103
104
|
}
|
|
105
|
+
this.log = options.log || (options.socket && options.socket.log) || null
|
|
104
106
|
this.onOverwriteFriendInfoChange = options.onOverwriteFriendInfoChange
|
|
105
107
|
this.shouldMarkCurrentSessionReadMethod = options.shouldMarkCurrentSessionReadMethod
|
|
106
108
|
this.event = new Event({
|
|
@@ -416,6 +418,7 @@ class ClientChat {
|
|
|
416
418
|
groupField: 'wechatFriendId',
|
|
417
419
|
sortField: 'wechatTime',
|
|
418
420
|
clientChat: this,
|
|
421
|
+
getSessionIdMethod: data => createSessionId(options.getLoginAccountIdMethod ? options.getLoginAccountIdMethod() : data && data.accountId, data && data.wechatFriendId),
|
|
419
422
|
checkMessageSendResultMethod: options.checkMessageSendResultMethod,
|
|
420
423
|
loadLossMessageDataMethod: options.loadLossFriendMessageDataMethod,
|
|
421
424
|
onAddMessageSuccess: ({ data, isBeforeLastMessage }) => {
|
|
@@ -539,6 +542,7 @@ class ClientChat {
|
|
|
539
542
|
groupField: 'wechatChatroomId',
|
|
540
543
|
sortField: 'wechatTime',
|
|
541
544
|
clientChat: this,
|
|
545
|
+
getSessionIdMethod: data => createSessionId(options.getLoginAccountIdMethod ? options.getLoginAccountIdMethod() : data && data.accountId, data && data.wechatChatroomId),
|
|
542
546
|
checkMessageSendResultMethod: options.checkMessageSendResultMethod,
|
|
543
547
|
loadLossMessageDataMethod: options.loadLossRoomMessageDataMethod,
|
|
544
548
|
onAddMessageSuccess: ({ data, isBeforeLastMessage }) => {
|
|
@@ -803,6 +807,7 @@ class ClientChat {
|
|
|
803
807
|
})
|
|
804
808
|
this.socket = new ClientChatSocket({
|
|
805
809
|
socket: options.socket,
|
|
810
|
+
log: this.log,
|
|
806
811
|
getLoginUserIdMethod: options.getLoginUserIdMethod,
|
|
807
812
|
getLoginUserTokenMethod: options.getLoginUserTokenMethod,
|
|
808
813
|
checkSocketEventNotifyMethod: options.checkSocketEventNotifyMethod,
|
|
@@ -1134,22 +1139,65 @@ class ClientChat {
|
|
|
1134
1139
|
|
|
1135
1140
|
},
|
|
1136
1141
|
onSocketOpen: () => {
|
|
1137
|
-
const
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1142
|
+
const reconnectTime = Date.now()
|
|
1143
|
+
const syncTasks = []
|
|
1144
|
+
const syncLossMessages = (type, messageInstance) => {
|
|
1145
|
+
const watermarkBefore = messageInstance.lastReceiveMessageTime
|
|
1146
|
+
if (!watermarkBefore) {
|
|
1147
|
+
messageInstance.setLastReceiveMessageTime(reconnectTime)
|
|
1148
|
+
this.socket.addLog({
|
|
1149
|
+
group: 'diagnostic:loss_sync_result',
|
|
1150
|
+
content: {
|
|
1151
|
+
event: 'loss_sync_result',
|
|
1152
|
+
type,
|
|
1153
|
+
result: 'initialized',
|
|
1154
|
+
watermarkBefore,
|
|
1155
|
+
watermarkAfter: messageInstance.lastReceiveMessageTime
|
|
1156
|
+
}
|
|
1157
|
+
})
|
|
1158
|
+
return
|
|
1159
|
+
}
|
|
1160
|
+
const startedAt = Date.now()
|
|
1161
|
+
const task = messageInstance.loadLossMessageData().then(result => {
|
|
1162
|
+
messageInstance.setLastReceiveMessageTime(reconnectTime)
|
|
1163
|
+
this.socket.addLog({
|
|
1164
|
+
group: 'diagnostic:loss_sync_result',
|
|
1165
|
+
content: Object.assign({
|
|
1166
|
+
event: 'loss_sync_result',
|
|
1167
|
+
type,
|
|
1168
|
+
result: 'success',
|
|
1169
|
+
watermarkBefore,
|
|
1170
|
+
watermarkAfter: messageInstance.lastReceiveMessageTime,
|
|
1171
|
+
durationMs: Date.now() - startedAt
|
|
1172
|
+
}, result)
|
|
1173
|
+
})
|
|
1174
|
+
return true
|
|
1175
|
+
}, error => {
|
|
1176
|
+
this.socket.addLog({
|
|
1177
|
+
group: 'diagnostic:loss_sync_result',
|
|
1178
|
+
content: {
|
|
1179
|
+
event: 'loss_sync_result',
|
|
1180
|
+
type,
|
|
1181
|
+
result: 'failed',
|
|
1182
|
+
watermarkBefore,
|
|
1183
|
+
watermarkAfter: messageInstance.lastReceiveMessageTime,
|
|
1184
|
+
durationMs: Date.now() - startedAt,
|
|
1185
|
+
errorType: error && (error.name || error.code) || typeof error
|
|
1186
|
+
}
|
|
1187
|
+
})
|
|
1188
|
+
return false
|
|
1189
|
+
})
|
|
1190
|
+
syncTasks.push(task)
|
|
1143
1191
|
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1192
|
+
syncLossMessages('friend', this.friendMessage)
|
|
1193
|
+
syncLossMessages('room', this.roomMessage)
|
|
1194
|
+
Promise.all(syncTasks).then(() => {
|
|
1147
1195
|
// 断线期间本地增量可能和服务端产生偏差(其他端已读、消息延迟等),重连后以服务端为准全量校准一次
|
|
1148
|
-
if (
|
|
1196
|
+
if (syncTasks.length) {
|
|
1149
1197
|
this.account.refreshAllAccountUnreadMesageNum()
|
|
1150
1198
|
}
|
|
1151
1199
|
})
|
|
1152
|
-
},
|
|
1200
|
+
},
|
|
1153
1201
|
onSocketClose: (evt) => {
|
|
1154
1202
|
},
|
|
1155
1203
|
onSocketKickOut: () => {
|
|
@@ -5,14 +5,20 @@ export default class ClientChatAccount {
|
|
|
5
5
|
data = Vue.observable({
|
|
6
6
|
accountData: [],
|
|
7
7
|
accountUnreadMessageNumData: [],
|
|
8
|
+
accountGreetingUnreadMsgCountData: {},
|
|
8
9
|
currentAccount: null
|
|
9
10
|
})
|
|
10
11
|
|
|
11
12
|
loadAccountDataMethod = null
|
|
12
13
|
|
|
13
14
|
getAccountUnreadMessageNumMethod = null
|
|
15
|
+
|
|
16
|
+
getAccountGreetingUnreadMsgCountMethod = null
|
|
14
17
|
|
|
15
18
|
accountMap = {}
|
|
19
|
+
|
|
20
|
+
// 好友请求数量请求合并,key为账号id列表
|
|
21
|
+
greetingUnreadRequestMap = {}
|
|
16
22
|
|
|
17
23
|
constructor (options) {
|
|
18
24
|
options = Object.assign({
|
|
@@ -21,11 +27,13 @@ export default class ClientChatAccount {
|
|
|
21
27
|
getAccountUnreadMessageNumMethod: null,
|
|
22
28
|
updateAccountMessageReadMethod: null,
|
|
23
29
|
deleteAccountSessionMethod: null,
|
|
30
|
+
getAccountGreetingUnreadMsgCountMethod: null,
|
|
24
31
|
onCurrentAccountChange: null,
|
|
25
32
|
onAccountAdded: null,
|
|
26
33
|
onAccountRemoved: null,
|
|
27
34
|
onUnreadMessageNumChange: null,
|
|
28
|
-
onDeleteAccountSession: null
|
|
35
|
+
onDeleteAccountSession: null,
|
|
36
|
+
onAccountLoaded: null
|
|
29
37
|
}, options)
|
|
30
38
|
if (!options.loadAccountDataMethod) {
|
|
31
39
|
throw new Error('缺少loadAccountDataMethod配置')
|
|
@@ -38,10 +46,12 @@ export default class ClientChatAccount {
|
|
|
38
46
|
this.getAccountUnreadMessageNumMethod = options.getAccountUnreadMessageNumMethod
|
|
39
47
|
this.updateAccountMessageReadMethod = options.updateAccountMessageReadMethod
|
|
40
48
|
this.deleteAccountSessionMethod = options.deleteAccountSessionMethod
|
|
49
|
+
this.getAccountGreetingUnreadMsgCountMethod = options.getAccountGreetingUnreadMsgCountMethod
|
|
41
50
|
this.onAccountAdded = options.onAccountAdded
|
|
42
51
|
this.onAccountRemoved = options.onAccountRemoved,
|
|
43
52
|
this.onUnreadMessageNumChange = options.onUnreadMessageNumChange
|
|
44
53
|
this.onDeleteAccountSession = options.onDeleteAccountSession
|
|
54
|
+
this.onAccountLoaded = options.onAccountLoaded
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
get accountData () {
|
|
@@ -55,6 +65,10 @@ export default class ClientChatAccount {
|
|
|
55
65
|
get currentAccount () {
|
|
56
66
|
return this.data.currentAccount
|
|
57
67
|
}
|
|
68
|
+
|
|
69
|
+
get accountGreetingUnreadMsgCountData () {
|
|
70
|
+
return this.data.accountGreetingUnreadMsgCountData
|
|
71
|
+
}
|
|
58
72
|
|
|
59
73
|
setCurrentAccount (accountId) {
|
|
60
74
|
let account = null
|
|
@@ -81,6 +95,15 @@ export default class ClientChatAccount {
|
|
|
81
95
|
this.addAccount(item)
|
|
82
96
|
})
|
|
83
97
|
}
|
|
98
|
+
// 重新加载后账号对象都被替换了,当前账号需要指向新对象,账号已经不存在了就置为null(界面上选择全部企微号)
|
|
99
|
+
const currentAccount = this.data.currentAccount
|
|
100
|
+
if (currentAccount) {
|
|
101
|
+
if (this.accountMap[currentAccount.id]) {
|
|
102
|
+
this.data.currentAccount = this.accountMap[currentAccount.id]
|
|
103
|
+
} else {
|
|
104
|
+
this.setCurrentAccount(null)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
84
107
|
}
|
|
85
108
|
|
|
86
109
|
getAccountData () {
|
|
@@ -282,6 +305,9 @@ export default class ClientChatAccount {
|
|
|
282
305
|
this._cacheLoadPromise = this.loadAccountDataMethod()
|
|
283
306
|
this._cacheLoadPromise.then(rs => {
|
|
284
307
|
this.setAccountData(rs.data)
|
|
308
|
+
this.onAccountLoaded && this.onAccountLoaded({
|
|
309
|
+
data: rs.data
|
|
310
|
+
})
|
|
285
311
|
})
|
|
286
312
|
this.cancelConnectRequest = () => {
|
|
287
313
|
this._cacheLoadPromise.abort()
|
|
@@ -298,9 +324,75 @@ export default class ClientChatAccount {
|
|
|
298
324
|
return this.loadData()
|
|
299
325
|
}
|
|
300
326
|
|
|
327
|
+
/**
|
|
328
|
+
* 设置指定企微账号的待处理好友请求数量,并重算all
|
|
329
|
+
*/
|
|
330
|
+
setAccountGreetingUnreadMsgCount (params) {
|
|
331
|
+
if (!params || !params.qwAccountId) {
|
|
332
|
+
throw new Error('缺少必须参数')
|
|
333
|
+
}
|
|
334
|
+
Vue.set(this.data.accountGreetingUnreadMsgCountData, params.qwAccountId, params.count || 0)
|
|
335
|
+
this.updateAllAccountGreetingUnreadMsgCount()
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
updateAllAccountGreetingUnreadMsgCount () {
|
|
339
|
+
const allCount = Object.keys(this.data.accountGreetingUnreadMsgCountData).reduce((rs, key) => {
|
|
340
|
+
return key === 'all' ? rs : rs + (this.data.accountGreetingUnreadMsgCountData[key] || 0)
|
|
341
|
+
}, 0)
|
|
342
|
+
Vue.set(this.data.accountGreetingUnreadMsgCountData, 'all', allCount)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* 获取待处理好友请求数量
|
|
347
|
+
* qwAccountIds不传则刷新所有账号;后端数量为0的账号不返回,所以先置0再覆盖
|
|
348
|
+
*/
|
|
349
|
+
getAccountGreetingUnreadMsgCount (params) {
|
|
350
|
+
if (!this.getAccountGreetingUnreadMsgCountMethod) {
|
|
351
|
+
return Promise.reject(new Error('getAccountGreetingUnreadMsgCountMethod未定义'))
|
|
352
|
+
}
|
|
353
|
+
let qwAccountIds = (params || {}).qwAccountIds
|
|
354
|
+
if (qwAccountIds && !Array.isArray(qwAccountIds)) {
|
|
355
|
+
qwAccountIds = [qwAccountIds]
|
|
356
|
+
}
|
|
357
|
+
qwAccountIds = (qwAccountIds || []).filter((id, index, data) => id && data.indexOf(id) === index).map(String)
|
|
358
|
+
const isAll = !qwAccountIds.length
|
|
359
|
+
const requestKey = isAll ? 'all' : qwAccountIds.slice().sort().join(',')
|
|
360
|
+
if (this.greetingUnreadRequestMap[requestKey]) {
|
|
361
|
+
return this.greetingUnreadRequestMap[requestKey]
|
|
362
|
+
}
|
|
363
|
+
const request = this.getAccountGreetingUnreadMsgCountMethod({
|
|
364
|
+
qwAccountIds: isAll ? undefined : qwAccountIds
|
|
365
|
+
}).then(rs => {
|
|
366
|
+
const targetIds = isAll ? Object.keys(this.accountMap) : qwAccountIds
|
|
367
|
+
targetIds.forEach(id => {
|
|
368
|
+
Vue.set(this.data.accountGreetingUnreadMsgCountData, id, 0)
|
|
369
|
+
})
|
|
370
|
+
;((rs && rs.data) || []).forEach(item => {
|
|
371
|
+
if (item && item.qwAccountId) {
|
|
372
|
+
Vue.set(this.data.accountGreetingUnreadMsgCountData, String(item.qwAccountId), item.count || 0)
|
|
373
|
+
}
|
|
374
|
+
})
|
|
375
|
+
this.updateAllAccountGreetingUnreadMsgCount()
|
|
376
|
+
return this.data.accountGreetingUnreadMsgCountData
|
|
377
|
+
}).finally(() => {
|
|
378
|
+
delete this.greetingUnreadRequestMap[requestKey]
|
|
379
|
+
})
|
|
380
|
+
this.greetingUnreadRequestMap[requestKey] = request
|
|
381
|
+
return request
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* 刷新所有账号的待处理好友请求数量
|
|
386
|
+
*/
|
|
387
|
+
refreshAllAccountGreetingUnreadMsgCount () {
|
|
388
|
+
return this.getAccountGreetingUnreadMsgCount()
|
|
389
|
+
}
|
|
390
|
+
|
|
301
391
|
reset () {
|
|
302
392
|
this.data.accountData = []
|
|
303
393
|
this.data.accountUnreadMessageNumData = []
|
|
394
|
+
this.data.accountGreetingUnreadMsgCountData = {}
|
|
395
|
+
this.greetingUnreadRequestMap = {}
|
|
304
396
|
if (this.cancelConnectRequest) {
|
|
305
397
|
this.cancelConnectRequest()
|
|
306
398
|
}
|