@aochuang/client-sdk 1.0.278
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/README.md +93 -0
- package/common/avatar/avatar.vue +86 -0
- package/common/avatar/index.js +3 -0
- package/common/badge/badge.vue +105 -0
- package/common/badge/index.js +3 -0
- package/common/context-menu/context-menu-box.vue +61 -0
- package/common/context-menu/context-menu-group.vue +162 -0
- package/common/context-menu/context-menu-item.vue +179 -0
- package/common/context-menu/context-menu.vue +201 -0
- package/common/context-menu/index.js +3 -0
- package/common/context-menu/utils.js +138 -0
- package/common/friend-avatar/default.svg +1 -0
- package/common/friend-avatar/friend-avatar.vue +29 -0
- package/common/friend-avatar/index.js +3 -0
- package/common/image/index.js +3 -0
- package/common/index.js +17 -0
- package/common/room-avatar/default.svg +6 -0
- package/common/room-avatar/index.js +3 -0
- package/common/room-avatar/room-avatar.vue +29 -0
- package/common/scroll-load-more/index.js +3 -0
- package/common/scroll-load-more/scroll-load-more.vue +195 -0
- package/common/user-avatar/default.svg +1 -0
- package/common/user-avatar/index.js +3 -0
- package/common/user-avatar/user-avatar.vue +29 -0
- package/components/account-select/account-select-skeleton.vue +56 -0
- package/components/account-select/account-select.vue +205 -0
- package/components/account-select/all.svg +1 -0
- package/components/account-select/index.js +3 -0
- package/components/chat-editor/MENTION_TOKEN_SUMMARY.md +74 -0
- package/components/chat-editor/chat-editor-button/chat-editor-button.vue +78 -0
- package/components/chat-editor/chat-editor-suggestions/chat-editor-suggestions.vue +329 -0
- package/components/chat-editor/chat-editor-toolbar/chat-editor-toolbar-item.vue +28 -0
- package/components/chat-editor/chat-editor-toolbar/chat-editor-toolbar.vue +17 -0
- package/components/chat-editor/chat-editor.vue +933 -0
- package/components/chat-editor/index.js +12 -0
- package/components/chat-editor/utils.js +189 -0
- package/components/chat-friend-profile/chat-friend-profile.vue +118 -0
- package/components/chat-friend-profile/index.js +3 -0
- package/components/chat-layout/chat-layout.vue +71 -0
- package/components/chat-layout/index.js +3 -0
- package/components/chat-panel/chat-panel-box.vue +350 -0
- package/components/chat-panel/chat-panel-chat.vue +121 -0
- package/components/chat-panel/chat-panel-chats.vue +674 -0
- package/components/chat-panel/chat-panel-empty.vue +32 -0
- package/components/chat-panel/chat-panel-increment.vue +80 -0
- package/components/chat-panel/chat-panel-inner-msg.vue +25 -0
- package/components/chat-panel/chat-panel-loading.vue +29 -0
- package/components/chat-panel/chat-panel-nearest.vue +136 -0
- package/components/chat-panel/chat-panel.vue +292 -0
- package/components/chat-panel/index.js +3 -0
- package/components/chat-panel/util.js +83 -0
- package/components/chat-room-profile/chat-room-profile.vue +103 -0
- package/components/chat-room-profile/index.js +3 -0
- package/components/contacts-friend-select/contacts-friend-select-skeleton.vue +41 -0
- package/components/contacts-friend-select/contacts-friend-select.vue +204 -0
- package/components/contacts-friend-select/index.js +3 -0
- package/components/contacts-group-select/contacts-group-select-item.vue +98 -0
- package/components/contacts-group-select/contacts-group-select-skeleton.vue +81 -0
- package/components/contacts-group-select/contacts-group-select.vue +396 -0
- package/components/contacts-group-select/index.js +3 -0
- package/components/contacts-room-select/contacts-room-select-skeleton.vue +41 -0
- package/components/contacts-room-select/contacts-room-select.vue +208 -0
- package/components/contacts-room-select/index.js +3 -0
- package/components/index.js +43 -0
- package/components/layout/index.js +3 -0
- package/components/layout/layout.vue +70 -0
- package/components/session-select/index.js +11 -0
- package/components/session-select/session-select-item-skeleton.vue +59 -0
- package/components/session-select/session-select-item.vue +190 -0
- package/components/session-select/session-select.vue +386 -0
- package/components/wechat-chat-control/calling/calling.vue +227 -0
- package/components/wechat-chat-control/calling/phone-fill.svg +1 -0
- package/components/wechat-chat-control/calling/vidicon-fill.svg +1 -0
- package/components/wechat-chat-control/channel-live/channel-live.vue +198 -0
- package/components/wechat-chat-control/channel-live/quote-icon.svg +1 -0
- package/components/wechat-chat-control/channel-video/channel-video.vue +180 -0
- package/components/wechat-chat-control/channel-video/quote-icon.svg +1 -0
- package/components/wechat-chat-control/channel-video-card/channel-video-card.vue +139 -0
- package/components/wechat-chat-control/channel-video-card/quote-icon.svg +1 -0
- package/components/wechat-chat-control/company-card/company-card.vue +136 -0
- package/components/wechat-chat-control/company-card/quote-icon.svg +1 -0
- package/components/wechat-chat-control/custom-expression/custom-expression.vue +45 -0
- package/components/wechat-chat-control/empty/empty.vue +27 -0
- package/components/wechat-chat-control/file-url/file-url.vue +307 -0
- package/components/wechat-chat-control/file-url/icons/file-excel-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/file-info-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/file-music-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/file-pdf-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/file-ppt-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/file-settings-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/file-text-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/file-unknow-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/file-word-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/file-zip-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/index.js +24 -0
- package/components/wechat-chat-control/image/image.vue +344 -0
- package/components/wechat-chat-control/image/index.js +1 -0
- package/components/wechat-chat-control/image/util.js +29 -0
- package/components/wechat-chat-control/index.js +104 -0
- package/components/wechat-chat-control/jx-sys-text/jx-sys-text.vue +28 -0
- package/components/wechat-chat-control/location/location.vue +179 -0
- package/components/wechat-chat-control/location/offline-bg.png +0 -0
- package/components/wechat-chat-control/member-change/member-change.vue +37 -0
- package/components/wechat-chat-control/music/icons/163.png +0 -0
- package/components/wechat-chat-control/music/icons/163.svg +12 -0
- package/components/wechat-chat-control/music/icons/default.png +0 -0
- package/components/wechat-chat-control/music/icons/default.svg +1 -0
- package/components/wechat-chat-control/music/icons/kuwo.png +0 -0
- package/components/wechat-chat-control/music/icons/qq.png +0 -0
- package/components/wechat-chat-control/music/icons/qq.svg +1 -0
- package/components/wechat-chat-control/music/music.vue +156 -0
- package/components/wechat-chat-control/music/utils.js +30 -0
- package/components/wechat-chat-control/quote-message/quote-message.vue +257 -0
- package/components/wechat-chat-control/real-time-position/icon.svg +1 -0
- package/components/wechat-chat-control/real-time-position/real-time-position.vue +57 -0
- package/components/wechat-chat-control/red-envelopes/quote-icon.svg +1 -0
- package/components/wechat-chat-control/red-envelopes/red-envelope.svg +1 -0
- package/components/wechat-chat-control/red-envelopes/red-envelopes.vue +168 -0
- package/components/wechat-chat-control/revoke-me-message/revoke-me-message.vue +41 -0
- package/components/wechat-chat-control/revoke-other-message/revoke-other-message.vue +41 -0
- package/components/wechat-chat-control/revoke-you-message/revoke-you-message.vue +41 -0
- package/components/wechat-chat-control/room-calling/phone-fill.svg +1 -0
- package/components/wechat-chat-control/room-calling/room-calling.vue +52 -0
- package/components/wechat-chat-control/room-calling/vidicon-fill.svg +1 -0
- package/components/wechat-chat-control/share-card/quote-icon.svg +1 -0
- package/components/wechat-chat-control/share-card/share-card.vue +140 -0
- package/components/wechat-chat-control/system/system.vue +122 -0
- package/components/wechat-chat-control/system-batch-message/system-batch-message.vue +28 -0
- package/components/wechat-chat-control/system-money/system-money.vue +39 -0
- package/components/wechat-chat-control/text/icons/icon.svg +6 -0
- package/components/wechat-chat-control/text/text.vue +164 -0
- package/components/wechat-chat-control/text-with-at/text-with-at.vue +88 -0
- package/components/wechat-chat-control/transfer/collection.svg +1 -0
- package/components/wechat-chat-control/transfer/quote-icon.svg +1 -0
- package/components/wechat-chat-control/transfer/red-transfer.svg +1 -0
- package/components/wechat-chat-control/transfer/refund.svg +1 -0
- package/components/wechat-chat-control/transfer/transfer.svg +1 -0
- package/components/wechat-chat-control/transfer/transfer.vue +263 -0
- package/components/wechat-chat-control/unknow/unknow.vue +21 -0
- package/components/wechat-chat-control/url/icons/link.svg +1 -0
- package/components/wechat-chat-control/url/icons/video.svg +6 -0
- package/components/wechat-chat-control/url/miniprogram.svg +1 -0
- package/components/wechat-chat-control/url/url-file.vue +47 -0
- package/components/wechat-chat-control/url/url-link.vue +169 -0
- package/components/wechat-chat-control/url/url-merge.vue +164 -0
- package/components/wechat-chat-control/url/url-miniprogram.vue +259 -0
- package/components/wechat-chat-control/url/url.vue +116 -0
- package/components/wechat-chat-control/util.js +234 -0
- package/components/wechat-chat-control/video/icons/video.svg +1 -0
- package/components/wechat-chat-control/video/video.vue +304 -0
- package/components/wechat-chat-control/voice/icons/voice.svg +1 -0
- package/components/wechat-chat-control/voice/voice.vue +464 -0
- package/components/wechat-chat-control/wechat-chat-control-config-item.vue +24 -0
- package/components/wechat-chat-control/wechat-chat-control-config-msg.vue +21 -0
- package/components/wechat-chat-control/wechat-chat-control-config.vue +57 -0
- package/components/wechat-chat-panel/chat-panel-chat-status/chat-panel-chat-status.vue +69 -0
- package/components/wechat-chat-panel/chat-panel-item.vue +695 -0
- package/components/wechat-chat-panel/chat-panel.vue +257 -0
- package/components/wechat-chat-panel/index.js +3 -0
- package/components/wework-chat-control/calling/calling.vue +223 -0
- package/components/wework-chat-control/calling/phone-fill.svg +1 -0
- package/components/wework-chat-control/calling/vidicon-fill.svg +1 -0
- package/components/wework-chat-control/channel-live/channel-live.vue +198 -0
- package/components/wework-chat-control/channel-live/quote-icon.svg +1 -0
- package/components/wework-chat-control/channel-video/channel-video.vue +180 -0
- package/components/wework-chat-control/channel-video/quote-icon.svg +1 -0
- package/components/wework-chat-control/company-card/company-card.vue +136 -0
- package/components/wework-chat-control/company-card/quote-icon.svg +1 -0
- package/components/wework-chat-control/custom-expression/custom-expression.vue +34 -0
- package/components/wework-chat-control/empty/empty.vue +27 -0
- package/components/wework-chat-control/expression/expression.vue +53 -0
- package/components/wework-chat-control/file-url/file-url.vue +247 -0
- package/components/wework-chat-control/file-url/icons/file-excel-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/file-info-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/file-music-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/file-pdf-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/file-ppt-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/file-settings-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/file-text-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/file-unknow-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/file-word-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/file-zip-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/index.js +24 -0
- package/components/wework-chat-control/image/image.vue +296 -0
- package/components/wework-chat-control/image/index.js +1 -0
- package/components/wework-chat-control/image/util.js +21 -0
- package/components/wework-chat-control/index.js +105 -0
- package/components/wework-chat-control/jx-sys-text/jx-sys-text.vue +28 -0
- package/components/wework-chat-control/link/link.vue +100 -0
- package/components/wework-chat-control/location/location.vue +181 -0
- package/components/wework-chat-control/location/offline-bg.png +0 -0
- package/components/wework-chat-control/red-envelopes/quote-icon.svg +1 -0
- package/components/wework-chat-control/red-envelopes/red-envelope.svg +1 -0
- package/components/wework-chat-control/red-envelopes/red-envelopes.vue +168 -0
- package/components/wework-chat-control/share-card/quote-icon.svg +1 -0
- package/components/wework-chat-control/share-card/share-card.vue +140 -0
- package/components/wework-chat-control/text/icons/icon.svg +6 -0
- package/components/wework-chat-control/text/text.vue +157 -0
- package/components/wework-chat-control/unknow/unknow.vue +21 -0
- package/components/wework-chat-control/url/icons/link.svg +1 -0
- package/components/wework-chat-control/url/icons/video.svg +6 -0
- package/components/wework-chat-control/url/miniprogram.svg +1 -0
- package/components/wework-chat-control/url/url-file.vue +37 -0
- package/components/wework-chat-control/url/url-link.vue +169 -0
- package/components/wework-chat-control/url/url-merge.vue +164 -0
- package/components/wework-chat-control/url/url-miniprogram.vue +248 -0
- package/components/wework-chat-control/url/url.vue +103 -0
- package/components/wework-chat-control/util.js +223 -0
- package/components/wework-chat-control/video/icons/video.svg +1 -0
- package/components/wework-chat-control/video/video.vue +304 -0
- package/components/wework-chat-control/voice/icons/voice.svg +1 -0
- package/components/wework-chat-control/voice/voice.vue +464 -0
- package/components/wework-chat-panel/chat-panel-controls/company-card/company-card.vue +35 -0
- package/components/wework-chat-panel/chat-panel-controls/expression/expression.vue +36 -0
- package/components/wework-chat-panel/chat-panel-controls/file-url/file-url.vue +35 -0
- package/components/wework-chat-panel/chat-panel-controls/image/image.vue +36 -0
- package/components/wework-chat-panel/chat-panel-controls/index.js +35 -0
- package/components/wework-chat-panel/chat-panel-controls/jx-sys-text/jx-sys-text.vue +28 -0
- package/components/wework-chat-panel/chat-panel-controls/link/link.vue +35 -0
- package/components/wework-chat-panel/chat-panel-controls/location/location.vue +35 -0
- package/components/wework-chat-panel/chat-panel-controls/text/text.vue +43 -0
- package/components/wework-chat-panel/chat-panel-controls/unkonw/unkonw.vue +39 -0
- package/components/wework-chat-panel/chat-panel-controls/video/video.vue +37 -0
- package/components/wework-chat-panel/chat-panel-controls/voice/voice.vue +35 -0
- package/components/wework-chat-panel/chat-panel-item.vue +650 -0
- package/components/wework-chat-panel/chat-panel.vue +163 -0
- package/components/wework-chat-panel/index.js +3 -0
- package/package.json +23 -0
- package/services/client-chat/client-chat-wechat/client-chat-account.js +426 -0
- package/services/client-chat/client-chat-wechat/client-chat-concats.js +1029 -0
- package/services/client-chat/client-chat-wechat/client-chat-draft.js +92 -0
- package/services/client-chat/client-chat-wechat/client-chat-message.js +588 -0
- package/services/client-chat/client-chat-wechat/client-chat-session-manage.js +67 -0
- package/services/client-chat/client-chat-wechat/client-chat-session.js +1048 -0
- package/services/client-chat/client-chat-wechat/client-chat-socket.js +215 -0
- package/services/client-chat/client-chat-wechat/client-chat.js +1065 -0
- package/services/client-chat/client-chat-wechat/index.js +3 -0
- package/services/client-chat/client-chat-wechat/utils.js +82 -0
- package/services/client-chat/client-chat-wework/client-chat-account.js +310 -0
- package/services/client-chat/client-chat-wework/client-chat-concats.js +772 -0
- package/services/client-chat/client-chat-wework/client-chat-message.js +278 -0
- package/services/client-chat/client-chat-wework/client-chat-session.js +929 -0
- package/services/client-chat/client-chat-wework/client-chat-socket.js +64 -0
- package/services/client-chat/client-chat-wework/client-chat.js +330 -0
- package/services/client-chat/client-chat-wework/index.js +3 -0
- package/services/client-chat/client-chat-wework/utils.js +82 -0
- package/services/index.js +10 -0
- package/services/socket/index.js +5 -0
- package/services/socket/socket.js +797 -0
- package/services/socket/utils.js +7 -0
- package/uni-common/account-portray/account-portray.vue +51 -0
- package/uni-common/account-select/account-select-item.vue +172 -0
- package/uni-common/account-select/account-select.vue +252 -0
- package/uni-common/all-friend-avatar/all-friend-avatar.vue +49 -0
- package/uni-common/friend-avatar/default.svg +1 -0
- package/uni-common/friend-avatar/friend-avatar.vue +27 -0
- package/uni-common/friend-avatar/index.js +3 -0
- package/uni-common/friend-loader/friend-loader.vue +53 -0
- package/uni-common/friend-portray/friend-portray.vue +56 -0
- package/uni-common/group-avatar/default.svg +1 -0
- package/uni-common/group-avatar/group-avatar.vue +18 -0
- package/uni-common/group-avatar/index.js +3 -0
- package/uni-common/room-avatar/default.svg +6 -0
- package/uni-common/room-avatar/index.js +3 -0
- package/uni-common/room-avatar/room-avatar.vue +27 -0
- package/uni-common/room-loader/room-loader.vue +53 -0
- package/uni-common/room-portray/room-portray.vue +56 -0
- package/uni-components/chat-control/calling/calling.vue +91 -0
- package/uni-components/chat-control/calling/phone-fill.svg +1 -0
- package/uni-components/chat-control/calling/vidicon-fill.svg +1 -0
- package/uni-components/chat-control/channel-video/channel-video.vue +89 -0
- package/uni-components/chat-control/channel-video-card/channel-video-card.vue +105 -0
- package/uni-components/chat-control/channel-video-live/channel-video-live.vue +92 -0
- package/uni-components/chat-control/chat-control-config-item/chat-control-config-item.vue +20 -0
- package/uni-components/chat-control/chat-control-config-item/index.js +3 -0
- package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-app.vue +25 -0
- package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-h5.vue +21 -0
- package/uni-components/chat-control/chat-control-config.vue +59 -0
- package/uni-components/chat-control/chat-control.vue +218 -0
- package/uni-components/chat-control/company-card/company-card.vue +123 -0
- package/uni-components/chat-control/const.js +28 -0
- package/uni-components/chat-control/expression/expression.vue +41 -0
- package/uni-components/chat-control/image/image.vue +68 -0
- package/uni-components/chat-control/index.js +89 -0
- package/uni-components/chat-control/location/location.vue +110 -0
- package/uni-components/chat-control/member-change/member-change.vue +32 -0
- package/uni-components/chat-control/quote-message/quote-message.vue +216 -0
- package/uni-components/chat-control/real-time-position/real-time-position.vue +62 -0
- package/uni-components/chat-control/redpacket/red-envelope.svg +1 -0
- package/uni-components/chat-control/redpacket/redpacket.vue +75 -0
- package/uni-components/chat-control/share-card/share-card.vue +101 -0
- package/uni-components/chat-control/system/system.vue +69 -0
- package/uni-components/chat-control/system-batch-message/system-batch-message.vue +30 -0
- package/uni-components/chat-control/system-text/system-text.vue +32 -0
- package/uni-components/chat-control/text/text.vue +67 -0
- package/uni-components/chat-control/text-with-at/text-with-at.vue +51 -0
- package/uni-components/chat-control/transfer/red-transfer.svg +1 -0
- package/uni-components/chat-control/transfer/transfer.vue +80 -0
- package/uni-components/chat-control/unkonw/unkonw.vue +37 -0
- package/uni-components/chat-control/url/icons/file-excel-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-info-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-music-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-pdf-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-ppt-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-settings-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-text-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-unknow-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-word-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-zip-line.svg +1 -0
- package/uni-components/chat-control/url/icons/index.js +24 -0
- package/uni-components/chat-control/url/miniprogram.svg +1 -0
- package/uni-components/chat-control/url/url-miniprogram.vue +116 -0
- package/uni-components/chat-control/url/url.vue +306 -0
- package/uni-components/chat-control/url-new/icons/file-excel-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-info-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-music-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-pdf-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-ppt-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-settings-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-text-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-unknow-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-word-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-zip-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/index.js +24 -0
- package/uni-components/chat-control/url-new/url-new.vue +110 -0
- package/uni-components/chat-control/utils.js +12 -0
- package/uni-components/chat-control/video/video.vue +156 -0
- package/uni-components/chat-control/voice/voice.vue +166 -0
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-collect.vue +84 -0
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-system.vue +28 -0
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet.vue +85 -0
- package/uni-components/chat-editor/chat-editor-func/chat-editor-func.vue +157 -0
- package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at-panel.vue +158 -0
- package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at.vue +61 -0
- package/uni-components/chat-editor/chat-editor-func-button/chat-editor-func-button.vue +58 -0
- package/uni-components/chat-editor/chat-editor-func-file/chat-editor-func-file.vue +54 -0
- package/uni-components/chat-editor/chat-editor-func-image/chat-editor-func-image.vue +42 -0
- package/uni-components/chat-editor/chat-editor-func-video/chat-editor-func-video.vue +42 -0
- package/uni-components/chat-editor/chat-editor-func-voice/chat-editor-func-voice.vue +25 -0
- package/uni-components/chat-editor/chat-editor-message-send/chat-editor-message-send.vue +158 -0
- package/uni-components/chat-editor/chat-editor-quote/chat-editor-quote.vue +75 -0
- package/uni-components/chat-editor/chat-editor.vue +257 -0
- package/uni-components/chat-editor/index.js +10 -0
- package/uni-components/chat-editor/util.js +65 -0
- package/uni-components/chat-panel/chat-panel-chats-box.vue +238 -0
- package/uni-components/chat-panel/chat-panel-chats-forward/chat-panel-chats-forward.vue +273 -0
- package/uni-components/chat-panel/chat-panel-chats-item.vue +578 -0
- package/uni-components/chat-panel/chat-panel-chats-status/chat-panel-chats-status.vue +71 -0
- package/uni-components/chat-panel/chat-panel-chats.vue +368 -0
- package/uni-components/chat-panel/chat-panel.vue +227 -0
- package/uni-components/contacts-group-select/contacts-group-select-item.vue +85 -0
- package/uni-components/contacts-group-select/contacts-group-select-panel.vue +119 -0
- package/uni-components/contacts-group-select/contacts-group-select.vue +150 -0
- package/utils/color.js +178 -0
- package/utils/data.js +11 -0
- package/utils/date.js +107 -0
- package/utils/event.js +3 -0
- package/utils/file.js +26 -0
- package/utils/index.js +5 -0
- package/utils/json.js +40 -0
- package/utils/log.js +243 -0
- package/utils/queue.js +97 -0
- package/utils/regexp.js +9 -0
- package/utils/string.js +66 -0
- package/utils/url.js +48 -0
- package/utils/util.js +130 -0
|
@@ -0,0 +1,1065 @@
|
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
import ClientChatSession from './client-chat-session.js'
|
|
3
|
+
import ClientChatMessage from './client-chat-message.js'
|
|
4
|
+
import ClientChatContacts from './client-chat-concats.js'
|
|
5
|
+
import ClientChatAccount from './client-chat-account.js'
|
|
6
|
+
import ClientChatSocket from './client-chat-socket.js'
|
|
7
|
+
import ClientChatDraft from './client-chat-draft.js'
|
|
8
|
+
import { createSessionId } from '../../../utils/string.js'
|
|
9
|
+
import Event from '../../../utils/event.js'
|
|
10
|
+
import { createSerialQueue } from '../../../utils/queue'
|
|
11
|
+
import ClientChatSessionManage from './client-chat-session-manage.js'
|
|
12
|
+
|
|
13
|
+
const CONNECT_STATUS = {
|
|
14
|
+
Normal: 'normal',
|
|
15
|
+
Loading: 'loading',
|
|
16
|
+
Complete: 'complete'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function shouldIgnoreSessionByMessage (data) {
|
|
20
|
+
// 群发消息的不处理会话
|
|
21
|
+
// public enum MsgSubTypeEnum {
|
|
22
|
+
// /*0:普通的聊天*/
|
|
23
|
+
// COMMON,
|
|
24
|
+
// /*1:分配记录消息*/
|
|
25
|
+
// ALLOT_MSG,
|
|
26
|
+
// /*2:批量发送*/
|
|
27
|
+
// BATCH_SEND,
|
|
28
|
+
// /*3:通过好友恢复*/
|
|
29
|
+
// ACCEPT_REPLY,
|
|
30
|
+
// /*4:自动回复*/
|
|
31
|
+
// AUTO_REPLY,
|
|
32
|
+
// // 5:入群欢迎语
|
|
33
|
+
// CHATROOM_WELCOME,
|
|
34
|
+
// //6:指定时间段内自动回复消息
|
|
35
|
+
// AUTO_REPLY_INTIME,
|
|
36
|
+
// //7:群自动回复
|
|
37
|
+
// CHATROOM_REPLY
|
|
38
|
+
// }
|
|
39
|
+
if (data.msgSubType === 2) {
|
|
40
|
+
return true
|
|
41
|
+
}
|
|
42
|
+
return data && data.msgType === 10000 && data.content && ['消息已发出,但被对方拒收了', '请先发送朋友验证请求,对方验证通过后,才能聊天'].some(v => data.content.indexOf(v) >= 0)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function isAutoReadMessage (data) {
|
|
46
|
+
return !!(data && data.id && data.id.indexOf('AUTO-READ-') === 0)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
class ClientChat {
|
|
50
|
+
data = Vue.observable({
|
|
51
|
+
connectStatus: CONNECT_STATUS.Normal
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
get connecting () {
|
|
55
|
+
return this.data.connectStatus === CONNECT_STATUS.Loading
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
constructor (options) {
|
|
59
|
+
options = Object.assign({
|
|
60
|
+
socket: null,
|
|
61
|
+
checkSocketEventNotifyMethod: null,
|
|
62
|
+
getLoginUserIdMethod: null,
|
|
63
|
+
getLoginUserTokenMethod: null,
|
|
64
|
+
loadAccountDataMethod: null,
|
|
65
|
+
getLoginAccountIdMethod: null, // 因为1.0有帮聊逻辑,帮聊消息以及通讯录的accountId不是登录用户的accountId,会导致找到的会话出现问题,所以这里提供一个方法让外部传入
|
|
66
|
+
getAccountUnreadMessageNumMethod: null,
|
|
67
|
+
updateAccountMessageReadMethod: null,
|
|
68
|
+
deleteAccountSessionMethod: null,
|
|
69
|
+
getAccountGreetingUnreadMsgCountMethod: null,
|
|
70
|
+
clearAccountGreetingUnreadMsgCountMethod: null,
|
|
71
|
+
loadContactsRoomGroupDataMethod: null,
|
|
72
|
+
loadContactsFriendGroupDataMethod: null,
|
|
73
|
+
loadContactsFriendDataMethod: null,
|
|
74
|
+
loadContactsRoomDataMethod: null,
|
|
75
|
+
loadContactsRoomMemberDataMethod: null,
|
|
76
|
+
getContactsFriendGroupCountMethod: null,
|
|
77
|
+
getContactsRoomGroupCountMethod: null,
|
|
78
|
+
getContactsFriendMethod: null,
|
|
79
|
+
getContactsRoomMethod: null,
|
|
80
|
+
stickyTopSessionMethod: null,
|
|
81
|
+
muteNotificationSessionMethod: null,
|
|
82
|
+
deleteSessionMethod: null,
|
|
83
|
+
getNextUnreadSessionMethod: null,
|
|
84
|
+
loadSessionDataMethod: null,
|
|
85
|
+
loadAssignTaskSessionDataMethod: null,
|
|
86
|
+
updateSessionReadMethod: null,
|
|
87
|
+
loadStarSessionDataMethod: null,
|
|
88
|
+
loadUnreadSessionDataMethod: null,
|
|
89
|
+
starSessionMethod: null,
|
|
90
|
+
unstarSessionMethod: null,
|
|
91
|
+
getSessionMethod: null,
|
|
92
|
+
loadFriendMessageDataMethod: null,
|
|
93
|
+
loadRoomMessageDataMethod: null,
|
|
94
|
+
checkMessageSendResultMethod: null,
|
|
95
|
+
loadLossRoomMessageDataMethod: null,
|
|
96
|
+
loadLossFriendMessageDataMethod: null,
|
|
97
|
+
onOverwriteFriendInfoChange: null // 为了兼容1.0拉取会话逻辑加的,1.0暂时不支持根据taskId拉取
|
|
98
|
+
}, options)
|
|
99
|
+
if (!options.loadFriendMessageDataMethod) {
|
|
100
|
+
throw new Error('loadFriendMessageDataMethod不能为空')
|
|
101
|
+
}
|
|
102
|
+
if (!options.loadRoomMessageDataMethod) {
|
|
103
|
+
throw new Error('loadRoomMessageDataMethod不能为空')
|
|
104
|
+
}
|
|
105
|
+
this.onOverwriteFriendInfoChange = options.onOverwriteFriendInfoChange
|
|
106
|
+
this.event = new Event({
|
|
107
|
+
checkOnMethod: (name) => {
|
|
108
|
+
if (name === 'ready') {
|
|
109
|
+
if (this.data.connectStatus === CONNECT_STATUS.Complete) {
|
|
110
|
+
this.event.emit('ready')
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
const mergeSessionCommonOptions = (options, instance) => {
|
|
116
|
+
let updateSessioning = false
|
|
117
|
+
let deleteSessioning = false
|
|
118
|
+
options.onAddSession = ({ session }) => {
|
|
119
|
+
// 同步未读会话
|
|
120
|
+
if (instance !== this.sessionUnread && session.unreadMsgCount > 0) {
|
|
121
|
+
const localSession = this.sessionUnread.findSession((localSession) => localSession.conversationId === session.conversationId)
|
|
122
|
+
if (!localSession) {
|
|
123
|
+
this.sessionUnread.addSession(Object.assign({}, session))
|
|
124
|
+
} else {
|
|
125
|
+
this.sessionUnread.updateSession(session.conversationId, session)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
options.onUpdateSession = ({ session, updateProps, changeProps }) => {
|
|
130
|
+
if (updateSessioning) {
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
updateSessioning = true
|
|
134
|
+
try {
|
|
135
|
+
if (changeProps && changeProps.mute) {
|
|
136
|
+
this.account.refreshAccountUnreadMessageNum({
|
|
137
|
+
wechatAccountId: session.wechatAccountId
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
if (changeProps && changeProps.starMark) {
|
|
141
|
+
if (changeProps.starMark.after === true) {
|
|
142
|
+
this.sessionStar.addSession(Object.assign({}, session))
|
|
143
|
+
} else {
|
|
144
|
+
this.sessionStar.removeSession(session.conversationId, false)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// 同步未读会话,如果是从最近会话更新的才同步,否则会导致从未读会话标记已读马上就删除了
|
|
148
|
+
if (instance === this.session && changeProps && changeProps.unreadMsgCount && changeProps.unreadMsgCount.after > 0) {
|
|
149
|
+
const localSession = this.sessionUnread.findSession((localSession) => localSession.conversationId === session.conversationId)
|
|
150
|
+
if (!localSession) {
|
|
151
|
+
this.sessionUnread.addSession(Object.assign({}, session))
|
|
152
|
+
} else {
|
|
153
|
+
this.sessionUnread.updateSession(session.conversationId, session)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const sessionInstances = this.sessionManage.getSessionInstacesBySessionId(session.conversationId)
|
|
157
|
+
sessionInstances.forEach(sessionInstance => {
|
|
158
|
+
if (instance === sessionInstance) {
|
|
159
|
+
return
|
|
160
|
+
}
|
|
161
|
+
// 同步其他session实例
|
|
162
|
+
sessionInstance.updateSession(session.conversationId, updateProps)
|
|
163
|
+
})
|
|
164
|
+
} catch (error) {
|
|
165
|
+
console.error('[client-chat] onUpdateSession sync error', {
|
|
166
|
+
instance: instance && instance.name,
|
|
167
|
+
sessionId: session && session.conversationId,
|
|
168
|
+
updateProps,
|
|
169
|
+
changeProps,
|
|
170
|
+
error
|
|
171
|
+
})
|
|
172
|
+
throw error
|
|
173
|
+
} finally {
|
|
174
|
+
updateSessioning = false
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
options.onRemoveSession = ({ session }) => {
|
|
178
|
+
// 移除不做同步,例如未读会话,前端会自己删除已读的会话,这个时候不能做同步,否则会把最近会话也移除了
|
|
179
|
+
}
|
|
180
|
+
options.onDeleteSession = ({ session }) => {
|
|
181
|
+
if (!session) {
|
|
182
|
+
return
|
|
183
|
+
}
|
|
184
|
+
if (deleteSessioning) {
|
|
185
|
+
return
|
|
186
|
+
}
|
|
187
|
+
deleteSessioning = true
|
|
188
|
+
try {
|
|
189
|
+
this.account.updateAccountUnreadMessageNum(session.wechatAccountId, ({ unreadMesasgeNum, unreadMessageMuteNum }) => {
|
|
190
|
+
// 如果是免打扰的会话
|
|
191
|
+
if (session.mute) {
|
|
192
|
+
return {
|
|
193
|
+
num: Math.max((unreadMesasgeNum || 0) - (session.unreadMsgCount || 0), 0),
|
|
194
|
+
muteNum: Math.max((unreadMessageMuteNum || 0) - (session.unreadMsgCount || 0), 0)
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
return {
|
|
198
|
+
num: Math.max((unreadMesasgeNum || 0) - (session.unreadMsgCount || 0), 0),
|
|
199
|
+
muteNum: unreadMessageMuteNum
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
// 删除会话会同步删除所有的实例,所以需要做这个检查
|
|
204
|
+
if (this.sessionManage.currentSession && this.sessionManage.currentSession.conversationId === session.conversationId) {
|
|
205
|
+
this.sessionManage.setCurrentSession(null)
|
|
206
|
+
}
|
|
207
|
+
const sessionInstances = this.sessionManage.getSessionInstacesBySessionId(session.conversationId)
|
|
208
|
+
sessionInstances.forEach(sessionInstance => {
|
|
209
|
+
if (instance === sessionInstance) {
|
|
210
|
+
return
|
|
211
|
+
}
|
|
212
|
+
// 移除前先把未读消息数量设置为0,否则后面微信号的未读数量会重复扣减
|
|
213
|
+
sessionInstance.updateSession(session.conversationId, {
|
|
214
|
+
unreadMsgCount: 0
|
|
215
|
+
})
|
|
216
|
+
// 同步其他session实例
|
|
217
|
+
sessionInstance.removeSession(session.conversationId)
|
|
218
|
+
})
|
|
219
|
+
} catch (error) {
|
|
220
|
+
console.error('[client-chat] onDeleteSession sync error', {
|
|
221
|
+
instance: instance && instance.name,
|
|
222
|
+
sessionId: session && session.conversationId,
|
|
223
|
+
error
|
|
224
|
+
})
|
|
225
|
+
throw error
|
|
226
|
+
} finally {
|
|
227
|
+
deleteSessioning = false
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
options.onClearVirtualSession = ({ virtualSessionData }) => {
|
|
231
|
+
const selectedVirtualSession = virtualSessionData.find(v => this.sessionManage.currentSession && v.conversationId === this.sessionManage.currentSession.conversationId)
|
|
232
|
+
if (selectedVirtualSession) {
|
|
233
|
+
this.sessionManage.setCurrentSession(null)
|
|
234
|
+
}
|
|
235
|
+
// 还要更新未读消息数量
|
|
236
|
+
}
|
|
237
|
+
options.onSessionReadChange = ({ session, oldUnreadMsgCount }) => {
|
|
238
|
+
const isMute = session.mute
|
|
239
|
+
this.account.updateAccountUnreadMessageNum(session.wechatAccountId, ({ unreadMesasgeNum, unreadMessageMuteNum }) => {
|
|
240
|
+
// 如果是免打扰的会话
|
|
241
|
+
if (isMute) {
|
|
242
|
+
return {
|
|
243
|
+
num: Math.max(0, unreadMesasgeNum - oldUnreadMsgCount),
|
|
244
|
+
muteNum: Math.max(0, unreadMessageMuteNum - oldUnreadMsgCount)
|
|
245
|
+
}
|
|
246
|
+
} else {
|
|
247
|
+
return {
|
|
248
|
+
num: Math.max(0, unreadMesasgeNum - oldUnreadMsgCount),
|
|
249
|
+
muteNum: unreadMessageMuteNum
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
})
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
this.session = new ClientChatSession({
|
|
256
|
+
groupField: 'wechatAccountId',
|
|
257
|
+
sortField: 'lastMsgTime',
|
|
258
|
+
name: 'session',
|
|
259
|
+
loadAssignTaskSessionDataMethod: options.loadAssignTaskSessionDataMethod,
|
|
260
|
+
loadSessionDataMethod: options.loadSessionDataMethod,
|
|
261
|
+
updateSessionReadMethod: options.updateSessionReadMethod,
|
|
262
|
+
getSessionMethod: options.getSessionMethod,
|
|
263
|
+
stickyTopSessionMethod: options.stickyTopSessionMethod,
|
|
264
|
+
muteNotificationSessionMethod: options.muteNotificationSessionMethod,
|
|
265
|
+
getNextUnreadSessionMethod: options.getNextUnreadSessionMethod,
|
|
266
|
+
deleteSessionMethod: options.deleteSessionMethod,
|
|
267
|
+
starSessionMethod: options.starSessionMethod,
|
|
268
|
+
unstarSessionMethod: options.unstarSessionMethod,
|
|
269
|
+
onBeforeCreate: ({ options, instance }) => {
|
|
270
|
+
mergeSessionCommonOptions(options, instance)
|
|
271
|
+
}
|
|
272
|
+
})
|
|
273
|
+
this.sessionFilter = new ClientChatSession({
|
|
274
|
+
groupField: 'wechatAccountId',
|
|
275
|
+
sortField: 'lastMsgTime',
|
|
276
|
+
name: 'sessionFilter',
|
|
277
|
+
loadAssignTaskSessionDataMethod: options.loadAssignTaskSessionDataMethod,
|
|
278
|
+
loadSessionDataMethod: options.loadSessionDataMethod,
|
|
279
|
+
updateSessionReadMethod: options.updateSessionReadMethod,
|
|
280
|
+
getSessionMethod: options.getSessionMethod,
|
|
281
|
+
stickyTopSessionMethod: options.stickyTopSessionMethod,
|
|
282
|
+
muteNotificationSessionMethod: options.muteNotificationSessionMethod,
|
|
283
|
+
deleteSessionMethod: options.deleteSessionMethod,
|
|
284
|
+
starSessionMethod: options.starSessionMethod,
|
|
285
|
+
unstarSessionMethod: options.unstarSessionMethod,
|
|
286
|
+
onBeforeCreate: ({ options, instance }) => {
|
|
287
|
+
mergeSessionCommonOptions(options, instance)
|
|
288
|
+
}
|
|
289
|
+
})
|
|
290
|
+
this.sessionStar = new ClientChatSession({
|
|
291
|
+
groupField: 'wechatAccountId',
|
|
292
|
+
sortField: 'lastMsgTime',
|
|
293
|
+
name: 'sessionStar',
|
|
294
|
+
loadAssignTaskSessionDataMethod: options.loadAssignTaskSessionDataMethod,
|
|
295
|
+
loadSessionDataMethod: (params, context) => {
|
|
296
|
+
if (!options.loadStarSessionDataMethod) {
|
|
297
|
+
return Promise.resolve({
|
|
298
|
+
data: []
|
|
299
|
+
})
|
|
300
|
+
}
|
|
301
|
+
return options.loadStarSessionDataMethod(params, context)
|
|
302
|
+
},
|
|
303
|
+
updateSessionReadMethod: options.updateSessionReadMethod,
|
|
304
|
+
getSessionMethod: options.getSessionMethod,
|
|
305
|
+
stickyTopSessionMethod: options.stickyTopSessionMethod,
|
|
306
|
+
muteNotificationSessionMethod: options.muteNotificationSessionMethod,
|
|
307
|
+
deleteSessionMethod: options.deleteSessionMethod,
|
|
308
|
+
starSessionMethod: options.starSessionMethod,
|
|
309
|
+
unstarSessionMethod: options.unstarSessionMethod,
|
|
310
|
+
onBeforeCreate: ({ options, instance }) => {
|
|
311
|
+
mergeSessionCommonOptions(options, instance)
|
|
312
|
+
}
|
|
313
|
+
})
|
|
314
|
+
this.sessionUnread = new ClientChatSession({
|
|
315
|
+
groupField: 'wechatAccountId',
|
|
316
|
+
sortField: 'lastMsgTime',
|
|
317
|
+
name: 'sessionUnread',
|
|
318
|
+
loadAssignTaskSessionDataMethod: options.loadAssignTaskSessionDataMethod,
|
|
319
|
+
loadSessionDataMethod: (params, context) => {
|
|
320
|
+
if (!options.loadUnreadSessionDataMethod) {
|
|
321
|
+
return Promise.resolve({
|
|
322
|
+
data: []
|
|
323
|
+
})
|
|
324
|
+
}
|
|
325
|
+
return options.loadUnreadSessionDataMethod(params, context)
|
|
326
|
+
},
|
|
327
|
+
updateSessionReadMethod: options.updateSessionReadMethod,
|
|
328
|
+
getSessionMethod: options.getSessionMethod,
|
|
329
|
+
stickyTopSessionMethod: options.stickyTopSessionMethod,
|
|
330
|
+
muteNotificationSessionMethod: options.muteNotificationSessionMethod,
|
|
331
|
+
deleteSessionMethod: options.deleteSessionMethod,
|
|
332
|
+
starSessionMethod: options.starSessionMethod,
|
|
333
|
+
unstarSessionMethod: options.unstarSessionMethod,
|
|
334
|
+
onBeforeCreate: ({ options, instance }) => {
|
|
335
|
+
mergeSessionCommonOptions(options, instance)
|
|
336
|
+
}
|
|
337
|
+
})
|
|
338
|
+
this.sessionManage = new ClientChatSessionManage({
|
|
339
|
+
sessionInstanceList: [
|
|
340
|
+
this.session,
|
|
341
|
+
this.sessionFilter,
|
|
342
|
+
this.sessionStar,
|
|
343
|
+
this.sessionUnread
|
|
344
|
+
],
|
|
345
|
+
onCurrentSessionChange: (evt) => {
|
|
346
|
+
if (evt && evt.sessionId) {
|
|
347
|
+
// 获取所有会话实例集合
|
|
348
|
+
const sessionInstances = this.sessionManage.getSessionInstacesBySessionId(evt.sessionId)
|
|
349
|
+
// 标记会话已读
|
|
350
|
+
// 只给第一个设置就行了,后面会同步已读状态的
|
|
351
|
+
if (sessionInstances && sessionInstances.length) {
|
|
352
|
+
sessionInstances[0].setSessionRead(evt.sessionId)
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
})
|
|
357
|
+
this.friendMessage = new ClientChatMessage({
|
|
358
|
+
groupField: 'wechatFriendId',
|
|
359
|
+
sortField: 'wechatTime',
|
|
360
|
+
clientChat: this,
|
|
361
|
+
checkMessageSendResultMethod: options.checkMessageSendResultMethod,
|
|
362
|
+
loadLossMessageDataMethod: options.loadLossFriendMessageDataMethod,
|
|
363
|
+
onAddMessageSuccess: ({ data }) => {
|
|
364
|
+
const accountId = options.getLoginAccountIdMethod ? options.getLoginAccountIdMethod() : data.accountId
|
|
365
|
+
let sessionId = createSessionId(accountId, data.wechatFriendId)
|
|
366
|
+
// 更新会话
|
|
367
|
+
if (!sessionId) {
|
|
368
|
+
return
|
|
369
|
+
}
|
|
370
|
+
if (isAutoReadMessage(data)) {
|
|
371
|
+
return this.handleAutoReadMessageSession(sessionId)
|
|
372
|
+
}
|
|
373
|
+
// 如果消息包含这种情况,就不加入会话列表
|
|
374
|
+
if (shouldIgnoreSessionByMessage(data)) {
|
|
375
|
+
return
|
|
376
|
+
}
|
|
377
|
+
const localSession = this.session.findSession(({ session }) => session.conversationId === sessionId)
|
|
378
|
+
if (!localSession) {
|
|
379
|
+
this.socket.addLog({
|
|
380
|
+
group: 'client-chat-message:onAddMessageSuccess',
|
|
381
|
+
content: {
|
|
382
|
+
title: '未获取到会话,开始从服务端获取',
|
|
383
|
+
data: {
|
|
384
|
+
sessionId,
|
|
385
|
+
accountId,
|
|
386
|
+
wechatFriendId: data.wechatFriendId
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
})
|
|
390
|
+
return this.session.getSession(sessionId, rs => {
|
|
391
|
+
// https://vs.rpa.cn/zentao/bug-view-2411.html
|
|
392
|
+
// 如果后端返回的未读数量是0,那么前端先自己兼容一下,因为后端更新会话是异步过程,有可能这里获取到的会话信息还是老的,并不是这个消息更新之后的信息,得看后端会不会异步改成同步
|
|
393
|
+
if (rs && rs.data && !rs.data.unreadMsgCount) {
|
|
394
|
+
rs.data.unreadMsgCount = data.isSend ? 0 : 1
|
|
395
|
+
rs.data.lastMsgContent = data.content
|
|
396
|
+
rs.data.lastMsgType = data.msgType
|
|
397
|
+
rs.data.lastMsgTime = data.wechatTime
|
|
398
|
+
rs.data.lastMsgId = data.id
|
|
399
|
+
rs.data.lastUpdateTime = data.updateDate
|
|
400
|
+
}
|
|
401
|
+
return rs
|
|
402
|
+
}).then((rs) => {
|
|
403
|
+
// 更新账号未读消息数量
|
|
404
|
+
this.account.updateAccountUnreadMessageNum(rs.data.wechatAccountId, ({ unreadMesasgeNum, unreadMessageMuteNum }) => {
|
|
405
|
+
if (rs.data.mute) {
|
|
406
|
+
return {
|
|
407
|
+
num: (unreadMesasgeNum || 0) + (rs.data.unreadMsgCount || 0),
|
|
408
|
+
muteNum: (unreadMessageMuteNum || 0) + (rs.data.unreadMsgCount || 0)
|
|
409
|
+
}
|
|
410
|
+
} else {
|
|
411
|
+
return {
|
|
412
|
+
num: (unreadMesasgeNum || 0) + (rs.data.unreadMsgCount || 0),
|
|
413
|
+
muteNum: unreadMessageMuteNum
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
})
|
|
417
|
+
}, (error) => {
|
|
418
|
+
this.socket.addLog({
|
|
419
|
+
group: 'client-chat-message:onAddMessageSuccess',
|
|
420
|
+
content: {
|
|
421
|
+
title: '未获取到会话,从服务端获取失败',
|
|
422
|
+
data: {
|
|
423
|
+
error: error && (error.message || error.errMsg || error.toString && error.toString()) || error,
|
|
424
|
+
sessionId,
|
|
425
|
+
accountId,
|
|
426
|
+
wechatFriendId: data.wechatFriendId
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
})
|
|
430
|
+
})
|
|
431
|
+
} else {
|
|
432
|
+
this.session.updateSession(sessionId, ({ session }) => {
|
|
433
|
+
const nextSession = {
|
|
434
|
+
lastMsgContent: data.content,
|
|
435
|
+
lastMsgType: data.msgType,
|
|
436
|
+
lastMsgTime: data.wechatTime,
|
|
437
|
+
lastMsgId: data.id,
|
|
438
|
+
lastUpdateTime: data.updateDate,
|
|
439
|
+
unreadMsgCount: session.unreadMsgCount
|
|
440
|
+
}
|
|
441
|
+
if (!data.isSend) {
|
|
442
|
+
if (this.sessionManage.currentSession && this.sessionManage.currentSession.conversationId === sessionId) {
|
|
443
|
+
// 标记已读
|
|
444
|
+
this.session.setSessionRead(sessionId)
|
|
445
|
+
} else {
|
|
446
|
+
nextSession.unreadMsgCount = session.unreadMsgCount + 1
|
|
447
|
+
// 更新账号未读消息数量
|
|
448
|
+
this.account.updateAccountUnreadMessageNum(session.wechatAccountId, ({ unreadMesasgeNum, unreadMessageMuteNum }) => {
|
|
449
|
+
if (session.mute) {
|
|
450
|
+
return {
|
|
451
|
+
num: (unreadMesasgeNum || 0) + 1,
|
|
452
|
+
muteNum: (unreadMessageMuteNum || 0) + 1
|
|
453
|
+
}
|
|
454
|
+
} else {
|
|
455
|
+
return {
|
|
456
|
+
num: (unreadMesasgeNum || 0) + 1,
|
|
457
|
+
muteNum: unreadMessageMuteNum
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
})
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return nextSession
|
|
464
|
+
})
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
queryMethod: (params) => {
|
|
468
|
+
return options.loadFriendMessageDataMethod(params)
|
|
469
|
+
}
|
|
470
|
+
})
|
|
471
|
+
this.friendMessageFilter = new ClientChatMessage({
|
|
472
|
+
groupField: 'wechatFriendId',
|
|
473
|
+
sortField: 'wechatTime',
|
|
474
|
+
clientChat: this,
|
|
475
|
+
checkMessageSendResultMethod: options.checkMessageSendResultMethod,
|
|
476
|
+
loadLossMessageDataMethod: options.loadLossFriendMessageDataMethod,
|
|
477
|
+
queryMethod: (params) => {
|
|
478
|
+
return options.loadFriendMessageDataMethod(params)
|
|
479
|
+
}
|
|
480
|
+
})
|
|
481
|
+
this.friendMessageContext = new ClientChatMessage({
|
|
482
|
+
groupField: 'wechatFriendId',
|
|
483
|
+
sortField: 'wechatTime',
|
|
484
|
+
clientChat: this,
|
|
485
|
+
checkMessageSendResultMethod: options.checkMessageSendResultMethod,
|
|
486
|
+
loadLossMessageDataMethod: options.loadLossFriendMessageDataMethod,
|
|
487
|
+
queryMethod: (params) => {
|
|
488
|
+
return options.loadFriendMessageDataMethod(params)
|
|
489
|
+
}
|
|
490
|
+
})
|
|
491
|
+
this.roomMessage = new ClientChatMessage({
|
|
492
|
+
groupField: 'wechatChatroomId',
|
|
493
|
+
sortField: 'wechatTime',
|
|
494
|
+
clientChat: this,
|
|
495
|
+
checkMessageSendResultMethod: options.checkMessageSendResultMethod,
|
|
496
|
+
loadLossMessageDataMethod: options.loadLossRoomMessageDataMethod,
|
|
497
|
+
onAddMessageSuccess: ({ data }) => {
|
|
498
|
+
const accountId = options.getLoginAccountIdMethod ? options.getLoginAccountIdMethod() : data.accountId
|
|
499
|
+
let sessionId = createSessionId(accountId, data.wechatChatroomId)
|
|
500
|
+
// 更新会话
|
|
501
|
+
if (!sessionId) {
|
|
502
|
+
return
|
|
503
|
+
}
|
|
504
|
+
if (isAutoReadMessage(data)) {
|
|
505
|
+
return this.handleAutoReadMessageSession(sessionId)
|
|
506
|
+
}
|
|
507
|
+
// 如果消息包含这种情况,就不加入会话列表
|
|
508
|
+
if (shouldIgnoreSessionByMessage(data)) {
|
|
509
|
+
return
|
|
510
|
+
}
|
|
511
|
+
// 更新会话未读消息数量
|
|
512
|
+
const localSession = this.session.findSession(({ session }) => session.conversationId === sessionId)
|
|
513
|
+
if (!localSession) {
|
|
514
|
+
this.socket.addLog({
|
|
515
|
+
group: 'client-chat-message:onAddMessageSuccess',
|
|
516
|
+
content: {
|
|
517
|
+
title: '未获取到会话,开始从服务端获取',
|
|
518
|
+
data: {
|
|
519
|
+
sessionId,
|
|
520
|
+
accountId,
|
|
521
|
+
wechatChatroomId: data.wechatChatroomId
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
})
|
|
525
|
+
this.session.getSession(sessionId, (rs) => {
|
|
526
|
+
// https://vs.rpa.cn/zentao/bug-view-2411.html
|
|
527
|
+
// 如果后端返回的未读数量是0,那么前端先自己兼容一下,因为后端更新会话是异步过程,有可能这里获取到的会话信息还是老的,并不是这个消息更新之后的信息,得看后端会不会异步改成同步
|
|
528
|
+
if (rs && rs.data && !rs.data.unreadMsgCount) {
|
|
529
|
+
rs.data.unreadMsgCount = data.isSend ? 0 : 1
|
|
530
|
+
rs.data.lastMsgContent = data.content
|
|
531
|
+
rs.data.lastMsgType = data.msgType
|
|
532
|
+
rs.data.lastMsgTime = data.wechatTime
|
|
533
|
+
rs.data.lastMsgId = data.id
|
|
534
|
+
rs.data.lastUpdateTime = data.updateDate
|
|
535
|
+
}
|
|
536
|
+
return rs
|
|
537
|
+
}).then((rs) => {
|
|
538
|
+
// 更新账号未读消息数量
|
|
539
|
+
this.account.updateAccountUnreadMessageNum(rs.data.wechatAccountId, ({ unreadMesasgeNum, unreadMessageMuteNum }) => {
|
|
540
|
+
if (rs.data.mute) {
|
|
541
|
+
return {
|
|
542
|
+
num: (unreadMesasgeNum || 0) + (rs.data.unreadMsgCount || 0),
|
|
543
|
+
muteNum: (unreadMessageMuteNum || 0) + (rs.data.unreadMsgCount || 0)
|
|
544
|
+
}
|
|
545
|
+
} else {
|
|
546
|
+
return {
|
|
547
|
+
num: (unreadMesasgeNum || 0) + (rs.data.unreadMsgCount || 0),
|
|
548
|
+
muteNum: unreadMessageMuteNum
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
})
|
|
552
|
+
}, (error) => {
|
|
553
|
+
this.socket.addLog({
|
|
554
|
+
group: 'client-chat-message:onAddMessageSuccess',
|
|
555
|
+
content: {
|
|
556
|
+
title: '未获取到会话,从服务端获取失败',
|
|
557
|
+
data: {
|
|
558
|
+
error: error && (error.message || error.errMsg || error.toString && error.toString()) || error,
|
|
559
|
+
sessionId,
|
|
560
|
+
accountId,
|
|
561
|
+
wechatChatroomId: data.wechatChatroomId
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
})
|
|
565
|
+
})
|
|
566
|
+
} else {
|
|
567
|
+
this.session.updateSession(sessionId, ({ session }) => {
|
|
568
|
+
const nextSession = {
|
|
569
|
+
lastMsgContent: data.content,
|
|
570
|
+
lastMsgType: data.msgType,
|
|
571
|
+
lastMsgTime: data.wechatTime,
|
|
572
|
+
lastMsgId: data.id,
|
|
573
|
+
lastUpdateTime: data.updateDate,
|
|
574
|
+
unreadMsgCount: session.unreadMsgCount
|
|
575
|
+
}
|
|
576
|
+
if (!data.isSend) {
|
|
577
|
+
if (this.sessionManage.currentSession && this.sessionManage.currentSession.conversationId === sessionId) {
|
|
578
|
+
// 标记已读
|
|
579
|
+
this.session.setSessionRead(sessionId)
|
|
580
|
+
} else {
|
|
581
|
+
nextSession.unreadMsgCount = session.unreadMsgCount + 1
|
|
582
|
+
// 更新账号未读消息数量
|
|
583
|
+
this.account.updateAccountUnreadMessageNum(session.wechatAccountId, ({ unreadMesasgeNum, unreadMessageMuteNum }) => {
|
|
584
|
+
if (session.mute) {
|
|
585
|
+
return {
|
|
586
|
+
num: (unreadMesasgeNum || 0) + 1,
|
|
587
|
+
muteNum: (unreadMessageMuteNum || 0) + 1
|
|
588
|
+
}
|
|
589
|
+
} else {
|
|
590
|
+
return {
|
|
591
|
+
num: (unreadMesasgeNum || 0) + 1,
|
|
592
|
+
muteNum: unreadMessageMuteNum
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
})
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
return nextSession
|
|
599
|
+
})
|
|
600
|
+
}
|
|
601
|
+
},
|
|
602
|
+
queryMethod: (params) => {
|
|
603
|
+
return options.loadRoomMessageDataMethod(params)
|
|
604
|
+
}
|
|
605
|
+
})
|
|
606
|
+
this.roomMessageFilter = new ClientChatMessage({
|
|
607
|
+
groupField: 'wechatChatroomId',
|
|
608
|
+
sortField: 'wechatTime',
|
|
609
|
+
clientChat: this,
|
|
610
|
+
checkMessageSendResultMethod: options.checkMessageSendResultMethod,
|
|
611
|
+
loadLossMessageDataMethod: options.loadLossRoomMessageDataMethod,
|
|
612
|
+
queryMethod: (params) => {
|
|
613
|
+
return options.loadRoomMessageDataMethod(params)
|
|
614
|
+
}
|
|
615
|
+
})
|
|
616
|
+
this.roomMessageContext = new ClientChatMessage({
|
|
617
|
+
groupField: 'wechatChatroomId',
|
|
618
|
+
sortField: 'wechatTime',
|
|
619
|
+
clientChat: this,
|
|
620
|
+
checkMessageSendResultMethod: options.checkMessageSendResultMethod,
|
|
621
|
+
loadLossMessageDataMethod: options.loadLossRoomMessageDataMethod,
|
|
622
|
+
queryMethod: (params) => {
|
|
623
|
+
return options.loadRoomMessageDataMethod(params)
|
|
624
|
+
}
|
|
625
|
+
})
|
|
626
|
+
this.contacts = new ClientChatContacts({
|
|
627
|
+
loadContactsRoomGroupDataMethod: options.loadContactsRoomGroupDataMethod,
|
|
628
|
+
loadContactsFriendGroupDataMethod: options.loadContactsFriendGroupDataMethod,
|
|
629
|
+
loadContactsFriendDataMethod: options.loadContactsFriendDataMethod,
|
|
630
|
+
loadContactsRoomDataMethod: options.loadContactsRoomDataMethod,
|
|
631
|
+
loadContactsRoomMemberDataMethod: options.loadContactsRoomMemberDataMethod,
|
|
632
|
+
getContactsFriendMethod: options.getContactsFriendMethod,
|
|
633
|
+
getContactsRoomMethod: options.getContactsRoomMethod,
|
|
634
|
+
getContactsFriendGroupCountMethod: options.getContactsFriendGroupCountMethod,
|
|
635
|
+
getContactsRoomGroupCountMethod: options.getContactsRoomGroupCountMethod,
|
|
636
|
+
onContactsRoomRemoved: ({ room }) => {
|
|
637
|
+
const accountId = options.getLoginAccountIdMethod ? options.getLoginAccountIdMethod() : room.accountId
|
|
638
|
+
let sessionId = createSessionId(accountId, room.id)
|
|
639
|
+
if (sessionId) {
|
|
640
|
+
this.session.removeSession(sessionId)
|
|
641
|
+
}
|
|
642
|
+
},
|
|
643
|
+
onLoadRoomGroupData: () => {
|
|
644
|
+
if (this.account.currentAccount) {
|
|
645
|
+
this.contacts.refreshAllRoomGroupCount({
|
|
646
|
+
wechatAccountId: this.account.currentAccount.id
|
|
647
|
+
})
|
|
648
|
+
}
|
|
649
|
+
},
|
|
650
|
+
onLoadFriendGroupData: () => {
|
|
651
|
+
if (this.account.currentAccount) {
|
|
652
|
+
this.contacts.refreshAllFriendGroupCount({
|
|
653
|
+
wechatAccountId: this.account.currentAccount.id
|
|
654
|
+
})
|
|
655
|
+
}
|
|
656
|
+
},
|
|
657
|
+
onUpdateFriend: ({ friend, updateProps, changeProps }) => {
|
|
658
|
+
this.contactsFilter.updateFriend(friend.id, updateProps)
|
|
659
|
+
},
|
|
660
|
+
onUpdateRoom: ({ room, updateProps }) => {
|
|
661
|
+
this.contactsFilter.updateRoom(room.id, updateProps)
|
|
662
|
+
}
|
|
663
|
+
})
|
|
664
|
+
this.contactsFilter = new ClientChatContacts({
|
|
665
|
+
loadContactsRoomGroupDataMethod: options.loadContactsRoomGroupDataMethod,
|
|
666
|
+
loadContactsFriendGroupDataMethod: options.loadContactsFriendGroupDataMethod,
|
|
667
|
+
loadContactsFriendDataMethod: options.loadContactsFriendDataMethod,
|
|
668
|
+
loadContactsRoomDataMethod: options.loadContactsRoomDataMethod,
|
|
669
|
+
loadContactsRoomMemberDataMethod: options.loadContactsRoomMemberDataMethod,
|
|
670
|
+
getContactsFriendMethod: options.getContactsFriendMethod,
|
|
671
|
+
getContactsRoomMethod: options.getContactsRoomMethod,
|
|
672
|
+
getContactsFriendGroupCountMethod: options.getContactsFriendGroupCountMethod,
|
|
673
|
+
getContactsRoomGroupCountMethod: options.getContactsRoomGroupCountMethod,
|
|
674
|
+
onUpdateFriend: ({ friend, updateProps }) => {
|
|
675
|
+
this.contacts.updateFriend(friend.id, updateProps)
|
|
676
|
+
},
|
|
677
|
+
onUpdateRoom: ({ room, updateProps }) => {
|
|
678
|
+
this.contacts.updateRoom(room.id, updateProps)
|
|
679
|
+
}
|
|
680
|
+
})
|
|
681
|
+
this.account = new ClientChatAccount({
|
|
682
|
+
loadAccountDataMethod: options.loadAccountDataMethod,
|
|
683
|
+
getAccountUnreadMessageNumMethod: options.getAccountUnreadMessageNumMethod,
|
|
684
|
+
updateAccountMessageReadMethod: options.updateAccountMessageReadMethod,
|
|
685
|
+
deleteAccountSessionMethod: options.deleteAccountSessionMethod,
|
|
686
|
+
getAccountGreetingUnreadMsgCountMethod: options.getAccountGreetingUnreadMsgCountMethod,
|
|
687
|
+
clearAccountGreetingUnreadMsgCountMethod: options.clearAccountGreetingUnreadMsgCountMethod,
|
|
688
|
+
onAccountAdded: ({ account }) => {
|
|
689
|
+
return this.account.refreshAccountUnreadMessageNum({
|
|
690
|
+
wechatAccountId: account.id
|
|
691
|
+
})
|
|
692
|
+
},
|
|
693
|
+
onAccountLoaded: () => {
|
|
694
|
+
this.socket.doHeartbeat()
|
|
695
|
+
},
|
|
696
|
+
onCurrentAccountChange: ({ currentAccount }) => {
|
|
697
|
+
// 如果群分组数据加载了再去刷成员数量,这样可以做到按需
|
|
698
|
+
if (this.contacts.friendGroupData && this.contacts.friendGroupData.length) {
|
|
699
|
+
this.contacts.refreshAllFriendGroupCount({
|
|
700
|
+
wechatAccountId: currentAccount ? currentAccount.id : null
|
|
701
|
+
})
|
|
702
|
+
}
|
|
703
|
+
if (this.contacts.roomGroupData && this.contacts.roomGroupData.length) {
|
|
704
|
+
this.contacts.refreshAllRoomGroupCount({
|
|
705
|
+
wechatAccountId: currentAccount ? currentAccount.id : null
|
|
706
|
+
})
|
|
707
|
+
}
|
|
708
|
+
},
|
|
709
|
+
onUnreadMessageNumChange: ({ accountId, unreadMessageNum }) => {
|
|
710
|
+
if (unreadMessageNum === 0) {
|
|
711
|
+
// 将账号下的所有已拉取的会话标记已读
|
|
712
|
+
this.session.setAccountSessionRead(accountId)
|
|
713
|
+
}
|
|
714
|
+
},
|
|
715
|
+
onDeleteAccountSession: ({ accountId }) => {
|
|
716
|
+
// 删除账号会话后,将所有账号的会话数据删除
|
|
717
|
+
this.session.clearAccountSession(accountId)
|
|
718
|
+
}
|
|
719
|
+
})
|
|
720
|
+
this.draft = new ClientChatDraft({
|
|
721
|
+
clientChat: this
|
|
722
|
+
})
|
|
723
|
+
this.socket = new ClientChatSocket({
|
|
724
|
+
socket: options.socket,
|
|
725
|
+
getLoginUserIdMethod: options.getLoginUserIdMethod,
|
|
726
|
+
getLoginUserTokenMethod: options.getLoginUserTokenMethod,
|
|
727
|
+
checkSocketEventNotifyMethod: options.checkSocketEventNotifyMethod,
|
|
728
|
+
beforeFireCallback: () => {
|
|
729
|
+
return this.connectPromise
|
|
730
|
+
},
|
|
731
|
+
onCmdMessageRecalled: ({ data }) => {
|
|
732
|
+
if (data.wechatFriendId) {
|
|
733
|
+
const friendMessage = this.friendMessage.findMessage(({ message }) => {
|
|
734
|
+
return message.msgId == data.msgId
|
|
735
|
+
})
|
|
736
|
+
if (!friendMessage) {
|
|
737
|
+
return
|
|
738
|
+
}
|
|
739
|
+
this.friendMessage.updateMessage(friendMessage.id, {
|
|
740
|
+
recalled: true
|
|
741
|
+
})
|
|
742
|
+
} else if (data.wechatChatroomId) {
|
|
743
|
+
const roomMessage = this.roomMessage.findMessage(({ message }) => {
|
|
744
|
+
return message.msgId == data.msgId
|
|
745
|
+
})
|
|
746
|
+
if (!roomMessage) {
|
|
747
|
+
return
|
|
748
|
+
}
|
|
749
|
+
this.roomMessage.updateMessage(roomMessage.id, {
|
|
750
|
+
recalled: true
|
|
751
|
+
})
|
|
752
|
+
}
|
|
753
|
+
},
|
|
754
|
+
// 接受新消息
|
|
755
|
+
onCmdNewMessage: ({ data }) => {
|
|
756
|
+
// 插入消息
|
|
757
|
+
if (data.friendMessage) {
|
|
758
|
+
this.friendMessage.addMessage(data.friendMessage)
|
|
759
|
+
this.friendMessage.setLastReceiveMessageTime(data.friendMessage.wechatTime)
|
|
760
|
+
} else if (data.chatroomMessage) {
|
|
761
|
+
this.roomMessage.addMessage(data.chatroomMessage)
|
|
762
|
+
this.roomMessage.setLastReceiveMessageTime(data.chatroomMessage.wechatTime)
|
|
763
|
+
}
|
|
764
|
+
},
|
|
765
|
+
// 发送消息结果,状态回刷
|
|
766
|
+
onCmdSendMessageResult: ({ data }) => {
|
|
767
|
+
const { cmdType, friendMessageId, chatroomMessageId, errMsg, seq, ...nextData } = data
|
|
768
|
+
if (friendMessageId) {
|
|
769
|
+
this.friendMessage.updateMessage(friendMessageId, Object.assign(nextData, {
|
|
770
|
+
resultMsg: errMsg
|
|
771
|
+
}))
|
|
772
|
+
} else {
|
|
773
|
+
this.roomMessage.updateMessage(chatroomMessageId, Object.assign(nextData, {
|
|
774
|
+
resultMsg: errMsg
|
|
775
|
+
}))
|
|
776
|
+
}
|
|
777
|
+
},
|
|
778
|
+
// 群聊有变化,如分配的情况
|
|
779
|
+
onCmdChatroomInfoChanged: ({ data }) => {
|
|
780
|
+
// 移除群聊
|
|
781
|
+
if (data.changeType === 3) {
|
|
782
|
+
this.contacts.removeRoom(data.wechatChatroomId)
|
|
783
|
+
} else {
|
|
784
|
+
// 其他情况就重新刷新一下群信息
|
|
785
|
+
if (this.sessionManage.currentSession && this.sessionManage.currentSession.targetId === data.wechatChatroomId) {
|
|
786
|
+
this.contacts.getRoom(data.wechatChatroomId, true) // 强制刷新群数据
|
|
787
|
+
this.contacts.loadRoomMemberData(data.wechatChatroomId, { // 强制刷新群成员数据,因为有可能群主变化了
|
|
788
|
+
wechatChatroomId: data.wechatChatroomId
|
|
789
|
+
}, true)
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
onCmdChatroomMemberInfoChanged: ({ data }) => {
|
|
794
|
+
// 如果没有changeType的时候,目前看应该是群成员或者群信息变化了,需要重新刷新一下群成员和群信息
|
|
795
|
+
if (this.sessionManage.currentSession && this.sessionManage.currentSession.targetId === data.wechatChatroomId) {
|
|
796
|
+
this.contacts.loadRoomMemberData(data.wechatChatroomId, { // 强制刷新群成员数据
|
|
797
|
+
wechatChatroomId: data.wechatChatroomId
|
|
798
|
+
}, true)
|
|
799
|
+
}
|
|
800
|
+
},
|
|
801
|
+
// 邀请成员
|
|
802
|
+
onCmdChatroomInvite: ({ data }) => {
|
|
803
|
+
// 如果没有changeType的时候,目前看应该是群成员或者群信息变化了,需要重新刷新一下群成员和群信息
|
|
804
|
+
if (this.sessionManage.currentSession && this.sessionManage.currentSession.targetId === data.wechatChatroomId) {
|
|
805
|
+
this.contacts.loadRoomMemberData(data.wechatChatroomId, { // 强制刷新群成员数据
|
|
806
|
+
wechatChatroomId: data.wechatChatroomId
|
|
807
|
+
}, true)
|
|
808
|
+
}
|
|
809
|
+
},
|
|
810
|
+
// 群聊有变化,如分配的情况
|
|
811
|
+
onCmdChatroomInfoChangedBatch: ({ data }) => {
|
|
812
|
+
// 增量拉取通讯录
|
|
813
|
+
// this.contacts.refresh().then(() => {
|
|
814
|
+
// // 增量拉取会话
|
|
815
|
+
// this.session.refresh()
|
|
816
|
+
// })
|
|
817
|
+
},
|
|
818
|
+
// 好友有变化,如分配的情况
|
|
819
|
+
onCmdFriendInfoChanged: ({ data }) => {
|
|
820
|
+
if (!this.socketFriendInfoChangedSerialQueue) {
|
|
821
|
+
this.socketFriendInfoChangedSerialQueue = createSerialQueue()
|
|
822
|
+
}
|
|
823
|
+
this.socketFriendInfoChangedSerialQueue.add(() => {
|
|
824
|
+
// 配分好友
|
|
825
|
+
if (data.changeType === 4) {
|
|
826
|
+
if (this.onOverwriteFriendInfoChange) {
|
|
827
|
+
return this.onOverwriteFriendInfoChange({
|
|
828
|
+
data,
|
|
829
|
+
reverseLastUpdateTime: this.session.reverseLastUpdateTime,
|
|
830
|
+
accountIds: (this.account.accountData || []).map(v => v.id)
|
|
831
|
+
})
|
|
832
|
+
} else {
|
|
833
|
+
// 增量拉取分配产生的会话
|
|
834
|
+
return this.session.loadAssignTaskSessionData({
|
|
835
|
+
taskId: data.taskId
|
|
836
|
+
}).then((rs) => {
|
|
837
|
+
const wechatAccountIds = Object.keys((rs || []).reduce((rs, v) => {
|
|
838
|
+
rs[v.wechatAccountId] = true
|
|
839
|
+
return rs
|
|
840
|
+
}, {}))
|
|
841
|
+
if (!wechatAccountIds || !wechatAccountIds.length) {
|
|
842
|
+
return
|
|
843
|
+
}
|
|
844
|
+
// 统计任务返回的会话数据来按需刷新分组数量
|
|
845
|
+
// 更新当前微信号分组统计数量
|
|
846
|
+
return Promise.all([].concat(wechatAccountIds.reduce((rs, v) => {
|
|
847
|
+
rs.push(
|
|
848
|
+
this.contacts.refreshAllRoomGroupCount({
|
|
849
|
+
wechatAccountId: v
|
|
850
|
+
}, true)
|
|
851
|
+
)
|
|
852
|
+
rs.push(
|
|
853
|
+
this.contacts.refreshAllFriendGroupCount({
|
|
854
|
+
wechatAccountId: v
|
|
855
|
+
}, true)
|
|
856
|
+
)
|
|
857
|
+
return rs
|
|
858
|
+
}, [
|
|
859
|
+
// 刷新一下微信号
|
|
860
|
+
this.account.reloadData()
|
|
861
|
+
]))).then(() => {
|
|
862
|
+
this.contacts.markModify() // 标记通讯录修改
|
|
863
|
+
})
|
|
864
|
+
})
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
// 删除好友
|
|
868
|
+
else if (data.changeType === 3) {
|
|
869
|
+
// 删除会话
|
|
870
|
+
const session = this.session.findSession(({ session }) => {
|
|
871
|
+
return session.targetId === data.wechatFriendId
|
|
872
|
+
})
|
|
873
|
+
if (session) {
|
|
874
|
+
this.session.removeSession(session.conversationId)
|
|
875
|
+
}
|
|
876
|
+
// 删除好友
|
|
877
|
+
this.contacts.removeFriend(data.wechatFriendId)
|
|
878
|
+
// todo 刷新一下微信号,如果微信号一个好友都没了,应该要删除掉的
|
|
879
|
+
this.contacts.markModify() // 标记通讯录修改
|
|
880
|
+
}
|
|
881
|
+
// 更新好友
|
|
882
|
+
else if (data.changeType === 2) {
|
|
883
|
+
this.contacts.getFriend(data.wechatFriendId, true).then(rs => {
|
|
884
|
+
this.contacts.updateFriend(data.wechatFriendId, rs.data)
|
|
885
|
+
})
|
|
886
|
+
}
|
|
887
|
+
})
|
|
888
|
+
},
|
|
889
|
+
// 群聊有变化,如分配的情况
|
|
890
|
+
onCmdChatroomInfoChanged: ({ data }) => {
|
|
891
|
+
// 配分群聊
|
|
892
|
+
if (data.changeType === 4) {
|
|
893
|
+
// 增量拉取通讯录
|
|
894
|
+
// this.contacts.refresh().then(() => {
|
|
895
|
+
// // 增量拉取会话
|
|
896
|
+
// this.session.refresh()
|
|
897
|
+
// })
|
|
898
|
+
}
|
|
899
|
+
// 删除群聊
|
|
900
|
+
else if (data.changeType === 3) {
|
|
901
|
+
// 删除会话
|
|
902
|
+
const session = this.session.findSession(({ session }) => {
|
|
903
|
+
return session.targetId === data.wechatChatroomId
|
|
904
|
+
})
|
|
905
|
+
if (session) {
|
|
906
|
+
this.session.removeSession(session.conversationId)
|
|
907
|
+
}
|
|
908
|
+
// 删除好友
|
|
909
|
+
this.contacts.removeRoom(data.wechatChatroomId)
|
|
910
|
+
}
|
|
911
|
+
// 更新好友
|
|
912
|
+
else if (data.changeType === 2) {
|
|
913
|
+
this.contacts.getRoom({
|
|
914
|
+
wechatAccountId: data.wechatAccountId,
|
|
915
|
+
wechatChatroomId: data.wechatChatroomId
|
|
916
|
+
}).then(rs => {
|
|
917
|
+
this.contacts.updateRoom(data.wechatChatroomId, rs.data)
|
|
918
|
+
})
|
|
919
|
+
}
|
|
920
|
+
},
|
|
921
|
+
// 下载视频任务
|
|
922
|
+
onCmdDownloadVideoResult: ({ data }) => {
|
|
923
|
+
if (data.friendMessageId && data.friendMessageId !== '0') {
|
|
924
|
+
this.friendMessage.updateMessage(data.friendMessageId, {
|
|
925
|
+
content: data.url
|
|
926
|
+
})
|
|
927
|
+
} else if (data.chatroomMessageId && data.chatroomMessageId !== '0') {
|
|
928
|
+
this.roomMessage.updateMessage(data.chatroomMessageId, {
|
|
929
|
+
content: data.url
|
|
930
|
+
})
|
|
931
|
+
}
|
|
932
|
+
},
|
|
933
|
+
// 打招呼有变化
|
|
934
|
+
onCmdNewGreetingMsg: ({ data }) => {
|
|
935
|
+
// {
|
|
936
|
+
// "cmdType": "CmdNewGreetingMsg",
|
|
937
|
+
// "seq": 440013669,
|
|
938
|
+
// "traceId": "a54c7704960f1708ec332238c9fba7cc",
|
|
939
|
+
// "unreadGreetingMsgCount": 1,
|
|
940
|
+
// "wechatAccountId": "e8aade993e66748cbb845d127ea8e2e067465de7"
|
|
941
|
+
// }
|
|
942
|
+
this.account.setAccountGreetingUnreadMsgCount({
|
|
943
|
+
wechatAccountId: data.wechatAccountId,
|
|
944
|
+
unreadGreetingMsgCount: data.unreadGreetingMsgCount
|
|
945
|
+
})
|
|
946
|
+
},
|
|
947
|
+
onHeartbeatCheck: ({ mergeParams }) => {
|
|
948
|
+
const ids = this.account.getAccountData().map(v => v.id)
|
|
949
|
+
mergeParams({
|
|
950
|
+
wechatAccountIds: ids
|
|
951
|
+
})
|
|
952
|
+
},
|
|
953
|
+
onHeartbeatSuccess: ({ data }) => {
|
|
954
|
+
if (!data) {
|
|
955
|
+
return
|
|
956
|
+
}
|
|
957
|
+
const onlineMap = data || {}
|
|
958
|
+
Object.keys(onlineMap).forEach(k => {
|
|
959
|
+
this.account.updateAccount(k, {
|
|
960
|
+
wechatAlive: onlineMap[k]
|
|
961
|
+
})
|
|
962
|
+
})
|
|
963
|
+
},
|
|
964
|
+
onSendMessage: ({ data, onCallback }) => {
|
|
965
|
+
// onCallback((res) => {
|
|
966
|
+
// // 如果发送转发的消息时,也需要检查并创建会话,和newMessage逻辑类似,先只管成功的情况
|
|
967
|
+
// if (data && data.cmdType === 'CmdForwardMessage') {
|
|
968
|
+
// if (res && res.data && res.data.data) {
|
|
969
|
+
// if (res.data.data.wechatFriendId) {
|
|
970
|
+
// // 插入消息
|
|
971
|
+
// this.friendMessage.addMessage(res.data.data)
|
|
972
|
+
// } else {
|
|
973
|
+
// this.roomMessage.addMessage(res.data.data)
|
|
974
|
+
// }
|
|
975
|
+
// }
|
|
976
|
+
// }
|
|
977
|
+
// })
|
|
978
|
+
},
|
|
979
|
+
onReceiveMessage: ({ data }) => {
|
|
980
|
+
|
|
981
|
+
},
|
|
982
|
+
onSocketOpen: () => {
|
|
983
|
+
const ps = []
|
|
984
|
+
if (this.friendMessage.lastReceiveMessageTime) {
|
|
985
|
+
ps.push(this.friendMessage.loadLossMessageData())
|
|
986
|
+
}
|
|
987
|
+
if (this.roomMessage.lastReceiveMessageTime) {
|
|
988
|
+
ps.push(this.roomMessage.loadLossMessageData())
|
|
989
|
+
}
|
|
990
|
+
Promise.all(ps).finally(() => {
|
|
991
|
+
this.friendMessage.setLastReceiveMessageTime(Date.now())
|
|
992
|
+
this.roomMessage.setLastReceiveMessageTime(Date.now())
|
|
993
|
+
})
|
|
994
|
+
},
|
|
995
|
+
onSocketClose: (evt) => {
|
|
996
|
+
},
|
|
997
|
+
onSocketKickOut: () => {
|
|
998
|
+
// 关闭socket连接
|
|
999
|
+
// https://vs.rpa.cn/zentao/bug-view-2493.html
|
|
1000
|
+
this.socket.close({
|
|
1001
|
+
code: 1000,
|
|
1002
|
+
reason: 'kickOut时主动关闭socket'
|
|
1003
|
+
})
|
|
1004
|
+
// 一般可能同一个账号在其他设备登录,这种情况需要重新登录
|
|
1005
|
+
this.event.emit('kickout')
|
|
1006
|
+
}
|
|
1007
|
+
})
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
connect () {
|
|
1011
|
+
if (this.data.connectStatus === CONNECT_STATUS.Complete) {
|
|
1012
|
+
return Promise.resolve()
|
|
1013
|
+
}
|
|
1014
|
+
if (this.data.connectStatus === CONNECT_STATUS.Loading) {
|
|
1015
|
+
return this.connectPromise
|
|
1016
|
+
}
|
|
1017
|
+
this.data.connectStatus = CONNECT_STATUS.Loading
|
|
1018
|
+
this.connectPromise = Promise.all([
|
|
1019
|
+
this.socket.reconnect()
|
|
1020
|
+
]).then(() => {
|
|
1021
|
+
this.data.connectStatus = CONNECT_STATUS.Complete
|
|
1022
|
+
this.event.emit('ready')
|
|
1023
|
+
})
|
|
1024
|
+
return this.connectPromise
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
disconnect () {
|
|
1028
|
+
this.data.connectStatus = CONNECT_STATUS.Normal
|
|
1029
|
+
this.contacts.reset()
|
|
1030
|
+
this.account.reset()
|
|
1031
|
+
this.session.reset()
|
|
1032
|
+
this.friendMessage.reset()
|
|
1033
|
+
this.roomMessage.reset()
|
|
1034
|
+
this.friendMessageFilter.reset()
|
|
1035
|
+
this.roomMessageFilter.reset()
|
|
1036
|
+
this.friendMessageContext.reset()
|
|
1037
|
+
this.roomMessageContext.reset()
|
|
1038
|
+
this.socket.disconnect()
|
|
1039
|
+
this.socketFriendInfoChangedSerialQueue && this.socketFriendInfoChangedSerialQueue.clear()
|
|
1040
|
+
this.event.off('ready')
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
handleAutoReadMessageSession (sessionId) {
|
|
1044
|
+
if (!sessionId) {
|
|
1045
|
+
return
|
|
1046
|
+
}
|
|
1047
|
+
const sessionInstances = this.sessionManage.getSessionInstacesBySessionId(sessionId)
|
|
1048
|
+
const readPromise = Promise.resolve(this.session.updateSessionRead({
|
|
1049
|
+
conversationId: sessionId
|
|
1050
|
+
}))
|
|
1051
|
+
return readPromise.finally(() => {
|
|
1052
|
+
if (sessionInstances && sessionInstances.length) {
|
|
1053
|
+
sessionInstances[0].markSessionRead(sessionId)
|
|
1054
|
+
sessionInstances.forEach(sessionInstance => {
|
|
1055
|
+
sessionInstance.removeSession(sessionId)
|
|
1056
|
+
})
|
|
1057
|
+
}
|
|
1058
|
+
if (this.sessionManage.currentSession && this.sessionManage.currentSession.conversationId === sessionId) {
|
|
1059
|
+
this.sessionManage.setCurrentSession(null)
|
|
1060
|
+
}
|
|
1061
|
+
})
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
export default ClientChat
|