@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<sdk-chat-panel
|
|
3
3
|
ref="panel"
|
|
4
|
-
v-bind="
|
|
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
|
-
|
|
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,14 +129,35 @@ export default {
|
|
|
126
129
|
},
|
|
127
130
|
contextChatId: {
|
|
128
131
|
type: String
|
|
132
|
+
},
|
|
133
|
+
onBeforeSelectionChange: {
|
|
134
|
+
type: Function
|
|
129
135
|
}
|
|
130
136
|
},
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
return !!item.
|
|
160
|
+
return !!item.isSend
|
|
137
161
|
},
|
|
138
162
|
handleChatsInitLoaded () {
|
|
139
163
|
this.$emit('initloaded')
|
|
@@ -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',
|
|
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.
|
|
3
|
+
"version": "1.0.401",
|
|
4
4
|
"description": "",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
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",
|
|
@@ -56,15 +56,30 @@ export default class ClientChatAccount {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
_addUnreadMessageNumLog (title, data) {
|
|
59
|
-
|
|
59
|
+
try {
|
|
60
|
+
if (!this.onUnreadMessageNumLog) {
|
|
61
|
+
return
|
|
62
|
+
}
|
|
60
63
|
this.onUnreadMessageNumLog({
|
|
61
|
-
group: '
|
|
62
|
-
content: {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
64
|
+
group: 'diagnostic:account_unread_changed',
|
|
65
|
+
content: Object.assign({
|
|
66
|
+
event: 'account_unread_changed',
|
|
67
|
+
title
|
|
68
|
+
}, data)
|
|
66
69
|
})
|
|
67
|
-
}
|
|
70
|
+
} catch (error) {}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
_addDiagnosticLog (event, data) {
|
|
74
|
+
try {
|
|
75
|
+
if (!this.onUnreadMessageNumLog) {
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
this.onUnreadMessageNumLog({
|
|
79
|
+
group: `diagnostic:${event}`,
|
|
80
|
+
content: Object.assign({ event }, data)
|
|
81
|
+
})
|
|
82
|
+
} catch (error) {}
|
|
68
83
|
}
|
|
69
84
|
|
|
70
85
|
get accountData () {
|
|
@@ -198,6 +213,7 @@ export default class ClientChatAccount {
|
|
|
198
213
|
}
|
|
199
214
|
|
|
200
215
|
refreshAllAccountUnreadMesageNum () {
|
|
216
|
+
const startedAt = Date.now()
|
|
201
217
|
this.getAccountUnreadMessageNumMethod({
|
|
202
218
|
wechatAccountIds: Object.keys(this.accountMap)
|
|
203
219
|
}).then(rs => {
|
|
@@ -216,10 +232,17 @@ export default class ClientChatAccount {
|
|
|
216
232
|
source: 'refreshAll',
|
|
217
233
|
accounts: nextData
|
|
218
234
|
})
|
|
235
|
+
}).catch(error => {
|
|
236
|
+
this._addDiagnosticLog('account_unread_refresh_failed', {
|
|
237
|
+
scope: 'all',
|
|
238
|
+
durationMs: Date.now() - startedAt,
|
|
239
|
+
errorType: error && (error.name || error.code) || typeof error
|
|
240
|
+
})
|
|
219
241
|
})
|
|
220
242
|
}
|
|
221
243
|
|
|
222
244
|
refreshAccountUnreadMessageNum (params) {
|
|
245
|
+
const startedAt = Date.now()
|
|
223
246
|
const { wechatAccountId, ...nextParams } = params
|
|
224
247
|
this.getAccountUnreadMessageNumMethod(Object.assign({
|
|
225
248
|
wechatAccountIds: [wechatAccountId]
|
|
@@ -251,6 +274,13 @@ export default class ClientChatAccount {
|
|
|
251
274
|
before: before ? { num: before.num, muteNum: before.muteNum } : null,
|
|
252
275
|
after: { num: after.num, muteNum: after.muteNum }
|
|
253
276
|
})
|
|
277
|
+
}).catch(error => {
|
|
278
|
+
this._addDiagnosticLog('account_unread_refresh_failed', {
|
|
279
|
+
scope: 'single',
|
|
280
|
+
wechatAccountId,
|
|
281
|
+
durationMs: Date.now() - startedAt,
|
|
282
|
+
errorType: error && (error.name || error.code) || typeof error
|
|
283
|
+
})
|
|
254
284
|
})
|
|
255
285
|
}
|
|
256
286
|
|
|
@@ -54,6 +54,7 @@ export default class ClientChatMessage {
|
|
|
54
54
|
groupField: null, // 分组的字段
|
|
55
55
|
checkMessageSendResultMethod: null, // 检查消息发送结果
|
|
56
56
|
loadLossMessageDataMethod: null, // 加载丢失的消息数据,例如socket断开期间没有收到的数据
|
|
57
|
+
getSessionIdMethod: null,
|
|
57
58
|
onAddMessageSuccess: null // 新增消息成功回调事件
|
|
58
59
|
}, options)
|
|
59
60
|
if (!options.clientChat) {
|
|
@@ -68,10 +69,72 @@ export default class ClientChatMessage {
|
|
|
68
69
|
this.sortField = options.sortField
|
|
69
70
|
this.checkMessageSendResultMethod = options.checkMessageSendResultMethod
|
|
70
71
|
this.loadLossMessageDataMethod = options.loadLossMessageDataMethod
|
|
72
|
+
this.getSessionIdMethod = options.getSessionIdMethod
|
|
71
73
|
this.onAddMessageSuccess = options.onAddMessageSuccess
|
|
72
74
|
this.event = new Event()
|
|
73
75
|
}
|
|
74
76
|
|
|
77
|
+
addDiagnosticLog (event, data = {}) {
|
|
78
|
+
if (!this.clientChat || !this.clientChat.socket || !this.clientChat.socket.addLog) {
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
this.clientChat.socket.addLog({
|
|
83
|
+
group: `diagnostic:${event}`,
|
|
84
|
+
content: Object.assign({
|
|
85
|
+
event
|
|
86
|
+
}, data)
|
|
87
|
+
})
|
|
88
|
+
} catch (error) {}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
getMessageDiagnosticData (data, extra = {}) {
|
|
92
|
+
let sessionId
|
|
93
|
+
try {
|
|
94
|
+
sessionId = this.getSessionIdMethod && this.getSessionIdMethod(data)
|
|
95
|
+
} catch (error) {}
|
|
96
|
+
return Object.assign({
|
|
97
|
+
messageId: data && data.id,
|
|
98
|
+
msgSvrId: data && data.msgSvrId,
|
|
99
|
+
sessionId
|
|
100
|
+
}, extra)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
handleSessionUpdateError (data, error) {
|
|
104
|
+
this.addDiagnosticLog('message_session_update_failed', this.getMessageDiagnosticData(data, {
|
|
105
|
+
errorType: error && (error.name || error.code) || typeof error
|
|
106
|
+
}))
|
|
107
|
+
try {
|
|
108
|
+
console.error('[client-chat-message] onAddMessageSuccess error', {
|
|
109
|
+
messageId: data && data.id,
|
|
110
|
+
error
|
|
111
|
+
})
|
|
112
|
+
} catch (consoleError) {}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
getGroupMessageSummary (groupId) {
|
|
116
|
+
const summary = {
|
|
117
|
+
count: 0,
|
|
118
|
+
latestMessageId: null,
|
|
119
|
+
latestMessageTime: null
|
|
120
|
+
}
|
|
121
|
+
if (!groupId) {
|
|
122
|
+
return summary
|
|
123
|
+
}
|
|
124
|
+
Object.keys(this.messageMap).forEach(id => {
|
|
125
|
+
const message = this.messageMap[id]
|
|
126
|
+
if (!message || message[this.groupField] !== groupId) {
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
summary.count++
|
|
130
|
+
if (!summary.latestMessageTime || message[this.sortField] > summary.latestMessageTime) {
|
|
131
|
+
summary.latestMessageId = message.id
|
|
132
|
+
summary.latestMessageTime = message[this.sortField]
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
return summary
|
|
136
|
+
}
|
|
137
|
+
|
|
75
138
|
getSortField (time) {
|
|
76
139
|
const step = 1000 * 60 * 60 * 24
|
|
77
140
|
const day = Math.floor(time / step)
|
|
@@ -110,9 +173,15 @@ export default class ClientChatMessage {
|
|
|
110
173
|
*/
|
|
111
174
|
addMessage (data, fireEvent) {
|
|
112
175
|
if (!data || !data.id || !data[this.groupField] || !data[this.sortField]) {
|
|
176
|
+
this.addDiagnosticLog('message_rejected', this.getMessageDiagnosticData(data, {
|
|
177
|
+
reason: 'missing_required_field'
|
|
178
|
+
}))
|
|
113
179
|
throw new Error('缺少必须参数')
|
|
114
180
|
}
|
|
115
181
|
if (this.messageMap[data.id]) {
|
|
182
|
+
this.addDiagnosticLog('message_rejected', this.getMessageDiagnosticData(data, {
|
|
183
|
+
reason: 'duplicate_message_id'
|
|
184
|
+
}))
|
|
116
185
|
return
|
|
117
186
|
}
|
|
118
187
|
if (this.tempMessageMap[data.id]) {
|
|
@@ -133,11 +202,22 @@ export default class ClientChatMessage {
|
|
|
133
202
|
Vue.set(this.data.messageData[groupField][sortFields.day], sortFields.milliseconds, [])
|
|
134
203
|
}
|
|
135
204
|
if (this.data.messageData[groupField][sortFields.day][sortFields.milliseconds].some(v => v.id === data.id)) {
|
|
205
|
+
this.addDiagnosticLog('message_rejected', this.getMessageDiagnosticData(data, {
|
|
206
|
+
reason: 'duplicate_time_bucket'
|
|
207
|
+
}))
|
|
136
208
|
return
|
|
137
209
|
}
|
|
138
210
|
this.data.messageData[groupField][sortFields.day][sortFields.milliseconds].push(data)
|
|
139
211
|
this.messageMap[data.id] = data
|
|
140
212
|
this.setLastMessageTime(groupField, data[this.sortField], data)
|
|
213
|
+
const storedDiagnostic = {}
|
|
214
|
+
if (isBeforeLastMessage) {
|
|
215
|
+
storedDiagnostic.outOfOrder = true
|
|
216
|
+
}
|
|
217
|
+
if (fireEvent === false) {
|
|
218
|
+
storedDiagnostic.eventDispatch = 'disabled'
|
|
219
|
+
}
|
|
220
|
+
this.addDiagnosticLog('message_stored', this.getMessageDiagnosticData(data, storedDiagnostic))
|
|
141
221
|
// 发送中的消息并且不是临时占位消息,需要增加轮询结果逻辑
|
|
142
222
|
if (data.isSend && data.sendStatus === 1 && !data._temp) {
|
|
143
223
|
// 排除一下系统消息,因为后端系统消息的sendStatus永远为1,这会导致前端总是轮训去调用接口检查消息状态
|
|
@@ -149,26 +229,49 @@ export default class ClientChatMessage {
|
|
|
149
229
|
// 先执行onAddMessageSuccess再发add-message事件,保证会话的getSession轮询先由这里发起、更新会话的回调排在最前面,
|
|
150
230
|
// 外部监听add-message后再调getSession只是复用同一个轮询
|
|
151
231
|
// try/catch是为了避免回调里的异常把add-message事件吞掉(外部的新消息提醒、本地消息缓存都依赖这个事件)
|
|
232
|
+
let sessionUpdateResult
|
|
152
233
|
try {
|
|
153
|
-
this.onAddMessageSuccess && this.onAddMessageSuccess({
|
|
234
|
+
sessionUpdateResult = this.onAddMessageSuccess && this.onAddMessageSuccess({
|
|
154
235
|
data,
|
|
155
236
|
lastMessageTime,
|
|
156
237
|
isBeforeLastMessage
|
|
157
238
|
})
|
|
158
239
|
} catch (error) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
240
|
+
this.handleSessionUpdateError(data, error)
|
|
241
|
+
}
|
|
242
|
+
if (sessionUpdateResult && typeof sessionUpdateResult.catch === 'function') {
|
|
243
|
+
sessionUpdateResult.catch(error => {
|
|
244
|
+
this.handleSessionUpdateError(data, error)
|
|
162
245
|
})
|
|
163
246
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
})
|
|
247
|
+
// 如果消息包含这种情况,就不能往外发送add-message事件
|
|
248
|
+
// 因为例如群发的消息,他没有会话,导致前端在处理来了新消息通知铃声提醒,获取会话一直获取不到,然后会总是发送请求
|
|
249
|
+
let suppressedReason = null
|
|
250
|
+
if (isBeforeLastMessage) {
|
|
251
|
+
suppressedReason = 'out_of_order'
|
|
252
|
+
} else if (isAutoReadMessage(data)) {
|
|
253
|
+
suppressedReason = 'auto_read'
|
|
254
|
+
} else if (shouldIgnoreSessionByMessage(data)) {
|
|
255
|
+
suppressedReason = 'ignore_session'
|
|
256
|
+
} else if (isDeletedMsg(data)) {
|
|
257
|
+
suppressedReason = 'deleted'
|
|
258
|
+
} else if (isBlockedMsg(data)) {
|
|
259
|
+
suppressedReason = 'blocked'
|
|
260
|
+
}
|
|
261
|
+
if (!suppressedReason) {
|
|
262
|
+
this.event && this.event.emit('add-message', {
|
|
263
|
+
data
|
|
264
|
+
})
|
|
265
|
+
this.addDiagnosticLog('message_event_emitted', this.getMessageDiagnosticData(data))
|
|
266
|
+
} else {
|
|
267
|
+
const suppressedDiagnostic = { reason: suppressedReason }
|
|
268
|
+
if (suppressedReason === 'out_of_order') {
|
|
269
|
+
suppressedDiagnostic.messageTime = data[this.sortField]
|
|
270
|
+
suppressedDiagnostic.lastMessageTime = lastMessageTime
|
|
271
|
+
}
|
|
272
|
+
this.addDiagnosticLog('message_event_suppressed', this.getMessageDiagnosticData(data, suppressedDiagnostic))
|
|
273
|
+
}
|
|
170
274
|
}
|
|
171
|
-
}
|
|
172
275
|
}
|
|
173
276
|
|
|
174
277
|
removeMessage (id) {
|
|
@@ -421,8 +524,54 @@ export default class ClientChatMessage {
|
|
|
421
524
|
}
|
|
422
525
|
|
|
423
526
|
reloadMessageData (params) {
|
|
527
|
+
const startedAt = Date.now()
|
|
528
|
+
const targetId = params && params[this.groupField]
|
|
529
|
+
const totalMemoryBefore = Object.keys(this.messageMap).length
|
|
530
|
+
const targetBefore = this.getGroupMessageSummary(targetId)
|
|
424
531
|
this.clearMessage()
|
|
425
|
-
return this.loadMessageData(params)
|
|
532
|
+
return this.loadMessageData(params).then(data => {
|
|
533
|
+
const targetAfter = this.getGroupMessageSummary(targetId)
|
|
534
|
+
this.addDiagnosticLog('chat_reload_result', {
|
|
535
|
+
result: 'success',
|
|
536
|
+
targetField: this.groupField,
|
|
537
|
+
targetId,
|
|
538
|
+
totalMemoryBefore,
|
|
539
|
+
targetMemoryBefore: targetBefore.count,
|
|
540
|
+
latestMessageIdBefore: targetBefore.latestMessageId,
|
|
541
|
+
latestMessageTimeBefore: targetBefore.latestMessageTime,
|
|
542
|
+
clearedCount: totalMemoryBefore,
|
|
543
|
+
loadedCount: Array.isArray(data) ? data.length : 0,
|
|
544
|
+
finalTargetCount: targetAfter.count,
|
|
545
|
+
latestMessageIdAfter: targetAfter.latestMessageId,
|
|
546
|
+
latestMessageTimeAfter: targetAfter.latestMessageTime,
|
|
547
|
+
upward: params && params.upward,
|
|
548
|
+
smallWechatTime: params && params.smallWechatTime,
|
|
549
|
+
bigWechatTime: params && params.bigWechatTime,
|
|
550
|
+
durationMs: Date.now() - startedAt
|
|
551
|
+
})
|
|
552
|
+
return data
|
|
553
|
+
}, error => {
|
|
554
|
+
const targetAfter = this.getGroupMessageSummary(targetId)
|
|
555
|
+
this.addDiagnosticLog('chat_reload_result', {
|
|
556
|
+
result: 'failed',
|
|
557
|
+
targetField: this.groupField,
|
|
558
|
+
targetId,
|
|
559
|
+
totalMemoryBefore,
|
|
560
|
+
targetMemoryBefore: targetBefore.count,
|
|
561
|
+
latestMessageIdBefore: targetBefore.latestMessageId,
|
|
562
|
+
latestMessageTimeBefore: targetBefore.latestMessageTime,
|
|
563
|
+
clearedCount: totalMemoryBefore,
|
|
564
|
+
finalTargetCount: targetAfter.count,
|
|
565
|
+
latestMessageIdAfter: targetAfter.latestMessageId,
|
|
566
|
+
latestMessageTimeAfter: targetAfter.latestMessageTime,
|
|
567
|
+
upward: params && params.upward,
|
|
568
|
+
smallWechatTime: params && params.smallWechatTime,
|
|
569
|
+
bigWechatTime: params && params.bigWechatTime,
|
|
570
|
+
durationMs: Date.now() - startedAt,
|
|
571
|
+
errorType: error && (error.name || error.code) || typeof error
|
|
572
|
+
})
|
|
573
|
+
return Promise.reject(error)
|
|
574
|
+
})
|
|
426
575
|
}
|
|
427
576
|
|
|
428
577
|
/***
|
|
@@ -587,18 +736,26 @@ export default class ClientChatMessage {
|
|
|
587
736
|
if (!this.loadLossMessageDataMethod) {
|
|
588
737
|
throw new Error('[ClientChatWechat]缺少loadLossMessageDataMethod方法定义')
|
|
589
738
|
}
|
|
590
|
-
this.loadLossMessageDataMethod({
|
|
739
|
+
return this.loadLossMessageDataMethod({
|
|
591
740
|
lastReceiveMessageTime: this.data.lastReceiveMessageTime
|
|
592
741
|
}).then((rs) => {
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
742
|
+
const result = {
|
|
743
|
+
returnedCount: 0,
|
|
744
|
+
insertedCount: 0,
|
|
745
|
+
duplicateCount: 0
|
|
596
746
|
}
|
|
597
|
-
|
|
598
|
-
|
|
747
|
+
const messages = rs && Array.isArray(rs.data) ? rs.data : []
|
|
748
|
+
result.returnedCount = messages.length
|
|
749
|
+
// 做个去重
|
|
750
|
+
const nextMessages = messages.filter(v => !this.messageMap[v.id])
|
|
751
|
+
result.insertedCount = nextMessages.length
|
|
752
|
+
result.duplicateCount = messages.length - nextMessages.length
|
|
753
|
+
if (nextMessages.length) {
|
|
754
|
+
nextMessages.forEach(item => {
|
|
599
755
|
this.addMessage(item)
|
|
600
756
|
})
|
|
601
757
|
}
|
|
758
|
+
return result
|
|
602
759
|
})
|
|
603
760
|
}
|
|
604
761
|
|