@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.
Files changed (366) hide show
  1. package/README.md +93 -0
  2. package/common/avatar/avatar.vue +86 -0
  3. package/common/avatar/index.js +3 -0
  4. package/common/badge/badge.vue +105 -0
  5. package/common/badge/index.js +3 -0
  6. package/common/context-menu/context-menu-box.vue +61 -0
  7. package/common/context-menu/context-menu-group.vue +162 -0
  8. package/common/context-menu/context-menu-item.vue +179 -0
  9. package/common/context-menu/context-menu.vue +201 -0
  10. package/common/context-menu/index.js +3 -0
  11. package/common/context-menu/utils.js +138 -0
  12. package/common/friend-avatar/default.svg +1 -0
  13. package/common/friend-avatar/friend-avatar.vue +29 -0
  14. package/common/friend-avatar/index.js +3 -0
  15. package/common/image/index.js +3 -0
  16. package/common/index.js +17 -0
  17. package/common/room-avatar/default.svg +6 -0
  18. package/common/room-avatar/index.js +3 -0
  19. package/common/room-avatar/room-avatar.vue +29 -0
  20. package/common/scroll-load-more/index.js +3 -0
  21. package/common/scroll-load-more/scroll-load-more.vue +195 -0
  22. package/common/user-avatar/default.svg +1 -0
  23. package/common/user-avatar/index.js +3 -0
  24. package/common/user-avatar/user-avatar.vue +29 -0
  25. package/components/account-select/account-select-skeleton.vue +56 -0
  26. package/components/account-select/account-select.vue +205 -0
  27. package/components/account-select/all.svg +1 -0
  28. package/components/account-select/index.js +3 -0
  29. package/components/chat-editor/MENTION_TOKEN_SUMMARY.md +74 -0
  30. package/components/chat-editor/chat-editor-button/chat-editor-button.vue +78 -0
  31. package/components/chat-editor/chat-editor-suggestions/chat-editor-suggestions.vue +329 -0
  32. package/components/chat-editor/chat-editor-toolbar/chat-editor-toolbar-item.vue +28 -0
  33. package/components/chat-editor/chat-editor-toolbar/chat-editor-toolbar.vue +17 -0
  34. package/components/chat-editor/chat-editor.vue +933 -0
  35. package/components/chat-editor/index.js +12 -0
  36. package/components/chat-editor/utils.js +189 -0
  37. package/components/chat-friend-profile/chat-friend-profile.vue +118 -0
  38. package/components/chat-friend-profile/index.js +3 -0
  39. package/components/chat-layout/chat-layout.vue +71 -0
  40. package/components/chat-layout/index.js +3 -0
  41. package/components/chat-panel/chat-panel-box.vue +350 -0
  42. package/components/chat-panel/chat-panel-chat.vue +121 -0
  43. package/components/chat-panel/chat-panel-chats.vue +674 -0
  44. package/components/chat-panel/chat-panel-empty.vue +32 -0
  45. package/components/chat-panel/chat-panel-increment.vue +80 -0
  46. package/components/chat-panel/chat-panel-inner-msg.vue +25 -0
  47. package/components/chat-panel/chat-panel-loading.vue +29 -0
  48. package/components/chat-panel/chat-panel-nearest.vue +136 -0
  49. package/components/chat-panel/chat-panel.vue +292 -0
  50. package/components/chat-panel/index.js +3 -0
  51. package/components/chat-panel/util.js +83 -0
  52. package/components/chat-room-profile/chat-room-profile.vue +103 -0
  53. package/components/chat-room-profile/index.js +3 -0
  54. package/components/contacts-friend-select/contacts-friend-select-skeleton.vue +41 -0
  55. package/components/contacts-friend-select/contacts-friend-select.vue +204 -0
  56. package/components/contacts-friend-select/index.js +3 -0
  57. package/components/contacts-group-select/contacts-group-select-item.vue +98 -0
  58. package/components/contacts-group-select/contacts-group-select-skeleton.vue +81 -0
  59. package/components/contacts-group-select/contacts-group-select.vue +396 -0
  60. package/components/contacts-group-select/index.js +3 -0
  61. package/components/contacts-room-select/contacts-room-select-skeleton.vue +41 -0
  62. package/components/contacts-room-select/contacts-room-select.vue +208 -0
  63. package/components/contacts-room-select/index.js +3 -0
  64. package/components/index.js +43 -0
  65. package/components/layout/index.js +3 -0
  66. package/components/layout/layout.vue +70 -0
  67. package/components/session-select/index.js +11 -0
  68. package/components/session-select/session-select-item-skeleton.vue +59 -0
  69. package/components/session-select/session-select-item.vue +190 -0
  70. package/components/session-select/session-select.vue +386 -0
  71. package/components/wechat-chat-control/calling/calling.vue +227 -0
  72. package/components/wechat-chat-control/calling/phone-fill.svg +1 -0
  73. package/components/wechat-chat-control/calling/vidicon-fill.svg +1 -0
  74. package/components/wechat-chat-control/channel-live/channel-live.vue +198 -0
  75. package/components/wechat-chat-control/channel-live/quote-icon.svg +1 -0
  76. package/components/wechat-chat-control/channel-video/channel-video.vue +180 -0
  77. package/components/wechat-chat-control/channel-video/quote-icon.svg +1 -0
  78. package/components/wechat-chat-control/channel-video-card/channel-video-card.vue +139 -0
  79. package/components/wechat-chat-control/channel-video-card/quote-icon.svg +1 -0
  80. package/components/wechat-chat-control/company-card/company-card.vue +136 -0
  81. package/components/wechat-chat-control/company-card/quote-icon.svg +1 -0
  82. package/components/wechat-chat-control/custom-expression/custom-expression.vue +45 -0
  83. package/components/wechat-chat-control/empty/empty.vue +27 -0
  84. package/components/wechat-chat-control/file-url/file-url.vue +307 -0
  85. package/components/wechat-chat-control/file-url/icons/file-excel-line.svg +1 -0
  86. package/components/wechat-chat-control/file-url/icons/file-info-line.svg +1 -0
  87. package/components/wechat-chat-control/file-url/icons/file-music-line.svg +1 -0
  88. package/components/wechat-chat-control/file-url/icons/file-pdf-line.svg +1 -0
  89. package/components/wechat-chat-control/file-url/icons/file-ppt-line.svg +1 -0
  90. package/components/wechat-chat-control/file-url/icons/file-settings-line.svg +1 -0
  91. package/components/wechat-chat-control/file-url/icons/file-text-line.svg +1 -0
  92. package/components/wechat-chat-control/file-url/icons/file-unknow-line.svg +1 -0
  93. package/components/wechat-chat-control/file-url/icons/file-word-line.svg +1 -0
  94. package/components/wechat-chat-control/file-url/icons/file-zip-line.svg +1 -0
  95. package/components/wechat-chat-control/file-url/icons/index.js +24 -0
  96. package/components/wechat-chat-control/image/image.vue +344 -0
  97. package/components/wechat-chat-control/image/index.js +1 -0
  98. package/components/wechat-chat-control/image/util.js +29 -0
  99. package/components/wechat-chat-control/index.js +104 -0
  100. package/components/wechat-chat-control/jx-sys-text/jx-sys-text.vue +28 -0
  101. package/components/wechat-chat-control/location/location.vue +179 -0
  102. package/components/wechat-chat-control/location/offline-bg.png +0 -0
  103. package/components/wechat-chat-control/member-change/member-change.vue +37 -0
  104. package/components/wechat-chat-control/music/icons/163.png +0 -0
  105. package/components/wechat-chat-control/music/icons/163.svg +12 -0
  106. package/components/wechat-chat-control/music/icons/default.png +0 -0
  107. package/components/wechat-chat-control/music/icons/default.svg +1 -0
  108. package/components/wechat-chat-control/music/icons/kuwo.png +0 -0
  109. package/components/wechat-chat-control/music/icons/qq.png +0 -0
  110. package/components/wechat-chat-control/music/icons/qq.svg +1 -0
  111. package/components/wechat-chat-control/music/music.vue +156 -0
  112. package/components/wechat-chat-control/music/utils.js +30 -0
  113. package/components/wechat-chat-control/quote-message/quote-message.vue +257 -0
  114. package/components/wechat-chat-control/real-time-position/icon.svg +1 -0
  115. package/components/wechat-chat-control/real-time-position/real-time-position.vue +57 -0
  116. package/components/wechat-chat-control/red-envelopes/quote-icon.svg +1 -0
  117. package/components/wechat-chat-control/red-envelopes/red-envelope.svg +1 -0
  118. package/components/wechat-chat-control/red-envelopes/red-envelopes.vue +168 -0
  119. package/components/wechat-chat-control/revoke-me-message/revoke-me-message.vue +41 -0
  120. package/components/wechat-chat-control/revoke-other-message/revoke-other-message.vue +41 -0
  121. package/components/wechat-chat-control/revoke-you-message/revoke-you-message.vue +41 -0
  122. package/components/wechat-chat-control/room-calling/phone-fill.svg +1 -0
  123. package/components/wechat-chat-control/room-calling/room-calling.vue +52 -0
  124. package/components/wechat-chat-control/room-calling/vidicon-fill.svg +1 -0
  125. package/components/wechat-chat-control/share-card/quote-icon.svg +1 -0
  126. package/components/wechat-chat-control/share-card/share-card.vue +140 -0
  127. package/components/wechat-chat-control/system/system.vue +122 -0
  128. package/components/wechat-chat-control/system-batch-message/system-batch-message.vue +28 -0
  129. package/components/wechat-chat-control/system-money/system-money.vue +39 -0
  130. package/components/wechat-chat-control/text/icons/icon.svg +6 -0
  131. package/components/wechat-chat-control/text/text.vue +164 -0
  132. package/components/wechat-chat-control/text-with-at/text-with-at.vue +88 -0
  133. package/components/wechat-chat-control/transfer/collection.svg +1 -0
  134. package/components/wechat-chat-control/transfer/quote-icon.svg +1 -0
  135. package/components/wechat-chat-control/transfer/red-transfer.svg +1 -0
  136. package/components/wechat-chat-control/transfer/refund.svg +1 -0
  137. package/components/wechat-chat-control/transfer/transfer.svg +1 -0
  138. package/components/wechat-chat-control/transfer/transfer.vue +263 -0
  139. package/components/wechat-chat-control/unknow/unknow.vue +21 -0
  140. package/components/wechat-chat-control/url/icons/link.svg +1 -0
  141. package/components/wechat-chat-control/url/icons/video.svg +6 -0
  142. package/components/wechat-chat-control/url/miniprogram.svg +1 -0
  143. package/components/wechat-chat-control/url/url-file.vue +47 -0
  144. package/components/wechat-chat-control/url/url-link.vue +169 -0
  145. package/components/wechat-chat-control/url/url-merge.vue +164 -0
  146. package/components/wechat-chat-control/url/url-miniprogram.vue +259 -0
  147. package/components/wechat-chat-control/url/url.vue +116 -0
  148. package/components/wechat-chat-control/util.js +234 -0
  149. package/components/wechat-chat-control/video/icons/video.svg +1 -0
  150. package/components/wechat-chat-control/video/video.vue +304 -0
  151. package/components/wechat-chat-control/voice/icons/voice.svg +1 -0
  152. package/components/wechat-chat-control/voice/voice.vue +464 -0
  153. package/components/wechat-chat-control/wechat-chat-control-config-item.vue +24 -0
  154. package/components/wechat-chat-control/wechat-chat-control-config-msg.vue +21 -0
  155. package/components/wechat-chat-control/wechat-chat-control-config.vue +57 -0
  156. package/components/wechat-chat-panel/chat-panel-chat-status/chat-panel-chat-status.vue +69 -0
  157. package/components/wechat-chat-panel/chat-panel-item.vue +695 -0
  158. package/components/wechat-chat-panel/chat-panel.vue +257 -0
  159. package/components/wechat-chat-panel/index.js +3 -0
  160. package/components/wework-chat-control/calling/calling.vue +223 -0
  161. package/components/wework-chat-control/calling/phone-fill.svg +1 -0
  162. package/components/wework-chat-control/calling/vidicon-fill.svg +1 -0
  163. package/components/wework-chat-control/channel-live/channel-live.vue +198 -0
  164. package/components/wework-chat-control/channel-live/quote-icon.svg +1 -0
  165. package/components/wework-chat-control/channel-video/channel-video.vue +180 -0
  166. package/components/wework-chat-control/channel-video/quote-icon.svg +1 -0
  167. package/components/wework-chat-control/company-card/company-card.vue +136 -0
  168. package/components/wework-chat-control/company-card/quote-icon.svg +1 -0
  169. package/components/wework-chat-control/custom-expression/custom-expression.vue +34 -0
  170. package/components/wework-chat-control/empty/empty.vue +27 -0
  171. package/components/wework-chat-control/expression/expression.vue +53 -0
  172. package/components/wework-chat-control/file-url/file-url.vue +247 -0
  173. package/components/wework-chat-control/file-url/icons/file-excel-line.svg +1 -0
  174. package/components/wework-chat-control/file-url/icons/file-info-line.svg +1 -0
  175. package/components/wework-chat-control/file-url/icons/file-music-line.svg +1 -0
  176. package/components/wework-chat-control/file-url/icons/file-pdf-line.svg +1 -0
  177. package/components/wework-chat-control/file-url/icons/file-ppt-line.svg +1 -0
  178. package/components/wework-chat-control/file-url/icons/file-settings-line.svg +1 -0
  179. package/components/wework-chat-control/file-url/icons/file-text-line.svg +1 -0
  180. package/components/wework-chat-control/file-url/icons/file-unknow-line.svg +1 -0
  181. package/components/wework-chat-control/file-url/icons/file-word-line.svg +1 -0
  182. package/components/wework-chat-control/file-url/icons/file-zip-line.svg +1 -0
  183. package/components/wework-chat-control/file-url/icons/index.js +24 -0
  184. package/components/wework-chat-control/image/image.vue +296 -0
  185. package/components/wework-chat-control/image/index.js +1 -0
  186. package/components/wework-chat-control/image/util.js +21 -0
  187. package/components/wework-chat-control/index.js +105 -0
  188. package/components/wework-chat-control/jx-sys-text/jx-sys-text.vue +28 -0
  189. package/components/wework-chat-control/link/link.vue +100 -0
  190. package/components/wework-chat-control/location/location.vue +181 -0
  191. package/components/wework-chat-control/location/offline-bg.png +0 -0
  192. package/components/wework-chat-control/red-envelopes/quote-icon.svg +1 -0
  193. package/components/wework-chat-control/red-envelopes/red-envelope.svg +1 -0
  194. package/components/wework-chat-control/red-envelopes/red-envelopes.vue +168 -0
  195. package/components/wework-chat-control/share-card/quote-icon.svg +1 -0
  196. package/components/wework-chat-control/share-card/share-card.vue +140 -0
  197. package/components/wework-chat-control/text/icons/icon.svg +6 -0
  198. package/components/wework-chat-control/text/text.vue +157 -0
  199. package/components/wework-chat-control/unknow/unknow.vue +21 -0
  200. package/components/wework-chat-control/url/icons/link.svg +1 -0
  201. package/components/wework-chat-control/url/icons/video.svg +6 -0
  202. package/components/wework-chat-control/url/miniprogram.svg +1 -0
  203. package/components/wework-chat-control/url/url-file.vue +37 -0
  204. package/components/wework-chat-control/url/url-link.vue +169 -0
  205. package/components/wework-chat-control/url/url-merge.vue +164 -0
  206. package/components/wework-chat-control/url/url-miniprogram.vue +248 -0
  207. package/components/wework-chat-control/url/url.vue +103 -0
  208. package/components/wework-chat-control/util.js +223 -0
  209. package/components/wework-chat-control/video/icons/video.svg +1 -0
  210. package/components/wework-chat-control/video/video.vue +304 -0
  211. package/components/wework-chat-control/voice/icons/voice.svg +1 -0
  212. package/components/wework-chat-control/voice/voice.vue +464 -0
  213. package/components/wework-chat-panel/chat-panel-controls/company-card/company-card.vue +35 -0
  214. package/components/wework-chat-panel/chat-panel-controls/expression/expression.vue +36 -0
  215. package/components/wework-chat-panel/chat-panel-controls/file-url/file-url.vue +35 -0
  216. package/components/wework-chat-panel/chat-panel-controls/image/image.vue +36 -0
  217. package/components/wework-chat-panel/chat-panel-controls/index.js +35 -0
  218. package/components/wework-chat-panel/chat-panel-controls/jx-sys-text/jx-sys-text.vue +28 -0
  219. package/components/wework-chat-panel/chat-panel-controls/link/link.vue +35 -0
  220. package/components/wework-chat-panel/chat-panel-controls/location/location.vue +35 -0
  221. package/components/wework-chat-panel/chat-panel-controls/text/text.vue +43 -0
  222. package/components/wework-chat-panel/chat-panel-controls/unkonw/unkonw.vue +39 -0
  223. package/components/wework-chat-panel/chat-panel-controls/video/video.vue +37 -0
  224. package/components/wework-chat-panel/chat-panel-controls/voice/voice.vue +35 -0
  225. package/components/wework-chat-panel/chat-panel-item.vue +650 -0
  226. package/components/wework-chat-panel/chat-panel.vue +163 -0
  227. package/components/wework-chat-panel/index.js +3 -0
  228. package/package.json +23 -0
  229. package/services/client-chat/client-chat-wechat/client-chat-account.js +426 -0
  230. package/services/client-chat/client-chat-wechat/client-chat-concats.js +1029 -0
  231. package/services/client-chat/client-chat-wechat/client-chat-draft.js +92 -0
  232. package/services/client-chat/client-chat-wechat/client-chat-message.js +588 -0
  233. package/services/client-chat/client-chat-wechat/client-chat-session-manage.js +67 -0
  234. package/services/client-chat/client-chat-wechat/client-chat-session.js +1048 -0
  235. package/services/client-chat/client-chat-wechat/client-chat-socket.js +215 -0
  236. package/services/client-chat/client-chat-wechat/client-chat.js +1065 -0
  237. package/services/client-chat/client-chat-wechat/index.js +3 -0
  238. package/services/client-chat/client-chat-wechat/utils.js +82 -0
  239. package/services/client-chat/client-chat-wework/client-chat-account.js +310 -0
  240. package/services/client-chat/client-chat-wework/client-chat-concats.js +772 -0
  241. package/services/client-chat/client-chat-wework/client-chat-message.js +278 -0
  242. package/services/client-chat/client-chat-wework/client-chat-session.js +929 -0
  243. package/services/client-chat/client-chat-wework/client-chat-socket.js +64 -0
  244. package/services/client-chat/client-chat-wework/client-chat.js +330 -0
  245. package/services/client-chat/client-chat-wework/index.js +3 -0
  246. package/services/client-chat/client-chat-wework/utils.js +82 -0
  247. package/services/index.js +10 -0
  248. package/services/socket/index.js +5 -0
  249. package/services/socket/socket.js +797 -0
  250. package/services/socket/utils.js +7 -0
  251. package/uni-common/account-portray/account-portray.vue +51 -0
  252. package/uni-common/account-select/account-select-item.vue +172 -0
  253. package/uni-common/account-select/account-select.vue +252 -0
  254. package/uni-common/all-friend-avatar/all-friend-avatar.vue +49 -0
  255. package/uni-common/friend-avatar/default.svg +1 -0
  256. package/uni-common/friend-avatar/friend-avatar.vue +27 -0
  257. package/uni-common/friend-avatar/index.js +3 -0
  258. package/uni-common/friend-loader/friend-loader.vue +53 -0
  259. package/uni-common/friend-portray/friend-portray.vue +56 -0
  260. package/uni-common/group-avatar/default.svg +1 -0
  261. package/uni-common/group-avatar/group-avatar.vue +18 -0
  262. package/uni-common/group-avatar/index.js +3 -0
  263. package/uni-common/room-avatar/default.svg +6 -0
  264. package/uni-common/room-avatar/index.js +3 -0
  265. package/uni-common/room-avatar/room-avatar.vue +27 -0
  266. package/uni-common/room-loader/room-loader.vue +53 -0
  267. package/uni-common/room-portray/room-portray.vue +56 -0
  268. package/uni-components/chat-control/calling/calling.vue +91 -0
  269. package/uni-components/chat-control/calling/phone-fill.svg +1 -0
  270. package/uni-components/chat-control/calling/vidicon-fill.svg +1 -0
  271. package/uni-components/chat-control/channel-video/channel-video.vue +89 -0
  272. package/uni-components/chat-control/channel-video-card/channel-video-card.vue +105 -0
  273. package/uni-components/chat-control/channel-video-live/channel-video-live.vue +92 -0
  274. package/uni-components/chat-control/chat-control-config-item/chat-control-config-item.vue +20 -0
  275. package/uni-components/chat-control/chat-control-config-item/index.js +3 -0
  276. package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-app.vue +25 -0
  277. package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-h5.vue +21 -0
  278. package/uni-components/chat-control/chat-control-config.vue +59 -0
  279. package/uni-components/chat-control/chat-control.vue +218 -0
  280. package/uni-components/chat-control/company-card/company-card.vue +123 -0
  281. package/uni-components/chat-control/const.js +28 -0
  282. package/uni-components/chat-control/expression/expression.vue +41 -0
  283. package/uni-components/chat-control/image/image.vue +68 -0
  284. package/uni-components/chat-control/index.js +89 -0
  285. package/uni-components/chat-control/location/location.vue +110 -0
  286. package/uni-components/chat-control/member-change/member-change.vue +32 -0
  287. package/uni-components/chat-control/quote-message/quote-message.vue +216 -0
  288. package/uni-components/chat-control/real-time-position/real-time-position.vue +62 -0
  289. package/uni-components/chat-control/redpacket/red-envelope.svg +1 -0
  290. package/uni-components/chat-control/redpacket/redpacket.vue +75 -0
  291. package/uni-components/chat-control/share-card/share-card.vue +101 -0
  292. package/uni-components/chat-control/system/system.vue +69 -0
  293. package/uni-components/chat-control/system-batch-message/system-batch-message.vue +30 -0
  294. package/uni-components/chat-control/system-text/system-text.vue +32 -0
  295. package/uni-components/chat-control/text/text.vue +67 -0
  296. package/uni-components/chat-control/text-with-at/text-with-at.vue +51 -0
  297. package/uni-components/chat-control/transfer/red-transfer.svg +1 -0
  298. package/uni-components/chat-control/transfer/transfer.vue +80 -0
  299. package/uni-components/chat-control/unkonw/unkonw.vue +37 -0
  300. package/uni-components/chat-control/url/icons/file-excel-line.svg +1 -0
  301. package/uni-components/chat-control/url/icons/file-info-line.svg +1 -0
  302. package/uni-components/chat-control/url/icons/file-music-line.svg +1 -0
  303. package/uni-components/chat-control/url/icons/file-pdf-line.svg +1 -0
  304. package/uni-components/chat-control/url/icons/file-ppt-line.svg +1 -0
  305. package/uni-components/chat-control/url/icons/file-settings-line.svg +1 -0
  306. package/uni-components/chat-control/url/icons/file-text-line.svg +1 -0
  307. package/uni-components/chat-control/url/icons/file-unknow-line.svg +1 -0
  308. package/uni-components/chat-control/url/icons/file-word-line.svg +1 -0
  309. package/uni-components/chat-control/url/icons/file-zip-line.svg +1 -0
  310. package/uni-components/chat-control/url/icons/index.js +24 -0
  311. package/uni-components/chat-control/url/miniprogram.svg +1 -0
  312. package/uni-components/chat-control/url/url-miniprogram.vue +116 -0
  313. package/uni-components/chat-control/url/url.vue +306 -0
  314. package/uni-components/chat-control/url-new/icons/file-excel-line.svg +1 -0
  315. package/uni-components/chat-control/url-new/icons/file-info-line.svg +1 -0
  316. package/uni-components/chat-control/url-new/icons/file-music-line.svg +1 -0
  317. package/uni-components/chat-control/url-new/icons/file-pdf-line.svg +1 -0
  318. package/uni-components/chat-control/url-new/icons/file-ppt-line.svg +1 -0
  319. package/uni-components/chat-control/url-new/icons/file-settings-line.svg +1 -0
  320. package/uni-components/chat-control/url-new/icons/file-text-line.svg +1 -0
  321. package/uni-components/chat-control/url-new/icons/file-unknow-line.svg +1 -0
  322. package/uni-components/chat-control/url-new/icons/file-word-line.svg +1 -0
  323. package/uni-components/chat-control/url-new/icons/file-zip-line.svg +1 -0
  324. package/uni-components/chat-control/url-new/icons/index.js +24 -0
  325. package/uni-components/chat-control/url-new/url-new.vue +110 -0
  326. package/uni-components/chat-control/utils.js +12 -0
  327. package/uni-components/chat-control/video/video.vue +156 -0
  328. package/uni-components/chat-control/voice/voice.vue +166 -0
  329. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-collect.vue +84 -0
  330. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-system.vue +28 -0
  331. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet.vue +85 -0
  332. package/uni-components/chat-editor/chat-editor-func/chat-editor-func.vue +157 -0
  333. package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at-panel.vue +158 -0
  334. package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at.vue +61 -0
  335. package/uni-components/chat-editor/chat-editor-func-button/chat-editor-func-button.vue +58 -0
  336. package/uni-components/chat-editor/chat-editor-func-file/chat-editor-func-file.vue +54 -0
  337. package/uni-components/chat-editor/chat-editor-func-image/chat-editor-func-image.vue +42 -0
  338. package/uni-components/chat-editor/chat-editor-func-video/chat-editor-func-video.vue +42 -0
  339. package/uni-components/chat-editor/chat-editor-func-voice/chat-editor-func-voice.vue +25 -0
  340. package/uni-components/chat-editor/chat-editor-message-send/chat-editor-message-send.vue +158 -0
  341. package/uni-components/chat-editor/chat-editor-quote/chat-editor-quote.vue +75 -0
  342. package/uni-components/chat-editor/chat-editor.vue +257 -0
  343. package/uni-components/chat-editor/index.js +10 -0
  344. package/uni-components/chat-editor/util.js +65 -0
  345. package/uni-components/chat-panel/chat-panel-chats-box.vue +238 -0
  346. package/uni-components/chat-panel/chat-panel-chats-forward/chat-panel-chats-forward.vue +273 -0
  347. package/uni-components/chat-panel/chat-panel-chats-item.vue +578 -0
  348. package/uni-components/chat-panel/chat-panel-chats-status/chat-panel-chats-status.vue +71 -0
  349. package/uni-components/chat-panel/chat-panel-chats.vue +368 -0
  350. package/uni-components/chat-panel/chat-panel.vue +227 -0
  351. package/uni-components/contacts-group-select/contacts-group-select-item.vue +85 -0
  352. package/uni-components/contacts-group-select/contacts-group-select-panel.vue +119 -0
  353. package/uni-components/contacts-group-select/contacts-group-select.vue +150 -0
  354. package/utils/color.js +178 -0
  355. package/utils/data.js +11 -0
  356. package/utils/date.js +107 -0
  357. package/utils/event.js +3 -0
  358. package/utils/file.js +26 -0
  359. package/utils/index.js +5 -0
  360. package/utils/json.js +40 -0
  361. package/utils/log.js +243 -0
  362. package/utils/queue.js +97 -0
  363. package/utils/regexp.js +9 -0
  364. package/utils/string.js +66 -0
  365. package/utils/url.js +48 -0
  366. package/utils/util.js +130 -0
@@ -0,0 +1,1048 @@
1
+ import Vue from 'vue'
2
+ import { isEmptyObject } from '../../../utils/util.js'
3
+ import { createSessionId } from './utils.js'
4
+ import { createPollRequest } from '../../../utils/util.js'
5
+
6
+ const ALL_WECHAT_ACCOUNT_ID = 'all'
7
+
8
+ const loopLoadAssignSessionData = (fetchFn, params) => {
9
+ let lastPs = null
10
+ let lastRs = null
11
+ let result = []
12
+ const loopFn = (params, total) => {
13
+ const { taskId, size, ...nextParams } = params
14
+ lastPs = fetchFn(Object.assign({}, nextParams, {
15
+ size,
16
+ taskId,
17
+ total
18
+ }))
19
+ lastRs = lastPs.then(rs => {
20
+ result = result.concat(rs.data || [])
21
+ if (rs.data.length < size) {
22
+ return result
23
+ } else {
24
+ return loopFn(params, result.length)
25
+ }
26
+ })
27
+ return lastRs
28
+ }
29
+ loopFn(params, result.length)
30
+ if (lastRs) {
31
+ lastRs.abort = () => {
32
+ lastPs && lastPs.abort && lastPs.abort()
33
+ }
34
+ }
35
+ return lastRs
36
+ }
37
+
38
+ export default class ClientChatSession {
39
+ data = Vue.observable({
40
+ // 加载会话数据中
41
+ loading: false,
42
+ // 加载分配任务会话中
43
+ loadAssignTaskSessioning: false,
44
+ /**
45
+ * 按照groupField分组的会话数据集合
46
+ */
47
+ sessionGroupData: {},
48
+ /**
49
+ * 按照groupField统计的未读会话总数
50
+ */
51
+ // sessionUnreadCountMap: {},
52
+ /**
53
+ * 按照groupField统计的免打扰会话
54
+ */
55
+ sessionMuteMap: {},
56
+ /**
57
+ * 新增会话时回调
58
+ * 如果会话的targetId对应的好友或者群不存在的时候隐藏起来
59
+ */
60
+ onBeforeAddSession: null,
61
+ /**
62
+ * 置顶会话
63
+ */
64
+ stickyTopSessionMethod: null,
65
+ /**
66
+ * 免打扰会话
67
+ */
68
+ muteNotificationSessionMethod: null,
69
+ /**
70
+ * 删除会话
71
+ */
72
+ deleteSessionMethod: null,
73
+ /**
74
+ * 虚拟会话数据
75
+ */
76
+ virtualSessionData: []
77
+ })
78
+
79
+ pollRequestMap = {}
80
+
81
+ accountIds = []
82
+
83
+ sessionMap = {}
84
+
85
+ // 根据lastMsgTime记录的最早的历史聊天会话,后面分页加载数据需要
86
+ /**
87
+ * {
88
+ * wechatAccountId: {
89
+ * lastMsgTime: null,
90
+ * lastUpdateTime: null
91
+ * }
92
+ * }
93
+ */
94
+ lastSessionInfo = {}
95
+
96
+ getSessionMethod = null
97
+
98
+ // 为了兼容老代码,当作所有微号的会话数据用
99
+ get sessionData () {
100
+ return this.sessionGroupData[ALL_WECHAT_ACCOUNT_ID]
101
+ }
102
+
103
+ get sessionGroupData () {
104
+ return this.data.sessionGroupData
105
+ }
106
+
107
+ // get sessionUnreadCountMap () {
108
+ // return this.data.sessionUnreadCountMap
109
+ // }
110
+
111
+ get sessionMuteMap () {
112
+ return this.data.sessionMuteMap
113
+ }
114
+
115
+ get loading () {
116
+ return this.data.loading
117
+ }
118
+
119
+ get loadAssignTaskSessioning () {
120
+ return this.data.loadAssignTaskSessioning
121
+ }
122
+
123
+ constructor (options) {
124
+ options = Object.assign({
125
+ name: null,
126
+ onBeforeAddSession: null,
127
+ onAddSession: null,
128
+ loadSessionDataMethod: null,
129
+ loadAssignTaskSessionDataMethod: null,
130
+ getNextUnreadSessionMethod: null,
131
+ stickyTopSessionMethod: null,
132
+ muteNotificationSessionMethod: null,
133
+ getSessionMethod: null,
134
+ updateSessionReadMethod: null,
135
+ starSessionMethod: null,
136
+ unstarSessionMethod: null,
137
+ onSessionReadChange: null,
138
+ onUpdateSession: null,
139
+ onRemoveSession: null,
140
+ onDeleteSession: null,
141
+ onClearVirtualSession: null,
142
+ onBeforeCreate: null
143
+ }, options)
144
+ // 实例化前时间,方便外面组合通用配置
145
+ if (options.onBeforeCreate) {
146
+ options.onBeforeCreate({
147
+ options,
148
+ instance: this
149
+ })
150
+ }
151
+ if (!options.loadSessionDataMethod) {
152
+ throw new Error('缺少loadSessionDataMethod配置')
153
+ }
154
+ if (!options.updateSessionReadMethod) {
155
+ throw new Error('缺少updateSessionReadMethod配置')
156
+ }
157
+ if (!options.getSessionMethod) {
158
+ throw new Error('缺少getSessionMethod配置')
159
+ }
160
+ if (!options.loadAssignTaskSessionDataMethod) {
161
+ throw new Error('缺少loadAssignTaskSessionDataMethod配置')
162
+ }
163
+ this.name = options.name
164
+ this.onBeforeAddSession = options.onBeforeAddSession
165
+ this.onAddSession = options.onAddSession
166
+ this.loadSessionData = options.loadSessionDataMethod
167
+ this.updateSessionRead = options.updateSessionReadMethod
168
+ this.getSessionMethod = options.getSessionMethod
169
+ this.loadAssignTaskSessionDataMethod = options.loadAssignTaskSessionDataMethod
170
+ this.stickyTopSessionMethod = options.stickyTopSessionMethod
171
+ this.muteNotificationSessionMethod = options.muteNotificationSessionMethod
172
+ this.starSessionMethod = options.starSessionMethod
173
+ this.unstarSessionMethod = options.unstarSessionMethod
174
+ this.deleteSessionMethod = options.deleteSessionMethod
175
+ this.onSessionReadChange = options.onSessionReadChange
176
+ this.onUpdateSession = options.onUpdateSession
177
+ this.onRemoveSession = options.onRemoveSession
178
+ this.onDeleteSession = options.onDeleteSession
179
+ this.onClearVirtualSession = options.onClearVirtualSession
180
+ }
181
+
182
+ generateSessionId (accountId, targetId) {
183
+ return createSessionId(accountId, targetId)
184
+ }
185
+
186
+ /**
187
+ * 设置会话数据
188
+ * @params { Object } data - 会话数据集合
189
+ * @params { String } wechatAccountId - 如果传wechatAccountId那么后面addSession的时候如果传wechatAccountId那么才会更新lastUpdateTime或者lastMsgTime,本质的意思是只有通过reload和loadData才刷新lastUpdateTime或者lastMsgTime,避免这个时间乱套了
190
+ */
191
+ setSessionData (data, wechatAccountId, reset = true) {
192
+ if (reset) {
193
+ this.sessionMap = {}
194
+ this.data.sessionGroupData = {}
195
+ // this.data.sessionUnreadCountMap = {}
196
+ this.data.sessionMuteMap = {}
197
+ }
198
+ if (data && data.length) {
199
+ data.forEach(item => {
200
+ if (item.isDeleted) {
201
+ this.removeSession(item.conversationId)
202
+ } else {
203
+ this.addSession(item, wechatAccountId)
204
+ }
205
+ })
206
+ }
207
+ }
208
+
209
+ refreshSession (sessionId) {
210
+ return this.getSessionMethod({
211
+ id: sessionId
212
+ }).then(rs => {
213
+ if (rs.data) {
214
+ const session = this.findSession(({ session }) => {
215
+ if (session.conversationId === sessionId) {
216
+ return true
217
+ }
218
+ })
219
+ if (session) {
220
+ this.updateSession(sessionId, rs.data)
221
+ } else {
222
+ this.addSession(rs.data)
223
+ }
224
+ return rs
225
+ } else {
226
+ return Promise.reject('未找到会话' + sessionId)
227
+ }
228
+ })
229
+ }
230
+
231
+ getSession (sessionId, serializeMethod) {
232
+ if (this.sessionMap[sessionId]) {
233
+ return Promise.resolve({
234
+ data: this.sessionMap[sessionId]
235
+ })
236
+ }
237
+ // 这里需要轮询从后端获取会话,后端会话更新和创建是异步的,所以要多轮训请求几次
238
+ if (this.pollRequestMap[sessionId]) {
239
+ this.pollRequestMap[sessionId].stop()
240
+ }
241
+ const pollRequest = createPollRequest(({ done, fail }) => {
242
+ return this.getSessionMethod({
243
+ id: sessionId
244
+ }).then((rs) => {
245
+ if (rs.data) {
246
+ done(rs)
247
+ }
248
+ })
249
+ })
250
+ this.pollRequestMap[sessionId] = pollRequest
251
+ return pollRequest.start().then(rs => {
252
+ if (serializeMethod) {
253
+ rs = serializeMethod(rs)
254
+ }
255
+ if (rs.data) {
256
+ this.addSession(rs.data)
257
+ return rs
258
+ } else {
259
+ return Promise.reject('未找到会话' + sessionId)
260
+ }
261
+ }).finally(() => {
262
+ if (this.pollRequestMap[sessionId] === pollRequest) {
263
+ delete this.pollRequestMap[sessionId]
264
+ }
265
+ })
266
+ }
267
+
268
+ findSession (findFn) {
269
+ let result
270
+ for (let i in this.sessionMap) {
271
+ if (findFn({
272
+ session: this.sessionMap[i]
273
+ })) {
274
+ result = this.sessionMap[i]
275
+ break
276
+ }
277
+ }
278
+ return result
279
+ }
280
+
281
+ getSortField (time) {
282
+ const step = 1000 * 60 * 60 * 24
283
+ const day = Math.floor(time / step)
284
+ const milliseconds = time - (day * step)
285
+ return {
286
+ day: Math.abs(day - 1000000), // 排序,由大到小
287
+ milliseconds: Math.abs(milliseconds - 86400000) // 排序,由大到小
288
+ }
289
+ }
290
+
291
+ _getSessionBySessionGroup (sessionId, wechatAccountId) {
292
+ if (!wechatAccountId) {
293
+ return
294
+ }
295
+ const session = this.sessionMap[sessionId]
296
+ if (!session) {
297
+ return
298
+ }
299
+ const topField = session.stickyOnTop ? 0 : 1 // 置顶
300
+ const sortFields = this.getSortField(session.lastMsgTime)
301
+ if (!this.data.sessionGroupData[wechatAccountId]) {
302
+ return
303
+ }
304
+ if (!this.data.sessionGroupData[wechatAccountId][topField]) {
305
+ return
306
+ }
307
+ if (!this.data.sessionGroupData[wechatAccountId][topField][sortFields.day]) {
308
+ return
309
+ }
310
+ if (!this.data.sessionGroupData[wechatAccountId][topField][sortFields.day][sortFields.milliseconds]) {
311
+ return
312
+ }
313
+ return this.data.sessionGroupData[wechatAccountId][topField][sortFields.day][sortFields.milliseconds].find(v => v.conversationId === sessionId)
314
+ }
315
+
316
+ _getLastSessionBySessionGroup (wechatAccountId) {
317
+ if (!wechatAccountId || !this._lastUpdateSessionMap || !this._lastUpdateSessionMap[wechatAccountId]) {
318
+ return
319
+ }
320
+ const sessionGroupData = this._lastUpdateSessionMap[wechatAccountId].lastMsgTime
321
+ if (!sessionGroupData) {
322
+ return
323
+ }
324
+ let result
325
+ Object.keys(sessionGroupData).reverse().some(topField => {
326
+ if (sessionGroupData[topField]) {
327
+ return Object.keys(sessionGroupData[topField]).reverse().some(dayKey => {
328
+ if (sessionGroupData[topField][dayKey]) {
329
+ return Object.keys(sessionGroupData[topField][dayKey]).reverse().some(milliseconds => {
330
+ if (sessionGroupData[topField][dayKey][milliseconds] && sessionGroupData[topField][dayKey][milliseconds].length) {
331
+ const sortItems = sessionGroupData[topField][dayKey][milliseconds].sort((a, b) => {
332
+ return a.lastMsgTime - b.lastMsgTime
333
+ })
334
+ result = sortItems[0]
335
+ return true
336
+ }
337
+ })
338
+ }
339
+ })
340
+ }
341
+ })
342
+ return result
343
+ }
344
+
345
+ /**
346
+ * 获取会话置顶数据
347
+ */
348
+ _getStickyOnTopSessionData (wechatAccountId) {
349
+ if (!wechatAccountId) {
350
+ return []
351
+ }
352
+ const sessionGroupData = this.data.sessionGroupData[wechatAccountId]
353
+ if (!sessionGroupData) {
354
+ return []
355
+ }
356
+ return Object.keys(sessionGroupData).reduce((rs, topKey) => {
357
+ if (topKey == 0 && sessionGroupData[topKey]) {
358
+ Object.keys(sessionGroupData[topKey]).forEach(dayKey => {
359
+ if (sessionGroupData[topKey][dayKey]) {
360
+ Object.keys(sessionGroupData[topKey][dayKey]).forEach(milliseconds => {
361
+ rs = rs.concat(sessionGroupData[topKey][dayKey][milliseconds] || [])
362
+ })
363
+ }
364
+ })
365
+ }
366
+ return rs
367
+ }, [])
368
+ }
369
+
370
+ /**
371
+ * 新增会话
372
+ * @params { Object } - data 会话数据
373
+ * @params { String } - wechatAccountId 如果传wechatAccountId那么后面addSession的时候如果传wechatAccountId那么才会更新lastUpdateTime或者lastMsgTime,本质的意思是只有通过reload和loadData才刷新lastUpdateTime或者lastMsgTime,避免这个时间乱套了
374
+ * 现在的逻辑是每个微号自己存自己的会话数据,只是会话是引用的,比如全部微信和指定微号会有相同的会话,这个会话数据是引用关系,方便后续更新和删除操作
375
+ * {
376
+ * "conversationId": "3d5398c24f1ae633047202fe17276571ef5e537e",
377
+ * "lastMsgContent": "wxid_ofo60wv6hxeg22:\n群收款消息",
378
+ * "lastMsgId": "8a3bf26d3abc52976c099f67a6d509864c87f632",
379
+ * "lastMsgTime": 1723456430000,
380
+ * "lastMsgType": 1,
381
+ * "lastUpdateTime": 1723456614979,
382
+ * "mute": false,
383
+ * "stickyOnTop": false,
384
+ * "targetId": "659bb02ebe1ffca423f5dede29b61145b705fbad",
385
+ * "type": 1, // 0 好友,1 群聊
386
+ * "unreadMsgCount": 3,
387
+ * "wechatAccountId": "2a39a725814acf07502299ab2285fff8d44377f5"
388
+ * }
389
+ */
390
+ addSession (data, wechatAccountId) {
391
+ if (!data || !data.conversationId) {
392
+ throw new Error('缺少必须参数conversationId')
393
+ }
394
+ if (!data.wechatAccountId) {
395
+ throw new Error('缺少必须参数wechatAccountId')
396
+ }
397
+ if (this.onBeforeAddSession && this.onBeforeAddSession({
398
+ data
399
+ }) === false) {
400
+ return
401
+ }
402
+ let nextData = data
403
+ // 如果会话已经存在,那么取已经存在的,以后有需要可以用data更新已经存在的会话,保持引用关系
404
+ if (this.sessionMap[data.conversationId]) {
405
+ nextData = this.sessionMap[data.conversationId]
406
+ } else {
407
+ this.sessionMap[data.conversationId] = nextData
408
+ }
409
+ const topField = nextData.stickyOnTop ? 0 : 1 // 置顶
410
+ if (wechatAccountId && wechatAccountId !== ALL_WECHAT_ACCOUNT_ID && nextData.wechatAccountId !== wechatAccountId) {
411
+ throw new Error('会话的wechatAccount和加载分组的wechatAccountId不一致')
412
+ }
413
+ const groupIds = []
414
+ // 传了wechatAccountId,是分页加载的,这里要保持分页加载数据的链路不受动态加载的影响
415
+ if (wechatAccountId) {
416
+ groupIds.push(wechatAccountId)
417
+ // 传了wechatAccountId才记录lastMsgTime和lastUpdateTime
418
+ const lastFields = ['lastMsgTime', 'lastUpdateTime']
419
+ groupIds.forEach(groupId => {
420
+ lastFields.forEach(lastField => {
421
+ const lastUpdateSortFields = this.getSortField(nextData[lastField])
422
+ if (!lastUpdateSortFields) {
423
+ return
424
+ }
425
+ if (!this._lastUpdateSessionMap) {
426
+ this._lastUpdateSessionMap = {}
427
+ }
428
+ if (!this._lastUpdateSessionMap[groupId]) {
429
+ this._lastUpdateSessionMap[groupId] = {}
430
+ }
431
+ if (!this._lastUpdateSessionMap[groupId][lastField]) {
432
+ this._lastUpdateSessionMap[groupId][lastField] = {}
433
+ }
434
+ if (!this._lastUpdateSessionMap[groupId][lastField][topField]) {
435
+ this._lastUpdateSessionMap[groupId][lastField][topField] = {}
436
+ }
437
+ if (!this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day]) {
438
+ this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day] = {}
439
+ }
440
+ if (!this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day][lastUpdateSortFields.milliseconds]) {
441
+ this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day][lastUpdateSortFields.milliseconds] = []
442
+ }
443
+ this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day][lastUpdateSortFields.milliseconds].push(nextData)
444
+ })
445
+ })
446
+ } else {
447
+ groupIds.push(nextData.wechatAccountId)
448
+ groupIds.push(ALL_WECHAT_ACCOUNT_ID)
449
+ }
450
+ // 分组的
451
+ const sortFields = this.getSortField(nextData.lastMsgTime)
452
+ groupIds.forEach(groupId => {
453
+ // 如果已经在分组里面了,就不新增了,
454
+ if (this._getSessionBySessionGroup(nextData.conversationId, groupId)) {
455
+ return
456
+ }
457
+ if (!this.data.sessionGroupData[groupId]) {
458
+ Vue.set(this.data.sessionGroupData, groupId, {})
459
+ }
460
+ if (!this.data.sessionGroupData[groupId][topField]) {
461
+ Vue.set(this.data.sessionGroupData[groupId], topField, {})
462
+ }
463
+ if (!this.data.sessionGroupData[groupId][topField][sortFields.day]) {
464
+ Vue.set(this.data.sessionGroupData[groupId][topField], sortFields.day, {})
465
+ }
466
+ if (!this.data.sessionGroupData[groupId][topField][sortFields.day][sortFields.milliseconds]) {
467
+ Vue.set(this.data.sessionGroupData[groupId][topField][sortFields.day], sortFields.milliseconds, [])
468
+ }
469
+ this.data.sessionGroupData[groupId][topField][sortFields.day][sortFields.milliseconds].push(nextData)
470
+ })
471
+ // if (typeof this.data.sessionUnreadCountMap[groupField] !== 'number') {
472
+ // Vue.set(this.data.sessionUnreadCountMap, groupField, 0)
473
+ // }
474
+ // if (data.unreadMsgCount) {
475
+ // this.data.sessionUnreadCountMap[groupField] += data.unreadMsgCount
476
+ // }
477
+ if (nextData.mute) {
478
+ if (!this.data.sessionMuteMap[nextData.wechatAccountId]) {
479
+ Vue.set(this.data.sessionMuteMap, nextData.wechatAccountId, {})
480
+ }
481
+ Vue.set(this.data.sessionMuteMap[nextData.wechatAccountId], nextData.conversationId, nextData)
482
+ }
483
+ // 检测一下是不是存在一样的虚拟会话,存在的话就删除
484
+ const virtualSessionIndex = this.data.virtualSessionData.findIndex(v => v.conversationId === nextData.conversationId)
485
+ if (virtualSessionIndex > -1) {
486
+ this.data.virtualSessionData.splice(virtualSessionIndex, 1)
487
+ }
488
+ this.onAddSession && this.onAddSession({
489
+ session: data
490
+ })
491
+ }
492
+
493
+ removeSession (conversationId) {
494
+ if (!this.sessionMap[conversationId]) {
495
+ return
496
+ }
497
+ const session = this.sessionMap[conversationId]
498
+ if (!session) {
499
+ return
500
+ }
501
+ const topField = session.stickyOnTop ? 0 : 1 // 置顶
502
+ const groupIds = [session.wechatAccountId, ALL_WECHAT_ACCOUNT_ID]
503
+ const sortFields = this.getSortField(session.lastMsgTime)
504
+ groupIds.forEach(groupId => {
505
+ if (!this.data.sessionGroupData[groupId] || !this.data.sessionGroupData[groupId][topField]) {
506
+ return
507
+ }
508
+ const groupSession = this.data.sessionGroupData[groupId][topField]
509
+ if (groupSession[sortFields.day] && groupSession[sortFields.day][sortFields.milliseconds]) {
510
+ const groupIndex = groupSession[sortFields.day][sortFields.milliseconds].indexOf(this.sessionMap[conversationId])
511
+ if (groupIndex >= 0) {
512
+ groupSession[sortFields.day][sortFields.milliseconds].splice(groupIndex, 1)
513
+ }
514
+ if (!groupSession[sortFields.day][sortFields.milliseconds].length) {
515
+ Vue.delete(groupSession[sortFields.day], sortFields.milliseconds)
516
+ }
517
+ if (isEmptyObject(groupSession[sortFields.day])) {
518
+ Vue.delete(groupSession, sortFields.day)
519
+ }
520
+ if (isEmptyObject(this.data.sessionGroupData[groupId][topField])) {
521
+ Vue.delete(this.data.sessionGroupData[groupId], topField)
522
+ }
523
+ if (isEmptyObject(this.data.sessionGroupData[groupId])) {
524
+ Vue.delete(this.data.sessionGroupData, groupId)
525
+ }
526
+ }
527
+ })
528
+ if (this.data.sessionMuteMap[session.wechatAccountId]) {
529
+ delete this.data.sessionMuteMap[session.wechatAccountId][conversationId]
530
+ }
531
+ const lastFields = ['lastMsgTime', 'lastUpdateTime']
532
+ groupIds.forEach(groupId => {
533
+ if (!this._lastUpdateSessionMap || !this._lastUpdateSessionMap[groupId]) {
534
+ return
535
+ }
536
+ lastFields.forEach(lastField => {
537
+ if (!this._lastUpdateSessionMap[groupId][lastField]) {
538
+ return
539
+ }
540
+ Object.keys(this._lastUpdateSessionMap[groupId][lastField]).forEach(topField => {
541
+ if (!this._lastUpdateSessionMap[groupId][lastField][topField]) {
542
+ return
543
+ }
544
+ const loastUpdateSortFields = this.getSortField(session.lastUpdateTime)
545
+ if (this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day] && this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day][loastUpdateSortFields.milliseconds]) {
546
+ const index = this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].indexOf(session)
547
+ if (index >= 0) {
548
+ this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].splice(index, 1)
549
+ }
550
+ if (!this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].length) {
551
+ Vue.delete(this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day], loastUpdateSortFields.milliseconds)
552
+ }
553
+ if (isEmptyObject(this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day])) {
554
+ Vue.delete(this._lastUpdateSessionMap[groupId][lastField][topField], loastUpdateSortFields.day)
555
+ }
556
+ }
557
+ })
558
+ })
559
+ })
560
+ delete this.sessionMap[conversationId]
561
+ this.onRemoveSession && this.onRemoveSession({
562
+ session
563
+ })
564
+ }
565
+
566
+ /**
567
+ * 设置会话未读消息数量
568
+ * @param sessionId - 会话id
569
+ * @param props | callback - 修改时数据或者回调,会把会话的未读数量作为上下文提供
570
+ */
571
+ updateSession (sessionId, callback) {
572
+ let session = this.sessionMap[sessionId]
573
+ if (!session) {
574
+ session = this.data.virtualSessionData.find(v => v.conversationId === sessionId)
575
+ }
576
+ if (!session) {
577
+ return
578
+ }
579
+ let nextProps = null
580
+ const changeProps = {}
581
+ if (typeof callback === 'function') {
582
+ nextProps = callback({
583
+ session
584
+ })
585
+ } else {
586
+ nextProps = callback
587
+ }
588
+ if (nextProps) {
589
+ // 分组的
590
+ const { unreadMsgCount, stickyOnTop, mute, lastMsgTime, ...nextUpdateProps } = nextProps
591
+ Object.keys(nextProps).forEach(k => {
592
+ if (session[k] !== nextProps[k]) {
593
+ changeProps[k] = {
594
+ before: session[k],
595
+ after: nextProps[k]
596
+ }
597
+ }
598
+ })
599
+ Object.keys(nextUpdateProps).forEach(k => {
600
+ Vue.set(session, k, nextUpdateProps[k])
601
+ })
602
+ // 处理会话时间
603
+ if (typeof lastMsgTime !== 'undefined' && session.lastMsgTime !== nextProps.lastMsgTime) {
604
+ const oldSortFields = this.getSortField(session.lastMsgTime)
605
+ // 把老的清空
606
+ // 重置一下数据
607
+ const groupIds = [ALL_WECHAT_ACCOUNT_ID, session.wechatAccountId]
608
+ groupIds.forEach(groupId => {
609
+ const topFields = [0, 1]
610
+ topFields.forEach(topField => {
611
+ if (
612
+ this.data.sessionGroupData[groupId] &&
613
+ this.data.sessionGroupData[groupId][topField] &&
614
+ this.data.sessionGroupData[groupId][topField][oldSortFields.day] &&
615
+ this.data.sessionGroupData[groupId][topField][oldSortFields.day][oldSortFields.milliseconds]
616
+ ) {
617
+ let index = -1
618
+ this.data.sessionGroupData[groupId][topField][oldSortFields.day][oldSortFields.milliseconds].some((v, i) => {
619
+ if (v.conversationId === session.conversationId) {
620
+ index = i
621
+ return true
622
+ }
623
+ })
624
+ this.data.sessionGroupData[groupId][topField][oldSortFields.day][oldSortFields.milliseconds].splice(index, 1)
625
+ }
626
+ })
627
+ })
628
+ // 按照新的时间来分组排序
629
+ Vue.set(session, 'lastMsgTime', lastMsgTime)
630
+ const topField = session.stickyOnTop ? 0 : 1 // 0置顶
631
+ const sortFields = this.getSortField(session.lastMsgTime)
632
+ groupIds.forEach(groupId => {
633
+ // 分组的
634
+ if (!this.data.sessionGroupData[groupId]) {
635
+ Vue.set(this.data.sessionGroupData, groupId, {})
636
+ }
637
+ if (!this.data.sessionGroupData[groupId][topField]) {
638
+ Vue.set(this.data.sessionGroupData[groupId], topField, {})
639
+ }
640
+ if (!this.data.sessionGroupData[groupId][topField][sortFields.day]) {
641
+ Vue.set(this.data.sessionGroupData[groupId][topField], sortFields.day, {})
642
+ }
643
+ if (!this.data.sessionGroupData[groupId][topField][sortFields.day][sortFields.milliseconds]) {
644
+ Vue.set(this.data.sessionGroupData[groupId][topField][sortFields.day], sortFields.milliseconds, [])
645
+ }
646
+ this.data.sessionGroupData[groupId][topField][sortFields.day][sortFields.milliseconds].push(session)
647
+ })
648
+ }
649
+ // 处理未读数量逻辑
650
+ if (typeof unreadMsgCount !== 'undefined' && session.unreadMsgCount !== nextProps.unreadMsgCount) {
651
+ // const origUnreadMsgCount = session.unreadMsgCount || 0
652
+ Vue.set(session, 'unreadMsgCount', unreadMsgCount)
653
+ // let nowUnreadMsgCount = session.unreadMsgCount || 0
654
+ // let diffUnreadMsgCount = nowUnreadMsgCount - origUnreadMsgCount
655
+ // if (diffUnreadMsgCount) {
656
+ // this.data.sessionUnreadCountMap[groupField] += diffUnreadMsgCount
657
+ // }
658
+ }
659
+ // 处理置顶会话逻辑
660
+ if (typeof stickyOnTop !== 'undefined' && session.stickyOnTop !== nextProps.stickyOnTop) {
661
+ Vue.set(session, 'stickyOnTop', stickyOnTop)
662
+ const topField = nextProps.stickyOnTop ? 0 : 1 // 0置顶
663
+ // 把已经存在的剔除,先删后插
664
+ // 所有的
665
+ const groupIds = [ALL_WECHAT_ACCOUNT_ID, session.wechatAccountId]
666
+ const sortFields = this.getSortField(session.lastMsgTime)
667
+ groupIds.forEach(groupId => {
668
+ // 重置一下数据
669
+ const topFields = [0, 1]
670
+ topFields.forEach(topField => {
671
+ if (
672
+ this.data.sessionGroupData[groupId] &&
673
+ this.data.sessionGroupData[groupId][topField] &&
674
+ this.data.sessionGroupData[groupId][topField][sortFields.day] &&
675
+ this.data.sessionGroupData[groupId][topField][sortFields.day][sortFields.milliseconds]
676
+ ) {
677
+ let index = -1
678
+ this.data.sessionGroupData[groupId][topField][sortFields.day][sortFields.milliseconds].some((v, i) => {
679
+ if (v.conversationId === session.conversationId) {
680
+ index = i
681
+ return true
682
+ }
683
+ })
684
+ this.data.sessionGroupData[groupId][topField][sortFields.day][sortFields.milliseconds].splice(index, 1)
685
+ }
686
+ })
687
+ })
688
+ groupIds.forEach(groupId => {
689
+ // 分组的
690
+ if (!this.data.sessionGroupData[groupId]) {
691
+ Vue.set(this.data.sessionGroupData, groupId, {})
692
+ }
693
+ if (!this.data.sessionGroupData[groupId][topField]) {
694
+ Vue.set(this.data.sessionGroupData[groupId], topField, {})
695
+ }
696
+ if (!this.data.sessionGroupData[groupId][topField][sortFields.day]) {
697
+ Vue.set(this.data.sessionGroupData[groupId][topField], sortFields.day, {})
698
+ }
699
+ if (!this.data.sessionGroupData[groupId][topField][sortFields.day][sortFields.milliseconds]) {
700
+ Vue.set(this.data.sessionGroupData[groupId][topField][sortFields.day], sortFields.milliseconds, [])
701
+ }
702
+ this.data.sessionGroupData[groupId][topField][sortFields.day][sortFields.milliseconds].push(session)
703
+ })
704
+ }
705
+ // 处理免打扰
706
+ if (typeof mute !== 'undefined' && session.mute !== nextProps.mute) {
707
+ Vue.set(session, 'mute', mute)
708
+ if (mute) {
709
+ if (!this.data.sessionMuteMap[session.wechatAccountId]) {
710
+ Vue.set(this.data.sessionMuteMap, session.wechatAccountId, {})
711
+ }
712
+ if (!this.data.sessionMuteMap[session.wechatAccountId][session.conversationId]) {
713
+ Vue.set(this.data.sessionMuteMap[session.wechatAccountId], session.conversationId, session)
714
+ }
715
+ } else {
716
+ if (this.data.sessionMuteMap[session.wechatAccountId]) {
717
+ Vue.delete(this.data.sessionMuteMap[session.wechatAccountId], session.conversationId)
718
+ }
719
+ }
720
+ }
721
+ }
722
+ if (changeProps && Object.keys(changeProps).length) {
723
+ this.onUpdateSession && this.onUpdateSession({
724
+ session,
725
+ changeProps,
726
+ updateProps: nextProps
727
+ })
728
+ }
729
+ }
730
+
731
+ /**
732
+ * 设置会话已读
733
+ */
734
+ setSessionRead (sessionId) {
735
+ let session = this.sessionMap[sessionId]
736
+ if (!session) {
737
+ session = this.data.virtualSessionData.find(v => v.conversationId === sessionId)
738
+ }
739
+ if (!session) {
740
+ return
741
+ }
742
+ return this.updateSessionRead({
743
+ conversationId: sessionId
744
+ }).then(() => {
745
+ this.markSessionRead(sessionId)
746
+ })
747
+ }
748
+
749
+ /**
750
+ * 标记会话已读,不经过服务器请求
751
+ */
752
+ markSessionRead (sessionId) {
753
+ let session = this.sessionMap[sessionId]
754
+ if (!session) {
755
+ session = this.data.virtualSessionData.find(v => v.conversationId === sessionId)
756
+ }
757
+ if (!session) {
758
+ return
759
+ }
760
+ const oldUnreadMsgCount = session.unreadMsgCount || 0
761
+ this.updateSession(sessionId, ({ session }) => {
762
+ return {
763
+ unreadMsgCount: 0
764
+ }
765
+ })
766
+ this.onSessionReadChange && this.onSessionReadChange({
767
+ session,
768
+ oldUnreadMsgCount
769
+ })
770
+ }
771
+
772
+ /**
773
+ * 设置账号下的会话已读
774
+ */
775
+ setAccountSessionRead (accountId) {
776
+ const sessions = this.sessionGroupData[accountId]
777
+ if (!sessions) {
778
+ return
779
+ }
780
+ // 置顶的
781
+ for (let i in sessions) {
782
+ // 大时间范围
783
+ for (let j in sessions[i]) {
784
+ // 小时间范围
785
+ for (let k in sessions[i][j]) {
786
+ if (sessions[i][j][k] && sessions[i][j][k].length) {
787
+ sessions[i][j][k].forEach(item => {
788
+ this.markSessionRead(item.conversationId)
789
+ })
790
+ }
791
+ }
792
+ }
793
+ }
794
+ }
795
+
796
+ /**
797
+ * 清空账号下的所有会话数据
798
+ */
799
+ clearAccountSession (wechatAccountId) {
800
+ const sessions = this.sessionGroupData[wechatAccountId]
801
+ if (!sessions) {
802
+ return
803
+ }
804
+ // 置顶的
805
+ for (let i in sessions) {
806
+ // 大时间范围
807
+ for (let j in sessions[i]) {
808
+ // 小时间范围
809
+ for (let k in sessions[i][j]) {
810
+ if (sessions[i][j][k] && sessions[i][j][k].length) {
811
+ sessions[i][j][k].forEach(item => {
812
+ this.removeSession(item.conversationId)
813
+ })
814
+ }
815
+ }
816
+ }
817
+ }
818
+ }
819
+
820
+ /**
821
+ * 加载分配好友/群任务产生的会话数据
822
+ */
823
+ loadAssignTaskSessionData (params) {
824
+ params = Object.assign({
825
+ taskId: null, // 分配的taskId
826
+ total: 0 , // 已获取总数
827
+ size: 50 // 每次获取数量
828
+ }, params)
829
+ this.data.loadAssignTaskSessioning = true
830
+ return loopLoadAssignSessionData((nextParams) => {
831
+ return this.loadAssignTaskSessionDataMethod(nextParams)
832
+ }, params).then(rs => {
833
+ if (rs && rs.length) {
834
+ this.setSessionData(rs, null, false)
835
+ }
836
+ return rs
837
+ }).finally(() => {
838
+ this.data.loadAssignTaskSessioning = false
839
+ })
840
+ }
841
+
842
+ /**
843
+ * 置顶会话
844
+ */
845
+ stickyTopSession (sessionId, isTop) {
846
+ if (!this.stickyTopSessionMethod) {
847
+ throw new Error('未配置stickyTopSessionMethod')
848
+ }
849
+ return this.stickyTopSessionMethod(Object.assign({
850
+ conversationId: sessionId,
851
+ enable: isTop
852
+ })).then(() => {
853
+ return this.updateSession(sessionId, {
854
+ stickyOnTop: isTop
855
+ })
856
+ })
857
+ }
858
+
859
+ /**
860
+ * 会话免打扰
861
+ */
862
+ muteNotificationSession (sessionId, isMute) {
863
+ if (!this.muteNotificationSessionMethod) {
864
+ throw new Error('未配置muteNotificationSessionMethod')
865
+ }
866
+ return this.muteNotificationSessionMethod(Object.assign({
867
+ conversationId: sessionId,
868
+ enable: isMute
869
+ })).then(() => {
870
+ return this.updateSession(sessionId, {
871
+ mute: isMute
872
+ })
873
+ })
874
+ }
875
+
876
+ /**
877
+ * 删除会话
878
+ */
879
+ deleteSession (sessionId) {
880
+ if (!this.deleteSessionMethod) {
881
+ throw new Error('未配置deleteSessionMethod')
882
+ }
883
+ const session = this.sessionMap[sessionId]
884
+ return this.deleteSessionMethod({
885
+ conversationId: sessionId
886
+ }).then(() => {
887
+ this.removeSession(sessionId)
888
+ this.onDeleteSession && this.onDeleteSession({
889
+ session
890
+ })
891
+ })
892
+ }
893
+
894
+ starSession (sessionId, sync) {
895
+ if (!this.starSessionMethod) {
896
+ throw new Error('starSessionMethod未定义')
897
+ }
898
+ if (sync !== false) {
899
+ return this.starSessionMethod(sessionId).then(() => {
900
+ this.updateSession(sessionId, {
901
+ starMark: true
902
+ })
903
+ })
904
+ } else {
905
+ this.updateSession(sessionId, {
906
+ starMark: true
907
+ })
908
+ }
909
+ }
910
+
911
+ unstarSession (sessionId, sync) {
912
+ if (!this.unstarSessionMethod) {
913
+ throw new Error('starSessionMethod未定义')
914
+ }
915
+ if (sync !== false) {
916
+ return this.unstarSessionMethod(sessionId).then(() => {
917
+ this.updateSession(sessionId, {
918
+ starMark: false
919
+ })
920
+ })
921
+ } else {
922
+ this.updateSession(sessionId, {
923
+ starMark: false
924
+ })
925
+ }
926
+ }
927
+
928
+ reload (params) {
929
+ params = Object.assign({
930
+ wechatAccountId: null, // 微账号id
931
+ size: 20 // 本次要获取的会话条数
932
+ }, params, {
933
+ lastUpdateTime: null // 最后更新时间
934
+ })
935
+ this.data.loading = true
936
+ const ps1 = this.loadSessionData(params, {
937
+ lastSession: null,
938
+ lastUpdateSession: null,
939
+ topSessionData: null
940
+ })
941
+ ps1.then((rs) => {
942
+ this.setSessionData(rs.data, params.wechatAccountId || ALL_WECHAT_ACCOUNT_ID)
943
+ })
944
+ if (this.cancelLoadDataRequest) {
945
+ this.cancelLoadDataRequest()
946
+ }
947
+ this.cancelLoadDataRequest = () => {
948
+ ps1 && ps1.abort && ps1.abort()
949
+ }
950
+ return Promise.all([ps1]).then((rs) => {
951
+ this.data.loading = false
952
+ return rs[0]
953
+ }, err => {
954
+ this.data.loading = false
955
+ return Promise.reject(err)
956
+ })
957
+ }
958
+
959
+ loadData (params) {
960
+ params = Object.assign({
961
+ wechatAccountId: null, // 微账号id
962
+ lastUpdateTime: null, // 最后更新时间
963
+ size: 20 // 本次要获取的会话条数
964
+ }, params)
965
+ this.data.loading = true
966
+ let lastSession = this._getLastSessionBySessionGroup(params.wechatAccountId || ALL_WECHAT_ACCOUNT_ID)
967
+ const ps1 = this.loadSessionData(params, {
968
+ lastSession,
969
+ topSessionData: this._getStickyOnTopSessionData(params.wechatAccountId || ALL_WECHAT_ACCOUNT_ID)
970
+ }).then(rs => {
971
+ // 这里地方还是需要用后端返回的数据设置,因为要将wechatAccountId记录到分组里面,addSession会做去重的
972
+ this.setSessionData(rs.data, params.wechatAccountId || ALL_WECHAT_ACCOUNT_ID, false)
973
+ return rs
974
+ })
975
+ if (this.cancelLoadDataRequest) {
976
+ this.cancelLoadDataRequest()
977
+ }
978
+ this.cancelLoadDataRequest = () => {
979
+ ps1 && ps1.abort && ps1.abort()
980
+ }
981
+ return Promise.all([ps1]).then((rs) => {
982
+ this.data.loading = false
983
+ return rs[0]
984
+ }, err => {
985
+ this.data.loading = false
986
+ return Promise.reject(err)
987
+ })
988
+ }
989
+
990
+ /**
991
+ * 新增虚拟会话
992
+ * 虚拟会话不会在会话列表展示,主要是给选中通讯录好友或群聊的时候产生一个统一的占位数据,后面加入来了新消息,那么会用新消息产生的会话替代这个虚拟会话
993
+ */
994
+ addVirtualSession (sessionData) {
995
+ if (!sessionData || typeof sessionData !== 'object') {
996
+ throw new Error('[ClientChatSession]虚拟会话必须是object')
997
+ }
998
+ if (!sessionData.conversationId) {
999
+ throw new Error('[ClientChatSession]虚拟会话缺少必须的conversationId属性')
1000
+ }
1001
+ if (this.data.virtualSessionData.some(v => v.conversationId === sessionData.conversationId)) {
1002
+ console.warn('[ClientChatSession]虚拟会话' + sessionData.conversationId + '已存在')
1003
+ return
1004
+ }
1005
+ this.data.virtualSessionData.push(sessionData)
1006
+ return sessionData
1007
+ }
1008
+
1009
+ /**
1010
+ * 获取虚拟会话
1011
+ */
1012
+ getVirtualSession (sessionId) {
1013
+ return this.data.virtualSessionData.find(v => v.conversationId === sessionId)
1014
+ }
1015
+
1016
+ /**
1017
+ * 清除虚拟会话
1018
+ */
1019
+ clearVirtualSession () {
1020
+ const virtualSessionData = this.data.virtualSessionData
1021
+ this.data.virtualSessionData = []
1022
+ this.onClearVirtualSession && this.onClearVirtualSession({
1023
+ virtualSessionData
1024
+ })
1025
+ }
1026
+
1027
+ reset () {
1028
+ this.data.sessionGroupData = {}
1029
+ this.data.sessionMuteMap = {}
1030
+ this.lastSessionInfo = {}
1031
+ // this.data.sessionUnreadCountMap = {}
1032
+ this.sessionMap = {}
1033
+ if (this.cancelLoadDataRequest) {
1034
+ this.cancelLoadDataRequest()
1035
+ this.cancelLoadDataRequest = null
1036
+ }
1037
+ if (this.cancelRefreshRequest) {
1038
+ this.cancelRefreshRequest()
1039
+ this.cancelRefreshRequest = null
1040
+ }
1041
+ if (this.pollRequestMap) {
1042
+ Object.keys(this.pollRequestMap).forEach(key => {
1043
+ this.pollRequestMap[key].stop()
1044
+ })
1045
+ this.pollRequestMap = {}
1046
+ }
1047
+ }
1048
+ }