@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,929 @@
1
+ import Vue from 'vue'
2
+ import { isEmptyObject } from '../../../utils/util.js'
3
+
4
+ const loopLoadAssignSessionData = (fetchFn, params) => {
5
+ let lastPs = null
6
+ let lastRs = null
7
+ let result = []
8
+ const loopFn = (params, total) => {
9
+ const { taskId, size, ...nextParams } = params
10
+ lastPs = fetchFn(Object.assign({}, nextParams, {
11
+ size,
12
+ taskId,
13
+ total
14
+ }))
15
+ lastRs = lastPs.then(rs => {
16
+ result = result.concat(rs.data || [])
17
+ if (rs.data.length < size) {
18
+ return result
19
+ } else {
20
+ return loopFn(params, result.length)
21
+ }
22
+ })
23
+ return lastRs
24
+ }
25
+ loopFn(params, result.length)
26
+ if (lastRs) {
27
+ lastRs.abort = () => {
28
+ lastPs && lastPs.abort && lastPs.abort()
29
+ }
30
+ }
31
+ return lastRs
32
+ }
33
+
34
+ export default class ClientChatSession {
35
+ data = Vue.observable({
36
+ // 加载会话数据中
37
+ loading: false,
38
+ // 加载分配任务会话中
39
+ loadAssignTaskSessioning: false,
40
+ /**
41
+ * {
42
+ * // 置顶状态
43
+ * topField: {
44
+ * sortField: {
45
+ * // 会话数据,可能存在多条,因为极端情况可能同一时间多条消息,按道理没有,先真么处理
46
+ * // 如果对象key是数字类型,那么默认就是按照正序排列的,这个key不能超过5位,否则排序会失效,利用浏览器的特性会块一些
47
+ * // 这里可以借助时间,但是时间要到天数上,类似前多少天,按照天在分组
48
+ * }
49
+ * }
50
+ * }
51
+ */
52
+ sessionData: {},
53
+ /**
54
+ * 按照groupField分组的会话数据集合
55
+ */
56
+ sessionGroupData: {},
57
+ /**
58
+ * 按照groupField统计的未读会话总数
59
+ */
60
+ // sessionUnreadCountMap: {},
61
+ /**
62
+ * 按照groupField统计的免打扰会话
63
+ */
64
+ sessionMuteMap: {},
65
+ /**
66
+ * 当前会话Id
67
+ */
68
+ currentSessionId: null,
69
+ /**
70
+ * 新增会话时回调
71
+ * 如果会话的targetId对应的好友或者群不存在的时候隐藏起来
72
+ */
73
+ onBeforeAddSession: null,
74
+ /**
75
+ * 置顶会话
76
+ */
77
+ stickyTopSessionMethod: null,
78
+ /**
79
+ * 免打扰会话
80
+ */
81
+ muteNotificationSessionMethod: null,
82
+ /**
83
+ * 删除会话
84
+ */
85
+ deleteSessionMethod: null
86
+ })
87
+
88
+ accountIds = []
89
+
90
+ sessionMap = {}
91
+
92
+ lastUpdateTime = null // 记录最近一次拉取会话时lastUpdateTime最小的值,用于后面refresh使用
93
+
94
+ lastSession = null // 根据lastMsgTime记录的最早的历史聊天会话,后面分页加载数据需要
95
+
96
+ getSessionMethod = null
97
+
98
+ get sessionData () {
99
+ return this.data.sessionData
100
+ }
101
+
102
+ get sessionGroupData () {
103
+ return this.data.sessionGroupData
104
+ }
105
+
106
+ // get sessionUnreadCountMap () {
107
+ // return this.data.sessionUnreadCountMap
108
+ // }
109
+
110
+ get sessionMuteMap () {
111
+ return this.data.sessionMuteMap
112
+ }
113
+
114
+ get currentSession () {
115
+ return this.sessionMap[this.data.currentSessionId]
116
+ }
117
+
118
+ get loading () {
119
+ return this.data.loading
120
+ }
121
+
122
+ get loadAssignTaskSessioning () {
123
+ return this.data.loadAssignTaskSessioning
124
+ }
125
+
126
+ constructor (options) {
127
+ options = Object.assign({
128
+ groupField: null,
129
+ sortField: null,
130
+ onBeforeAddSession: null,
131
+ loadSessionDataMethod: null,
132
+ loadAssignTaskSessionDataMethod: null,
133
+ stickyTopSessionMethod: null,
134
+ muteNotificationSessionMethod: null,
135
+ getSessionMethod: null,
136
+ updateSessionReadMethod: null,
137
+ onSessionReadChange: null
138
+ }, options)
139
+ if (!options.groupField) {
140
+ throw new Error('缺少分组字段配置')
141
+ }
142
+ if (!options.sortField) {
143
+ throw new Error('缺少排序字段配置')
144
+ }
145
+ if (!options.loadSessionDataMethod) {
146
+ throw new Error('缺少loadSessionDataMethod配置')
147
+ }
148
+ if (!options.updateSessionReadMethod) {
149
+ throw new Error('缺少updateSessionReadMethod配置')
150
+ }
151
+ if (!options.getSessionMethod) {
152
+ throw new Error('缺少getSessionMethod配置')
153
+ }
154
+ this.onBeforeAddSession = options.onBeforeAddSession
155
+ this.loadSessionData = options.loadSessionDataMethod
156
+ this.updateSessionRead = options.updateSessionReadMethod
157
+ this.getSessionMethod = options.getSessionMethod
158
+ this.loadAssignTaskSessionDataMethod = options.loadAssignTaskSessionDataMethod
159
+ this.stickyTopSessionMethod = options.stickyTopSessionMethod
160
+ this.muteNotificationSessionMethod = options.muteNotificationSessionMethod
161
+ this.deleteSessionMethod = options.deleteSessionMethod
162
+ this.onSessionReadChange = options.onSessionReadChange
163
+ this.groupField = options.groupField
164
+ this.sortField = options.sortField
165
+ }
166
+
167
+ setSessionData (data, reset = true) {
168
+ if (reset) {
169
+ this.sessionMap = {}
170
+ this.data.sessionData = {}
171
+ this.data.sessionGroupData = {}
172
+ // this.data.sessionUnreadCountMap = {}
173
+ this.data.sessionMuteMap = {}
174
+ }
175
+ if (data && data.length) {
176
+ data.forEach(item => {
177
+ if (item.isDeleted) {
178
+ this.removeSession(item.id, false)
179
+ } else {
180
+ this.addSession(item)
181
+ }
182
+ })
183
+ }
184
+ this.checkAndUpdateLastUpdateSession()
185
+ }
186
+
187
+ getSession (sessionId) {
188
+ if (this.sessionMap[sessionId]) {
189
+ return Promise.resolve({
190
+ data: this.sessionMap[sessionId]
191
+ })
192
+ }
193
+ return this.getSessionMethod({
194
+ id: sessionId
195
+ }).then(rs => {
196
+ if (rs.data) {
197
+ this.addSession(rs.data)
198
+ return rs
199
+ } else {
200
+ return Promise.reject('未找到会话' + sessionId)
201
+ }
202
+ })
203
+ }
204
+
205
+ getSessionByLocal (sessionId) {
206
+ return this.sessionMap[sessionId]
207
+ }
208
+
209
+ findSession (findFn) {
210
+ let result
211
+ for (let i in this.sessionMap) {
212
+ if (findFn({
213
+ session: this.sessionMap[i]
214
+ })) {
215
+ result = this.sessionMap[i]
216
+ break
217
+ }
218
+ }
219
+ return result
220
+ }
221
+
222
+ getSortField (time) {
223
+ const step = 1000 * 60 * 60 * 24
224
+ const day = Math.floor(time / step)
225
+ const milliseconds = time - (day * step)
226
+ return {
227
+ day: Math.abs(day - 1000000), // 排序,由大到小
228
+ milliseconds: Math.abs(milliseconds - 86400000) // 排序,由大到小
229
+ }
230
+ }
231
+
232
+ /**
233
+ * {
234
+ * "id": "3d5398c24f1ae633047202fe17276571ef5e537e",
235
+ * "lastMsgContent": "wxid_ofo60wv6hxeg22:\n群收款消息",
236
+ * "lastMsgId": "8a3bf26d3abc52976c099f67a6d509864c87f632",
237
+ * "lastMsgTime": 1723456430000,
238
+ * "lastMsgType": 1,
239
+ * "lastUpdateTime": 1723456614979,
240
+ * "mute": false,
241
+ * "stickyOnTop": false,
242
+ * "targetId": "659bb02ebe1ffca423f5dede29b61145b705fbad",
243
+ * "type": 1, // 0 好友,1 群聊
244
+ * "unreadMsgCount": 3,
245
+ * "wechatAccountId": "2a39a725814acf07502299ab2285fff8d44377f5"
246
+ * }
247
+ */
248
+ addSession (data) {
249
+ if (!data || !data.id) {
250
+ throw new Error('缺少必须参数id')
251
+ }
252
+ if (this.onBeforeAddSession && this.onBeforeAddSession({
253
+ data
254
+ }) === false) {
255
+ return
256
+ }
257
+ if (this.sessionMap[data.id]) {
258
+ return
259
+ }
260
+ const topField = data.stickyOnTop ? 0 : 1 // 置顶
261
+ if (!this.data.sessionData[topField]) {
262
+ Vue.set(this.data.sessionData, topField, {})
263
+ }
264
+ // 所有的
265
+ const sortFields = this.getSortField(data[this.sortField])
266
+ if (!this.data.sessionData[topField][sortFields.day]) {
267
+ Vue.set(this.data.sessionData[topField], sortFields.day, {})
268
+ }
269
+ if (!this.data.sessionData[topField][sortFields.day][sortFields.milliseconds]) {
270
+ Vue.set(this.data.sessionData[topField][sortFields.day], sortFields.milliseconds, [])
271
+ }
272
+ this.data.sessionData[topField][sortFields.day][sortFields.milliseconds].push(data)
273
+ // 记录lastUpdateSession的顺序,因为后续分页加载会话数据的时候,加载的参数需要获取目前会话数据中最久远的一条会话记录,作为下载加载会话的参考数据
274
+ const lastUpdateSortFields = this.getSortField(data.lastUpdateTime)
275
+ if (!this._lastUpdateSessionMap) {
276
+ this._lastUpdateSessionMap = {}
277
+ }
278
+ if (!this._lastUpdateSessionMap[lastUpdateSortFields.day]) {
279
+ this._lastUpdateSessionMap[lastUpdateSortFields.day] = {}
280
+ }
281
+ if (!this._lastUpdateSessionMap[lastUpdateSortFields.day][lastUpdateSortFields.milliseconds]) {
282
+ this._lastUpdateSessionMap[lastUpdateSortFields.day][lastUpdateSortFields.milliseconds] = []
283
+ }
284
+ this._lastUpdateSessionMap[lastUpdateSortFields.day][lastUpdateSortFields.milliseconds].push(data)
285
+ // 1.0需要记录lastUpdateSession的顺序,因为后续分页加载会话数据的时候,加载的参数需要获取目前会话数据中最久远的一条会话记录,作为下载加载会话的参考数据
286
+ const reverseLastUpdateSortFields = this.getSortField(data.lastUpdateTime)
287
+ if (!this._reverseLastUpdateSessionMap) {
288
+ this._reverseLastUpdateSessionMap = {}
289
+ }
290
+ if (!this._reverseLastUpdateSessionMap[reverseLastUpdateSortFields.day]) {
291
+ this._reverseLastUpdateSessionMap[reverseLastUpdateSortFields.day] = {}
292
+ }
293
+ if (!this._reverseLastUpdateSessionMap[reverseLastUpdateSortFields.day][reverseLastUpdateSortFields.milliseconds]) {
294
+ this._reverseLastUpdateSessionMap[reverseLastUpdateSortFields.day][reverseLastUpdateSortFields.milliseconds] = []
295
+ }
296
+ this._reverseLastUpdateSessionMap[reverseLastUpdateSortFields.day][reverseLastUpdateSortFields.milliseconds].push(data)
297
+ // 分组的
298
+ const groupField = data[this.groupField] || 'unkonw'
299
+ if (!this.data.sessionGroupData[groupField]) {
300
+ Vue.set(this.data.sessionGroupData, groupField, {})
301
+ }
302
+ if (!this.data.sessionGroupData[groupField][topField]) {
303
+ Vue.set(this.data.sessionGroupData[groupField], topField, {})
304
+ }
305
+ if (!this.data.sessionGroupData[groupField][topField][sortFields.day]) {
306
+ Vue.set(this.data.sessionGroupData[groupField][topField], sortFields.day, {})
307
+ }
308
+ if (!this.data.sessionGroupData[groupField][topField][sortFields.day][sortFields.milliseconds]) {
309
+ Vue.set(this.data.sessionGroupData[groupField][topField][sortFields.day], sortFields.milliseconds, [])
310
+ }
311
+ this.data.sessionGroupData[groupField][topField][sortFields.day][sortFields.milliseconds].push(data)
312
+ this.sessionMap[data.id] = data
313
+ // if (typeof this.data.sessionUnreadCountMap[groupField] !== 'number') {
314
+ // Vue.set(this.data.sessionUnreadCountMap, groupField, 0)
315
+ // }
316
+ // if (data.unreadMsgCount) {
317
+ // this.data.sessionUnreadCountMap[groupField] += data.unreadMsgCount
318
+ // }
319
+ if (data.mute) {
320
+ if (!this.data.sessionMuteMap[groupField]) {
321
+ Vue.set(this.data.sessionMuteMap, groupField, {})
322
+ }
323
+ Vue.set(this.data.sessionMuteMap[groupField], data.id, data)
324
+ }
325
+ // 记录一下最小的更新时间,后面可能会被删除,要等后端改接口参数
326
+ if (data.lastUpdateTime && (!this.lastUpdateTime || data.lastUpdateTime < this.lastUpdateTime)) {
327
+ this.lastUpdateTime = data.lastUpdateTime
328
+ this.lastUpdateSession = data
329
+ }
330
+ // 1.0需要最大的时间拉取会话,先兼容一下,后面后端改了就可以删除了,应该都用lastMsgTime的
331
+ if (data.lastUpdateTime && (!this.reverseLastUpdateTime || data.lastUpdateTime >= this.reverseLastUpdateTime)) {
332
+ this.reverseLastUpdateTime = data.lastUpdateTime
333
+ this.reverseLastUpdateSession = data
334
+ }
335
+ if (data.lastMsgTime && (!this.lastSession || data.lastMsgTime < this.lastSession.lastMsgTime)) {
336
+ this.lastSession = data
337
+ }
338
+ }
339
+
340
+ removeSession (id, checkLastUpdateSession) {
341
+ if (!this.sessionMap[id]) {
342
+ return
343
+ }
344
+ const session = this.sessionMap[id]
345
+ if (!session) {
346
+ return
347
+ }
348
+ const topField = session.stickyOnTop ? 0 : 1 // 置顶
349
+ const sortFields = this.getSortField(session[this.sortField])
350
+ if (this.data.sessionData[topField] && this.data.sessionData[topField][sortFields.day] && this.data.sessionData[topField][sortFields.day][sortFields.milliseconds]) {
351
+ const index = this.data.sessionData[topField][sortFields.day][sortFields.milliseconds].indexOf(this.sessionMap[id])
352
+ if (index >= 0) {
353
+ this.data.sessionData[topField][sortFields.day][sortFields.milliseconds].splice(index, 1)
354
+ }
355
+ if (!this.data.sessionData[topField][sortFields.day][sortFields.milliseconds].length) {
356
+ Vue.delete(this.data.sessionData[topField][sortFields.day], sortFields.milliseconds)
357
+ }
358
+ if (isEmptyObject(this.data.sessionData[topField][sortFields.day])) {
359
+ Vue.delete(this.data.sessionData[topField], sortFields.day)
360
+ }
361
+ if (isEmptyObject(this.data.sessionData[topField])) {
362
+ Vue.delete(this.data.sessionData, topField)
363
+ }
364
+ }
365
+ const groupField = session[this.groupField] || 'unkonw'
366
+ if (this.data.sessionGroupData[groupField] && this.data.sessionGroupData[groupField][topField]) {
367
+ const groupSession = this.data.sessionGroupData[groupField][topField]
368
+ if (groupSession[sortFields.day] && groupSession[sortFields.day][sortFields.milliseconds]) {
369
+ const groupIndex = groupSession[sortFields.day][sortFields.milliseconds].indexOf(this.sessionMap[id])
370
+ if (groupIndex >= 0) {
371
+ groupSession[sortFields.day][sortFields.milliseconds].splice(groupIndex, 1)
372
+ }
373
+ if (!groupSession[sortFields.day][sortFields.milliseconds].length) {
374
+ Vue.delete(groupSession[sortFields.day], sortFields.milliseconds)
375
+ }
376
+ if (isEmptyObject(groupSession[sortFields.day])) {
377
+ Vue.delete(groupSession, sortFields.day)
378
+ }
379
+ if (isEmptyObject(this.data.sessionGroupData[groupField][topField])) {
380
+ Vue.delete(this.data.sessionGroupData[groupField], topField)
381
+ }
382
+ if (isEmptyObject(this.data.sessionGroupData[groupField])) {
383
+ Vue.delete(this.data.sessionGroupData, groupField)
384
+ }
385
+ }
386
+ }
387
+ if (this.data.sessionMuteMap[groupField]) {
388
+ delete this.data.sessionMuteMap[groupField][id]
389
+ }
390
+ if (this._lastUpdateSessionMap) {
391
+ const loastUpdateSortFields = this.getSortField(session.lastUpdateTime)
392
+ if (this._lastUpdateSessionMap[loastUpdateSortFields.day] && this._lastUpdateSessionMap[loastUpdateSortFields.day][loastUpdateSortFields.milliseconds]) {
393
+ const index = this._lastUpdateSessionMap[loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].indexOf(session)
394
+ if (index >= 0) {
395
+ this._lastUpdateSessionMap[loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].splice(index, 1)
396
+ }
397
+ if (!this._lastUpdateSessionMap[loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].length) {
398
+ Vue.delete(this._lastUpdateSessionMap[loastUpdateSortFields.day], loastUpdateSortFields.milliseconds)
399
+ }
400
+ if (isEmptyObject(this._lastUpdateSessionMap[loastUpdateSortFields.day])) {
401
+ Vue.delete(this._lastUpdateSessionMap, loastUpdateSortFields.day)
402
+ }
403
+ }
404
+ }
405
+ if (this._reverseLastUpdateSessionMap) {
406
+ const loastUpdateSortFields = this.getSortField(session.lastUpdateTime)
407
+ if (this._reverseLastUpdateSessionMap[loastUpdateSortFields.day] && this._reverseLastUpdateSessionMap[loastUpdateSortFields.day][loastUpdateSortFields.milliseconds]) {
408
+ const index = this._reverseLastUpdateSessionMap[loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].indexOf(session)
409
+ if (index >= 0) {
410
+ this._reverseLastUpdateSessionMap[loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].splice(index, 1)
411
+ }
412
+ if (!this._reverseLastUpdateSessionMap[loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].length) {
413
+ Vue.delete(this._reverseLastUpdateSessionMap[loastUpdateSortFields.day], loastUpdateSortFields.milliseconds)
414
+ }
415
+ if (isEmptyObject(this._reverseLastUpdateSessionMap[loastUpdateSortFields.day])) {
416
+ Vue.delete(this._reverseLastUpdateSessionMap, loastUpdateSortFields.day)
417
+ }
418
+ }
419
+ }
420
+ delete this.sessionMap[id]
421
+ if (checkLastUpdateSession !== false) {
422
+ // todo 后面可能会删掉这块的逻辑,因为后端排序逻辑变了
423
+ this.checkAndUpdateLastUpdateSession()
424
+ }
425
+ if (checkLastUpdateSession !== false) {
426
+ this.checkAndUpdateLastSession()
427
+ }
428
+ if (checkLastUpdateSession !== false) {
429
+ this.checkAndUpdateReverseLastUpdateSession()
430
+ }
431
+ }
432
+
433
+ /**
434
+ * 删除会话的时候需要重新计算一下
435
+ */
436
+ checkAndUpdateLastUpdateSession () {
437
+ if (!this._lastUpdateSessionMap) {
438
+ return
439
+ }
440
+ // lastSession是最小的时间,就是更早的,因为加载更多是从现在的加载历史的
441
+ const dayKeys = Object.keys(this._lastUpdateSessionMap)
442
+ const millisecondsKeys = Object.keys(this._lastUpdateSessionMap[dayKeys[dayKeys.length - 1]])
443
+ const lastSessionSort = (this._lastUpdateSessionMap[dayKeys[dayKeys.length - 1]][millisecondsKeys[millisecondsKeys.length - 1]] || []).sort((a, b) => {
444
+ return a.lastUpdateTime - b.lastUpdateTime
445
+ })
446
+ if (!lastSessionSort || !lastSessionSort.length) {
447
+ return
448
+ }
449
+ this.lastUpdateSession = lastSessionSort[0]
450
+ this.lastUpdateTime = lastSessionSort[0].lastUpdateTime
451
+ }
452
+
453
+ /**
454
+ * 删除会话的时候需要重新计算一下
455
+ */
456
+ checkAndUpdateReverseLastUpdateSession () {
457
+ if (!this._reverseLastUpdateSessionMap) {
458
+ return
459
+ }
460
+ // lastSession是最小的时间,就是更早的,因为加载更多是从现在的加载历史的
461
+ const dayKeys = Object.keys(this._reverseLastUpdateSessionMap)
462
+ const millisecondsKeys = Object.keys(this._reverseLastUpdateSessionMap[dayKeys[dayKeys.length - 1]])
463
+ const lastSessionSort = (this._reverseLastUpdateSessionMap[dayKeys[dayKeys.length - 1]][millisecondsKeys[millisecondsKeys.length - 1]] || []).sort((a, b) => {
464
+ return b.lastUpdateTime - a.lastUpdateTime
465
+ })
466
+ if (!lastSessionSort || !lastSessionSort.length) {
467
+ return
468
+ }
469
+ this.reverseLastUpdateSession = lastSessionSort[0]
470
+ this.reverseLastUpdateTime = lastSessionSort[0].lastUpdateTime
471
+ }
472
+
473
+ checkAndUpdateLastSession () {
474
+ // lastSession是最小的时间,就是更早的,因为加载更多是从现在的加载历史的
475
+ let lastSession = null
476
+ let lastTopSession = null
477
+ let lastUnTopSession = null
478
+ // 置顶的
479
+ if (this.data.sessionData['0']) {
480
+ const lastDayKeys = Object.keys(this.data.sessionData['0'])
481
+ const lastDayKey = lastDayKeys[lastDayKeys.length - 1]
482
+ const lastMillisecondsKeys = Object.keys(this.data.sessionData['0'][lastDayKey])
483
+ const lastMillisecordsKey = lastMillisecondsKeys[lastMillisecondsKeys.length - 1]
484
+ const lastSessionSort = (this.data.sessionData['0'][lastDayKey][lastMillisecordsKey] || []).sort((a, b) => {
485
+ return a.lastMsgTime - b.lastMsgTime
486
+ })
487
+ lastTopSession = lastSessionSort[0]
488
+ }
489
+ if (this.data.sessionData['1']) {
490
+ const lastDayKeys = Object.keys(this.data.sessionData['1'])
491
+ const lastDayKey = lastDayKeys[lastDayKeys.length - 1]
492
+ const lastMillisecondsKeys = Object.keys(this.data.sessionData['1'][lastDayKey])
493
+ const lastMillisecordsKey = lastMillisecondsKeys[lastMillisecondsKeys.length - 1]
494
+ const lastSessionSort = (this.data.sessionData['1'][lastDayKey][lastMillisecordsKey] || []).sort((a, b) => {
495
+ return a.lastMsgTime - b.lastMsgTime
496
+ })
497
+ lastUnTopSession = lastSessionSort[0]
498
+ }
499
+ if (!lastTopSession) {
500
+ lastSession = lastUnTopSession
501
+ } else if (!lastUnTopSession) {
502
+ lastSession = lastTopSession
503
+ } else {
504
+ if (lastTopSession.lastMsgTime < lastUnTopSession.lastMsgTime) {
505
+ lastSession = lastTopSession
506
+ } else {
507
+ lastSession = lastUnTopSession
508
+ }
509
+ }
510
+ this.lastSession = lastSession
511
+ }
512
+
513
+ /**
514
+ * 设置会话未读消息数量
515
+ * @param sessionId - 会话id
516
+ * @param props | callback - 修改时数据或者回调,会把会话的未读数量作为上下文提供
517
+ */
518
+ updateSession (sessionId, callback) {
519
+ const session = this.sessionMap[sessionId]
520
+ if (!session) {
521
+ return
522
+ }
523
+ let nextProps = null
524
+ if (typeof callback === 'function') {
525
+ nextProps = callback({
526
+ session
527
+ })
528
+ } else {
529
+ nextProps = callback
530
+ }
531
+ if (nextProps) {
532
+ // 分组的
533
+ const groupField = session[this.groupField] || 'unkonw'
534
+ const { unreadMsgCount, stickyOnTop, mute, lastMsgTime, ...nextUpdateProps } = nextProps
535
+ Object.keys(nextUpdateProps).forEach(k => {
536
+ Vue.set(session, k, nextUpdateProps[k])
537
+ })
538
+ // 处理会话时间
539
+ if (typeof lastMsgTime !== 'undefined') {
540
+ const oldSortFields = this.getSortField(session.lastMsgTime)
541
+ // 把老的清空
542
+ // 重置一下数据
543
+ const topFields = [0, 1]
544
+ topFields.forEach(topField => {
545
+ if (this.data.sessionData[topField] && this.data.sessionData[topField][oldSortFields.day] && this.data.sessionData[topField][oldSortFields.day][oldSortFields.milliseconds]) {
546
+ let index = -1
547
+ this.data.sessionData[topField][oldSortFields.day][oldSortFields.milliseconds].some((v, i) => {
548
+ if (v === session) {
549
+ index = i
550
+ return true
551
+ }
552
+ })
553
+ if (index >= 0) {
554
+ this.data.sessionData[topField][oldSortFields.day][oldSortFields.milliseconds].splice(index, 1)
555
+ }
556
+ }
557
+ if (this.data.sessionGroupData[groupField] && this.data.sessionGroupData[groupField][topField] && this.data.sessionGroupData[groupField][topField][oldSortFields.day] && this.data.sessionGroupData[groupField][topField][oldSortFields.day][oldSortFields.milliseconds]) {
558
+ let index = -1
559
+ this.data.sessionGroupData[groupField][topField][oldSortFields.day][oldSortFields.milliseconds].some((v, i) => {
560
+ if (v === session) {
561
+ index = i
562
+ return true
563
+ }
564
+ })
565
+ this.data.sessionGroupData[groupField][topField][oldSortFields.day][oldSortFields.milliseconds].splice(index, 1)
566
+ }
567
+ })
568
+ // 按照新的时间来分组排序
569
+ Vue.set(session, 'lastMsgTime', lastMsgTime)
570
+ const topField = session.stickyOnTop ? 0 : 1 // 0置顶
571
+ const sortFields = this.getSortField(session.lastMsgTime)
572
+ // 所有的
573
+ if (!this.data.sessionData[topField]) {
574
+ Vue.set(this.data.sessionData, topField, {})
575
+ }
576
+ if (!this.data.sessionData[topField][sortFields.day]) {
577
+ Vue.set(this.data.sessionData[topField], sortFields.day, {})
578
+ }
579
+ if (!this.data.sessionData[topField][sortFields.day][sortFields.milliseconds]) {
580
+ Vue.set(this.data.sessionData[topField][sortFields.day], sortFields.milliseconds, [])
581
+ }
582
+ this.data.sessionData[topField][sortFields.day][sortFields.milliseconds].push(session)
583
+ // 分组的
584
+ if (!this.data.sessionGroupData[groupField]) {
585
+ Vue.set(this.data.sessionGroupData, groupField, {})
586
+ }
587
+ if (!this.data.sessionGroupData[groupField][topField]) {
588
+ Vue.set(this.data.sessionGroupData[groupField], topField, {})
589
+ }
590
+ if (!this.data.sessionGroupData[groupField][topField][sortFields.day]) {
591
+ Vue.set(this.data.sessionGroupData[groupField][topField], sortFields.day, {})
592
+ }
593
+ if (!this.data.sessionGroupData[groupField][topField][sortFields.day][sortFields.milliseconds]) {
594
+ Vue.set(this.data.sessionGroupData[groupField][topField][sortFields.day], sortFields.milliseconds, [])
595
+ }
596
+ this.data.sessionGroupData[groupField][topField][sortFields.day][sortFields.milliseconds].push(session)
597
+ }
598
+ // 处理未读数量逻辑
599
+ if (typeof unreadMsgCount !== 'undefined') {
600
+ const origUnreadMsgCount = session.unreadMsgCount || 0
601
+ Vue.set(session, 'unreadMsgCount', unreadMsgCount)
602
+ // let nowUnreadMsgCount = session.unreadMsgCount || 0
603
+ // let diffUnreadMsgCount = nowUnreadMsgCount - origUnreadMsgCount
604
+ // if (diffUnreadMsgCount) {
605
+ // this.data.sessionUnreadCountMap[groupField] += diffUnreadMsgCount
606
+ // }
607
+ }
608
+ // 处理置顶会话逻辑
609
+ if (typeof stickyOnTop !== 'undefined') {
610
+ Vue.set(session, 'stickyOnTop', stickyOnTop)
611
+ const topField = nextProps.stickyOnTop ? 0 : 1 // 0置顶
612
+ // 把已经存在的剔除,先删后插
613
+ // 所有的
614
+ const sortFields = this.getSortField(session[this.sortField])
615
+ // 重置一下数据
616
+ const topFields = [0, 1]
617
+ topFields.forEach(topField => {
618
+ if (this.data.sessionData[topField] && this.data.sessionData[topField][sortFields.day] && this.data.sessionData[topField][sortFields.day][sortFields.milliseconds]) {
619
+ let index = -1
620
+ this.data.sessionData[topField][sortFields.day][sortFields.milliseconds].some((v, i) => {
621
+ if (v === session) {
622
+ index = i
623
+ return true
624
+ }
625
+ })
626
+ if (index >= 0) {
627
+ this.data.sessionData[topField][sortFields.day][sortFields.milliseconds].splice(index, 1)
628
+ }
629
+ }
630
+ if (this.data.sessionGroupData[groupField] && this.data.sessionGroupData[groupField][topField] && this.data.sessionGroupData[groupField][topField][sortFields.day] && this.data.sessionGroupData[groupField][topField][sortFields.day][sortFields.milliseconds]) {
631
+ let index = -1
632
+ this.data.sessionGroupData[groupField][topField][sortFields.day][sortFields.milliseconds].some((v, i) => {
633
+ if (v === session) {
634
+ index = i
635
+ return true
636
+ }
637
+ })
638
+ this.data.sessionGroupData[groupField][topField][sortFields.day][sortFields.milliseconds].splice(index, 1)
639
+ }
640
+ })
641
+ // 所有的
642
+ if (!this.data.sessionData[topField]) {
643
+ Vue.set(this.data.sessionData, topField, {})
644
+ }
645
+ if (!this.data.sessionData[topField][sortFields.day]) {
646
+ Vue.set(this.data.sessionData[topField], sortFields.day, {})
647
+ }
648
+ if (!this.data.sessionData[topField][sortFields.day][sortFields.milliseconds]) {
649
+ Vue.set(this.data.sessionData[topField][sortFields.day], sortFields.milliseconds, [])
650
+ }
651
+ this.data.sessionData[topField][sortFields.day][sortFields.milliseconds].push(session)
652
+ // 分组的
653
+ if (!this.data.sessionGroupData[groupField]) {
654
+ Vue.set(this.data.sessionGroupData, groupField, {})
655
+ }
656
+ if (!this.data.sessionGroupData[groupField][topField]) {
657
+ Vue.set(this.data.sessionGroupData[groupField], topField, {})
658
+ }
659
+ if (!this.data.sessionGroupData[groupField][topField][sortFields.day]) {
660
+ Vue.set(this.data.sessionGroupData[groupField][topField], sortFields.day, {})
661
+ }
662
+ if (!this.data.sessionGroupData[groupField][topField][sortFields.day][sortFields.milliseconds]) {
663
+ Vue.set(this.data.sessionGroupData[groupField][topField][sortFields.day], sortFields.milliseconds, [])
664
+ }
665
+ this.data.sessionGroupData[groupField][topField][sortFields.day][sortFields.milliseconds].push(session)
666
+ }
667
+ // 处理免打扰
668
+ if (typeof mute !== 'undefined') {
669
+ Vue.set(session, 'mute', mute)
670
+ if (mute) {
671
+ if (!this.data.sessionMuteMap[groupField]) {
672
+ Vue.set(this.data.sessionMuteMap, groupField, {})
673
+ }
674
+ if (!this.data.sessionMuteMap[groupField][session.id]) {
675
+ Vue.set(this.data.sessionMuteMap[groupField], session.id, session)
676
+ }
677
+ } else {
678
+ if (this.data.sessionMuteMap[groupField]) {
679
+ Vue.delete(this.data.sessionMuteMap[groupField], session.id)
680
+ }
681
+ }
682
+ }
683
+ }
684
+ }
685
+
686
+ /**
687
+ * 设置会话已读
688
+ */
689
+ setSessionRead (sessionId) {
690
+ const session = this.sessionMap[sessionId]
691
+ if (!session) {
692
+ return
693
+ }
694
+ return this.updateSessionRead({
695
+ id: sessionId
696
+ }).then(() => {
697
+ this.markSessionRead(sessionId)
698
+ })
699
+ }
700
+
701
+ /**
702
+ * 标记会话已读,不经过服务器请求
703
+ */
704
+ markSessionRead (sessionId) {
705
+ const session = this.sessionMap[sessionId]
706
+ if (!session) {
707
+ return
708
+ }
709
+ const oldUnreadMsgCount = session.unreadMsgCount || 0
710
+ this.updateSession(sessionId, ({ session }) => {
711
+ return {
712
+ unreadMsgCount: 0
713
+ }
714
+ })
715
+ this.onSessionReadChange && this.onSessionReadChange({
716
+ session,
717
+ oldUnreadMsgCount
718
+ })
719
+ }
720
+
721
+ /**
722
+ * 设置账号下的会话已读
723
+ */
724
+ setAccountSessionRead (accountId) {
725
+ const sessions = this.sessionGroupData[accountId]
726
+ if (!sessions) {
727
+ return
728
+ }
729
+ // 置顶的
730
+ for (let i in sessions) {
731
+ // 大时间范围
732
+ for (let j in sessions[i]) {
733
+ // 小时间范围
734
+ for (let k in sessions[i][j]) {
735
+ if (sessions[i][j][k] && sessions[i][j][k].length) {
736
+ sessions[i][j][k].forEach(item => {
737
+ this.markSessionRead(item.id)
738
+ })
739
+ }
740
+ }
741
+ }
742
+ }
743
+ }
744
+
745
+ /**
746
+ * 清空账号下的所有会话数据
747
+ */
748
+ clearAccountSession (accountId) {
749
+ const sessions = this.sessionGroupData[accountId]
750
+ if (!sessions) {
751
+ return
752
+ }
753
+ // 置顶的
754
+ for (let i in sessions) {
755
+ // 大时间范围
756
+ for (let j in sessions[i]) {
757
+ // 小时间范围
758
+ for (let k in sessions[i][j]) {
759
+ if (sessions[i][j][k] && sessions[i][j][k].length) {
760
+ sessions[i][j][k].forEach(item => {
761
+ this.removeSession(item.id, false)
762
+ })
763
+ }
764
+ }
765
+ }
766
+ }
767
+ this.checkAndUpdateLastUpdateSession()
768
+ }
769
+
770
+ /**
771
+ * 加载分配好友/群任务产生的会话数据
772
+ */
773
+ loadAssignTaskSessionData (params) {
774
+ params = Object.assign({
775
+ taskId: null, // 分配的taskId
776
+ total: 0 , // 已获取总数
777
+ size: 50 // 每次获取数量
778
+ }, params)
779
+ this.data.loadAssignTaskSessioning = true
780
+ return loopLoadAssignSessionData((nextParams) => {
781
+ return this.loadAssignTaskSessionDataMethod(nextParams)
782
+ }, params).then(rs => {
783
+ if (rs && rs.length) {
784
+ this.setSessionData(rs, false)
785
+ }
786
+ return rs
787
+ }).finally(() => {
788
+ this.data.loadAssignTaskSessioning = false
789
+ })
790
+ }
791
+
792
+ /**
793
+ * 置顶会话
794
+ */
795
+ stickyTopSession (sessionId, isTop) {
796
+ if (!this.stickyTopSessionMethod) {
797
+ throw new Error('未配置stickyTopSessionMethod')
798
+ }
799
+ return this.stickyTopSessionMethod(Object.assign({
800
+ id: sessionId,
801
+ enable: isTop
802
+ })).then(() => {
803
+ return this.updateSession(sessionId, {
804
+ stickyOnTop: isTop
805
+ })
806
+ })
807
+ }
808
+
809
+ /**
810
+ * 会话免打扰
811
+ */
812
+ muteNotificationSession (sessionId, isMute) {
813
+ if (!this.muteNotificationSessionMethod) {
814
+ throw new Error('未配置muteNotificationSessionMethod')
815
+ }
816
+ return this.muteNotificationSessionMethod(Object.assign({
817
+ id: sessionId,
818
+ enable: isMute
819
+ })).then(() => {
820
+ return this.updateSession(sessionId, {
821
+ mute: isMute
822
+ })
823
+ })
824
+ }
825
+
826
+ /**
827
+ * 删除会话
828
+ */
829
+ deleteSession (sessionId) {
830
+ if (!this.deleteSessionMethod) {
831
+ throw new Error('未配置deleteSessionMethod')
832
+ }
833
+ return this.deleteSessionMethod({
834
+ id: sessionId
835
+ }).then(() => {
836
+ return this.removeSession(sessionId)
837
+ })
838
+ }
839
+
840
+ setCurrentSession (sessionId) {
841
+ if (sessionId && !this.sessionMap[sessionId]) {
842
+ return
843
+ }
844
+ this.data.currentSessionId = sessionId
845
+ }
846
+
847
+ reload (params) {
848
+ params = Object.assign({
849
+ wechatAccountId: null, // 微账号id
850
+ size: 20 // 本次要获取的会话条数
851
+ }, params, {
852
+ lastUpdateTime: null // 最后更新时间
853
+ })
854
+ this.data.loading = true
855
+ this.lastUpdateTime = null
856
+ this.lastUpdateSession = null
857
+ this.lastSession = null
858
+ const ps1 = this.loadSessionData(params, {
859
+ lastUpdateSession: this.lastUpdateSession
860
+ })
861
+ ps1.then((rs) => {
862
+ this.setSessionData(rs.data)
863
+ })
864
+ if (this.cancelLoadDataRequest) {
865
+ this.cancelLoadDataRequest()
866
+ }
867
+ this.cancelLoadDataRequest = () => {
868
+ ps1.abort && ps1.abort()
869
+ }
870
+ return Promise.all([ps1]).then((rs) => {
871
+ this.data.loading = false
872
+ return rs[0]
873
+ }, err => {
874
+ this.data.loading = false
875
+ return Promise.reject(err)
876
+ })
877
+ }
878
+
879
+ loadData (params) {
880
+ params = Object.assign({
881
+ wechatAccountId: null, // 微账号id
882
+ lastUpdateTime: null, // 最后更新时间
883
+ size: 20 // 本次要获取的会话条数
884
+ }, params)
885
+ if (this.lastUpdateTime && !params.lastUpdateTime) {
886
+ params.lastUpdateTime = this.lastUpdateTime
887
+ }
888
+ this.data.loading = true
889
+ const ps1 = this.loadSessionData(params, {
890
+ lastUpdateSession: this.lastUpdateSession,
891
+ lastSession: this.lastSession
892
+ })
893
+ ps1.then((rs) => {
894
+ this.setSessionData(rs.data, false)
895
+ })
896
+ if (this.cancelLoadDataRequest) {
897
+ this.cancelLoadDataRequest()
898
+ }
899
+ this.cancelLoadDataRequest = () => {
900
+ ps1.abort && ps1.abort()
901
+ }
902
+ return Promise.all([ps1]).then((rs) => {
903
+ this.data.loading = false
904
+ return rs[0]
905
+ }, err => {
906
+ this.data.loading = false
907
+ return Promise.reject(err)
908
+ })
909
+ }
910
+
911
+ reset () {
912
+ this.lastUpdateTime = null
913
+ this.lastUpdateSession = null
914
+ this.lastSession = null
915
+ this.data.sessionData = {}
916
+ this.data.sessionGroupData = {}
917
+ this.data.sessionMuteMap = {}
918
+ // this.data.sessionUnreadCountMap = {}
919
+ this.sessionMap = {}
920
+ if (this.cancelLoadDataRequest) {
921
+ this.cancelLoadDataRequest()
922
+ this.cancelLoadDataRequest = null
923
+ }
924
+ if (this.cancelRefreshRequest) {
925
+ this.cancelRefreshRequest()
926
+ this.cancelRefreshRequest = null
927
+ }
928
+ }
929
+ }