mdm-im-v3 2.1.2 → 2.1.3

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 (26) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +50 -1
  3. package/dist/{FilePreview-Cz0KMA_m.js → FilePreview-CJdqlDs0.js} +2 -2
  4. package/dist/core.es.js +2 -2
  5. package/dist/{index-P9_HILzo.js → index-BLdSVjT-.js} +133 -63
  6. package/dist/{index-C8koozDu.js → index-CrMTFmHU.js} +2 -2
  7. package/dist/{index-GiaKeCU7.js → index-VIcWin6Y.js} +25 -11
  8. package/dist/index.es.js +1 -1
  9. package/dist/style/index.css +1 -1
  10. package/dist-h5/{ChatHistoryH5-CKDqKPl-.js → ChatHistoryH5-BeCSVzKZ.js} +2 -2
  11. package/dist-h5/{ChatPageH5-FXZxtcQr.js → ChatPageH5-GUblGkKv.js} +12 -7
  12. package/dist-h5/{ChatSettingsH5-PackrlPt.js → ChatSettingsH5-wyQ01zjO.js} +3 -2
  13. package/dist-h5/{CreateGroupH5-CO_ZH36_.js → CreateGroupH5-CCtTCnLG.js} +2 -2
  14. package/dist-h5/{GroupAnnouncementH5-yUDR5kYW.js → GroupAnnouncementH5-BYN-HzX0.js} +1 -1
  15. package/dist-h5/{GroupInfoDialogH5-BRk-_mEn.js → GroupInfoDialogH5-DDjYHm7i.js} +1 -1
  16. package/dist-h5/{GroupMembersH5-BVHUF2mG.js → GroupMembersH5-DUWs89a3.js} +1 -1
  17. package/dist-h5/{GroupNoticeH5-KA-L2h9r.js → GroupNoticeH5-C6hNtZzy.js} +1 -1
  18. package/dist-h5/{MemberDetailH5-BfAE0nx-.js → MemberDetailH5-BZlExAgj.js} +16 -3
  19. package/dist-h5/{SearchPageH5-B6B_U4hW.js → SearchPageH5-CjBq_40x.js} +2 -2
  20. package/dist-h5/{SelectMembersH5-CrPoBnYp.js → SelectMembersH5-BSLarLGK.js} +2 -2
  21. package/dist-h5/{imChat-pGlpr8Vj.js → imChat-CdmqPGQ6.js} +1 -1
  22. package/dist-h5/index.es.js +2 -2
  23. package/dist-h5/{indexH5-sKvS7t3k.js → indexH5-CCseQmQb.js} +4 -3
  24. package/dist-h5/{indexH5-CCvF1MV7.js → indexH5-DikfbMIK.js} +126 -53
  25. package/dist-h5/style/index-h5.css +1 -1
  26. package/package.json +1 -1
@@ -1,10 +1,10 @@
1
1
  import { computed, ref, watch, onBeforeUnmount, openBlock, createElementBlock, createVNode, unref, withCtx, createElementVNode, withModifiers, createTextVNode, toDisplayString, createCommentVNode, Fragment, renderList, createBlock, normalizeClass, normalizeStyle, inject, provide, onMounted, nextTick } from "vue";
2
2
  import { useRouter } from "vue-router";
3
3
  import { NavBar, Icon, Badge, PullRefresh, SwipeCell, Loading, Empty, Button, ActionSheet, Cell, showDialog, showToast } from "vant";
4
- import { u as useChatStore, I as IM_CVS_TYPE, g as getGroupAvatarBg, i as isDefaultAvatar, a as getAvatarBg, b as getAvatarText, c as cloneDeep, d as getConversationBurnSetting, e as useMessage, f as useUsers, h as useConversations, j as useMsgList, m as mittBus, k as IM_LOGIN_STATUS, p as preserveBurnInEx, l as IM_LOGIN_PLATFORM, s as sleep, n as handleUrl } from "./indexH5-CCvF1MV7.js";
4
+ import { u as useChatStore, I as IM_CVS_TYPE, g as getGroupAvatarBg, i as isDefaultAvatar, a as getAvatarBg, b as getAvatarText, c as cloneDeep, d as getConversationBurnSetting, e as useMessage, f as useUsers, h as useConversations, j as useMsgList, m as mittBus, k as IM_LOGIN_STATUS, p as preserveBurnInEx, l as IM_LOGIN_PLATFORM, s as sleep, n as handleUrl } from "./indexH5-DikfbMIK.js";
5
5
  import "element-plus";
6
6
  import { d as defaultAvatar } from "./default_avatar-BE2kit_X.js";
7
- import { J as JoinGroupDialogH5, G as GroupInfoDialogH5 } from "./GroupInfoDialogH5-BRk-_mEn.js";
7
+ import { J as JoinGroupDialogH5, G as GroupInfoDialogH5 } from "./GroupInfoDialogH5-DDjYHm7i.js";
8
8
  const _hoisted_1 = { class: "chat-list-h5" };
9
9
  const _hoisted_2 = { key: 0 };
10
10
  const _hoisted_3 = { style: { "display": "flex", "align-items": "center", "gap": "20px" } };
@@ -619,7 +619,7 @@ const _sfc_main = {
619
619
  provide("loadMessageCount", pageCount);
620
620
  }
621
621
  const chatMessage = useChatStore();
622
- const { initIMSDK, waitForSyncFinish } = useMessage();
622
+ const { initIMSDK, waitForSyncFinish, publishUnreadCount } = useMessage();
623
623
  const baseUrl = computed(() => chatMessage.getBaseUrl);
624
624
  const localUser = computed(() => chatMessage.getUserInfo);
625
625
  computed(() => chatMessage.getLoginStatus);
@@ -936,6 +936,7 @@ const _sfc_main = {
936
936
  await nextTick();
937
937
  initMessagePage();
938
938
  }
939
+ publishUnreadCount("init");
939
940
  };
940
941
  const handleGroupApplicationAdded = (data) => {
941
942
  if (!(data == null ? void 0 : data.groupID)) return;
@@ -482,7 +482,10 @@ const useChatStore = defineStore("chatMessage", {
482
482
  },
483
483
  // 更新未读总数
484
484
  setUnReadCount(count = 0) {
485
- this.unReadCount = count;
485
+ const next = Number(count) || 0;
486
+ if (this.unReadCount === next) return;
487
+ console.log("[IM][unread] store 未读总数更新", { from: this.unReadCount, to: next });
488
+ this.unReadCount = next;
486
489
  },
487
490
  // 更新用户的登录状态
488
491
  setLoginStatus(val) {
@@ -10821,20 +10824,20 @@ class ImKit extends EventEmitter {
10821
10824
  }
10822
10825
  /**
10823
10826
  * 获取所有会话的未读消息总数
10824
- * @returns {Number}
10827
+ * @returns {Number|null} 未读总数;获取失败返回 null(调用方不应把 null 当成 0 覆盖本地值)
10825
10828
  */
10826
10829
  async getTotalUnreadMsgCount(operationID = uuidv4()) {
10827
10830
  var _a;
10828
10831
  if (!this.IMSDK) {
10829
- return 0;
10832
+ return null;
10830
10833
  }
10831
10834
  try {
10832
10835
  const res = await ((_a = this.IMSDK) == null ? void 0 : _a.getTotalUnreadMsgCount(operationID));
10833
- return (res == null ? void 0 : res.data) || 0;
10836
+ return Number(res == null ? void 0 : res.data) || 0;
10834
10837
  } catch (error) {
10835
- console.error("获取未读消息总数失败:", error);
10838
+ console.error("[IM][unread] 获取未读消息总数失败:", error);
10836
10839
  this.handleError(error);
10837
- return 0;
10840
+ return null;
10838
10841
  }
10839
10842
  }
10840
10843
  /**
@@ -36430,6 +36433,11 @@ const conversationList = ref([]);
36430
36433
  const skipSortIds = /* @__PURE__ */ new Set();
36431
36434
  const currentConversation = ref({});
36432
36435
  const currentConversationUsers = ref([]);
36436
+ let conversationListReady = false;
36437
+ const setConversationListReady = (value) => {
36438
+ conversationListReady = Boolean(value);
36439
+ };
36440
+ const isConversationListReady = () => conversationListReady;
36433
36441
  const useConversations = () => {
36434
36442
  const chatMessage = useChatStore();
36435
36443
  const baseUrl = chatMessage.getBaseUrl;
@@ -36558,8 +36566,12 @@ const useConversations = () => {
36558
36566
  currentConversation.value = curCvs;
36559
36567
  }
36560
36568
  const unreadCount = getUnReadMessageCount();
36561
- if (chatMessage.setUnReadCount) {
36562
- chatMessage.setUnReadCount(unreadCount);
36569
+ if (conversationListReady) {
36570
+ if (chatMessage.setUnReadCount) {
36571
+ chatMessage.setUnReadCount(unreadCount);
36572
+ }
36573
+ } else {
36574
+ console.log("[IM][unread] 会话列表未加载完成,跳过列表汇总覆盖", { listCount: unreadCount });
36563
36575
  }
36564
36576
  };
36565
36577
  const getCurrentConversation = (id) => {
@@ -36619,6 +36631,7 @@ const useConversations = () => {
36619
36631
  };
36620
36632
  const clearConversationList = () => {
36621
36633
  skipSortIds.clear();
36634
+ conversationListReady = false;
36622
36635
  currentConversationUsers.value = [];
36623
36636
  conversationList.value = [];
36624
36637
  currentConversation.value = {};
@@ -36634,7 +36647,9 @@ const useConversations = () => {
36634
36647
  getConversationIDBySessionType,
36635
36648
  getConversationByKey,
36636
36649
  markSkipNextSort,
36637
- clearConversationList
36650
+ clearConversationList,
36651
+ setConversationListReady,
36652
+ isConversationListReady
36638
36653
  };
36639
36654
  };
36640
36655
  const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6MrnknFD1b8Vx+j8JBV86o4s2KAl/Y81O1HUIPqy/qE9LHpCEBpFLqsIRBYq5AWkG6rvWA49Xy6kkeXJ/Q5A9Pmdhat/d3OkTAUNhurrB9wcVQaMgAqbBIsOV1EdH15iZcX2Cx4/fearf2LFyeeDQj5LpKLHtT4gIhakLP+Zz6MBxLhwWQCo4GE+8wGywqsW77TmSmn/vD7o35Pn2quofKvurJZ8KmJw3xZmI6C+2ex9b1xeg5wz4DbtB42FRf2bIn9VHhPDzT+o+gIyI0v3WUo8UXct06bGE5bFCxuqLAG/bczezYAZtuJmILj9ZdkeL41di61n19Gm4YEUCqpPGuxmQkGF+ZJlOB6zcA1ngi/jG2geu81a5FdByDAoMec9vhkr3bWWSVkOjW8ZY08ZxIMPED6rF8MVyzRgxQRpH+aR9LqheJxfrv6F1C5GfmsC/kjgOsB/3rz83plnZGr8Yq2xfyrGgt2duAHvO46ibhiBDPjzTFv6S2ab1sOGuAMsqji2O1qfFFZTDwX4lYD0G6RP9yYKUavSH3b3wh1/Ly9aVZ736qDF+N5z6VSZCNVYflRFRK0MlCN0R2xv4mGog9Q32WLWiEIWcAqX5dT4oEY6sjgZjPMnwFkzwDkDqY6DIiXmGl01t9Ifd+b9j1ax8mnP4a9+3oAXP1MNT09Z6pPdm33lOhZVrHX+1ahXZbwPtVBjbwHlKZ6DWkOojoykhTbFZ9ML6RhgoMDS3kFKCeKhsWxV6qDyTmtxcVTIQzCwDUGsRx1DmThS8noTvFIny6yGYjZpsjLe/3ZErLm+gdm7WOMN+Ndv8APtOWIVSNeEF7ccF41REJxF+gHANDXSFvAHXJJ90+qQ/En44G4rcg9lDacS6xfJWI7wdIa8G/JqZ3iaiZejFvtcuE1pLQMvSWa7WtyogE44sRP62y0Sav9BcAAAD//xrBmEkAAAAGSURBVAMAFY4uAUYOw/MAAAAASUVORK5CYII=";
@@ -36969,9 +36984,10 @@ const handleLinks = (text = "") => {
36969
36984
  });
36970
36985
  };
36971
36986
  const NOTICE_AGENT_PREFIX = "agent_";
36987
+ const isNoticeAgentUser = (userID) => String(userID || "").startsWith(NOTICE_AGENT_PREFIX);
36972
36988
  const isNoticeAgentConversation = (cvs) => {
36973
36989
  if (!cvs || cvs.conversationType !== IM_CVS_TYPE.Single) return false;
36974
- return String(cvs.userID || "").startsWith(NOTICE_AGENT_PREFIX);
36990
+ return isNoticeAgentUser(cvs.userID);
36975
36991
  };
36976
36992
  const createCvsId = (msg) => {
36977
36993
  if (msg.sessionType === IM_CVS_TYPE.Single) {
@@ -39801,6 +39817,7 @@ let syncFinished = false;
39801
39817
  let syncWaiters = [];
39802
39818
  let conversationBusBound = false;
39803
39819
  let burnHandlerBound = false;
39820
+ let lastUnreadCount = null;
39804
39821
  const resolveSyncWaiters = (ok) => {
39805
39822
  syncFinished = true;
39806
39823
  const waiters = syncWaiters.splice(0);
@@ -39908,7 +39925,9 @@ const useMessage = (config = {}) => {
39908
39925
  updateConversationLatestMessage,
39909
39926
  getConversationIDBySessionType,
39910
39927
  getConversationByKey,
39911
- clearConversationList
39928
+ clearConversationList,
39929
+ setConversationListReady: setConversationListReady2,
39930
+ isConversationListReady: isConversationListReady2
39912
39931
  } = useConversations();
39913
39932
  const {
39914
39933
  messageList: messageList2,
@@ -39968,23 +39987,64 @@ const useMessage = (config = {}) => {
39968
39987
  if (((_a = currentConversation2.value) == null ? void 0 : _a.conversationID) === data.conversationID) {
39969
39988
  currentConversation2.value = { ...currentConversation2.value, ...data };
39970
39989
  }
39990
+ refreshUnreadCount();
39971
39991
  });
39972
39992
  }
39973
- const getUnReadMessageCount = async (bool = false) => {
39993
+ const publishUnreadCount = (reason = "update", extra = {}) => {
39994
+ if (reason === "init") {
39995
+ setConversationListReady2(true);
39996
+ if (conversationList2.value.length > 0) {
39997
+ const listCount = conversationList2.value.reduce(
39998
+ (pre, cur) => pre + (cur.unreadCount > 0 ? cur.unreadCount : 0),
39999
+ 0
40000
+ );
40001
+ messageStore.setUnReadCount(listCount);
40002
+ }
40003
+ }
40004
+ const count = Number(messageStore.getUnReadCount) || 0;
40005
+ lastUnreadCount = count;
40006
+ const payload = { count, reason, time: Date.now(), ...extra };
40007
+ console.log("[IM][unread] 广播未读消息事件", payload);
40008
+ mittBus.emit("IM_UNREAD_COUNT_CHANGED", payload);
40009
+ };
40010
+ const publishUnreadIfChanged = (reason = "update") => {
40011
+ if ((Number(messageStore.getUnReadCount) || 0) === lastUnreadCount) return;
40012
+ publishUnreadCount(reason);
40013
+ };
40014
+ const refreshUnreadCount = () => {
40015
+ if (isConversationListReady2()) {
40016
+ publishUnreadIfChanged("update");
40017
+ } else {
40018
+ getUnReadMessageCount(true);
40019
+ }
40020
+ };
40021
+ const getUnReadMessageCount = async (bool = false, reason = "update", extra = {}) => {
39974
40022
  if (bool) {
39975
40023
  if (!imInstance) return;
39976
40024
  const countScope = imSessionScope(messageStore);
39977
40025
  const countRevision = sessionRevision;
39978
40026
  const count = await (imInstance == null ? void 0 : imInstance.getTotalUnreadMsgCount());
39979
40027
  if (countRevision !== sessionRevision || countScope !== imSessionScope(messageStore)) return;
40028
+ if (count == null) {
40029
+ console.warn("[IM][unread] SDK 未读总数获取失败,保留当前未读数", {
40030
+ current: messageStore.getUnReadCount
40031
+ });
40032
+ return;
40033
+ }
40034
+ console.log("[IM][unread] 重新计算未读总数", { source: "sdk", count: count || 0, reason });
39980
40035
  messageStore.setUnReadCount(count || 0);
39981
40036
  } else {
39982
40037
  const count = conversationList2.value.reduce((pre, cur) => {
39983
40038
  return pre + (cur.unreadCount > 0 ? cur.unreadCount : 0);
39984
40039
  }, 0);
39985
- console.log("全部未读消息1:", count);
40040
+ console.log("[IM][unread] 重新计算未读总数", { source: "conversationList", count, reason });
39986
40041
  messageStore.setUnReadCount(count || 0);
39987
40042
  }
40043
+ if (reason === "receive") {
40044
+ publishUnreadCount(reason, extra);
40045
+ } else {
40046
+ publishUnreadIfChanged(reason);
40047
+ }
39988
40048
  };
39989
40049
  const setConversationMsgAsRead = async (id) => {
39990
40050
  var _a;
@@ -40031,6 +40091,7 @@ const useMessage = (config = {}) => {
40031
40091
  if (imInstance === previous) imInstance = null;
40032
40092
  if (typeof window !== "undefined" && window.imInstance === previous) window.imInstance = null;
40033
40093
  resetSyncState();
40094
+ lastUnreadCount = null;
40034
40095
  if (clearData) {
40035
40096
  clearConversationList();
40036
40097
  clearMessageList();
@@ -40330,6 +40391,7 @@ const useMessage = (config = {}) => {
40330
40391
  return curMsgList;
40331
40392
  };
40332
40393
  onSessionEvent(CbEvents.OnRecvNewMessages, async (list) => {
40394
+ var _a;
40333
40395
  console.log("批量接收消息:", list);
40334
40396
  if ((list == null ? void 0 : list.length) > 0) {
40335
40397
  await resolveConversationIDs(list);
@@ -40344,6 +40406,9 @@ const useMessage = (config = {}) => {
40344
40406
  const latestMsg = curMsgList[curMsgList.length - 1];
40345
40407
  updateConversationLatestMessage(cvs.conversationID, latestMsg, handleMessage(latestMsg));
40346
40408
  }
40409
+ if (!isActive()) return;
40410
+ const cvsId = ((_a = list[list.length - 1]) == null ? void 0 : _a.conversationID) || "";
40411
+ await getUnReadMessageCount(!isConversationListReady2(), "receive", { conversationID: cvsId });
40347
40412
  }
40348
40413
  });
40349
40414
  onSessionEvent(CbEvents.OnRecvC2CReadReceipt, async (list) => {
@@ -40372,7 +40437,7 @@ const useMessage = (config = {}) => {
40372
40437
  if (val === IM_LOGIN_STATUS.Logged) {
40373
40438
  initTimer = setTimeout(() => {
40374
40439
  if (!isActive()) return;
40375
- getUnReadMessageCount();
40440
+ getUnReadMessageCount(true);
40376
40441
  }, 1e3);
40377
40442
  } else if (val === IM_LOGIN_STATUS.Logout) {
40378
40443
  mittBus.emit("IM_LOGOUT");
@@ -40386,6 +40451,7 @@ const useMessage = (config = {}) => {
40386
40451
  console.log("IM 服务端同步完成");
40387
40452
  resolveSyncWaiters(true);
40388
40453
  mittBus.emit("IM_SYNC_SERVER_FINISH", true);
40454
+ getUnReadMessageCount(true);
40389
40455
  });
40390
40456
  onSessionEvent(CbEvents.OnSyncServerFailed, (data) => {
40391
40457
  console.warn("IM 服务端同步失败:", data);
@@ -40402,6 +40468,7 @@ const useMessage = (config = {}) => {
40402
40468
  if (Array.isArray(data) && (data == null ? void 0 : data.length)) {
40403
40469
  console.log("会话状态改变:", data);
40404
40470
  handleConversationList(data, "update", handleMessage);
40471
+ refreshUnreadCount();
40405
40472
  }
40406
40473
  });
40407
40474
  onSessionEvent(CbEvents.OnNewConversation, async (data) => {
@@ -40426,6 +40493,7 @@ const useMessage = (config = {}) => {
40426
40493
  } else if (newList.length > 0) {
40427
40494
  handleConversationList(newList, "add", handleMessage);
40428
40495
  }
40496
+ refreshUnreadCount();
40429
40497
  mittBus.emit("OnNewConversationCreated", data);
40430
40498
  }
40431
40499
  });
@@ -40530,6 +40598,7 @@ const useMessage = (config = {}) => {
40530
40598
  initIMSDK,
40531
40599
  clearInstance,
40532
40600
  getUnReadMessageCount,
40601
+ publishUnreadCount,
40533
40602
  setConversationMsgAsRead,
40534
40603
  waitForSyncFinish
40535
40604
  };
@@ -40573,13 +40642,13 @@ const _sfc_main = {
40573
40642
  default: "1"
40574
40643
  }
40575
40644
  },
40576
- emits: ["send-chat-text", "invite-member"],
40645
+ emits: ["send-chat-text", "invite-member", "unread-change"],
40577
40646
  setup(__props, { expose: __expose, emit: __emit }) {
40578
40647
  const routes = [
40579
40648
  {
40580
40649
  path: "/messages",
40581
40650
  name: "Messages",
40582
- component: () => import("./indexH5-sKvS7t3k.js"),
40651
+ component: () => import("./indexH5-CCseQmQb.js"),
40583
40652
  meta: { title: "消息" }
40584
40653
  },
40585
40654
  // 根路径重定向到会话列表页
@@ -40590,61 +40659,61 @@ const _sfc_main = {
40590
40659
  {
40591
40660
  path: "/chat",
40592
40661
  name: "Chat",
40593
- component: () => import("./ChatPageH5-FXZxtcQr.js"),
40662
+ component: () => import("./ChatPageH5-GUblGkKv.js"),
40594
40663
  meta: { title: "聊天" }
40595
40664
  },
40596
40665
  {
40597
40666
  path: "/search",
40598
40667
  name: "Search",
40599
- component: () => import("./SearchPageH5-B6B_U4hW.js"),
40668
+ component: () => import("./SearchPageH5-CjBq_40x.js"),
40600
40669
  meta: { title: "搜索" }
40601
40670
  },
40602
40671
  {
40603
40672
  path: "/notice",
40604
40673
  name: "Notice",
40605
- component: () => import("./GroupNoticeH5-KA-L2h9r.js"),
40674
+ component: () => import("./GroupNoticeH5-C6hNtZzy.js"),
40606
40675
  meta: { title: "群通知" }
40607
40676
  },
40608
40677
  {
40609
40678
  path: "/create-group",
40610
40679
  name: "CreateGroup",
40611
- component: () => import("./CreateGroupH5-CO_ZH36_.js"),
40680
+ component: () => import("./CreateGroupH5-CCtTCnLG.js"),
40612
40681
  meta: { title: "创建群组" }
40613
40682
  },
40614
40683
  {
40615
40684
  path: "/select-members",
40616
40685
  name: "SelectMembers",
40617
- component: () => import("./SelectMembersH5-CrPoBnYp.js"),
40686
+ component: () => import("./SelectMembersH5-BSLarLGK.js"),
40618
40687
  meta: { title: "成员选择" }
40619
40688
  },
40620
40689
  {
40621
40690
  path: "/member-detail",
40622
40691
  name: "MemberDetail",
40623
- component: () => import("./MemberDetailH5-BfAE0nx-.js"),
40692
+ component: () => import("./MemberDetailH5-BZlExAgj.js"),
40624
40693
  meta: { title: "个人详情" }
40625
40694
  },
40626
40695
  {
40627
40696
  path: "/chat-settings",
40628
40697
  name: "ChatSettings",
40629
- component: () => import("./ChatSettingsH5-PackrlPt.js"),
40698
+ component: () => import("./ChatSettingsH5-wyQ01zjO.js"),
40630
40699
  meta: { title: "聊天设置" }
40631
40700
  },
40632
40701
  {
40633
40702
  path: "/group-announcement",
40634
40703
  name: "GroupAnnouncement",
40635
- component: () => import("./GroupAnnouncementH5-yUDR5kYW.js"),
40704
+ component: () => import("./GroupAnnouncementH5-BYN-HzX0.js"),
40636
40705
  meta: { title: "群公告" }
40637
40706
  },
40638
40707
  {
40639
40708
  path: "/chat-history",
40640
40709
  name: "ChatHistory",
40641
- component: () => import("./ChatHistoryH5-CKDqKPl-.js"),
40710
+ component: () => import("./ChatHistoryH5-BeCSVzKZ.js"),
40642
40711
  meta: { title: "聊天记录" }
40643
40712
  },
40644
40713
  {
40645
40714
  path: "/group-members",
40646
40715
  name: "GroupMembers",
40647
- component: () => import("./GroupMembersH5-BVHUF2mG.js"),
40716
+ component: () => import("./GroupMembersH5-DUWs89a3.js"),
40648
40717
  meta: { title: "群成员" }
40649
40718
  }
40650
40719
  ];
@@ -40667,6 +40736,7 @@ const _sfc_main = {
40667
40736
  provide(routeLocationKey, routeLocation);
40668
40737
  const props = __props;
40669
40738
  const emits = __emit;
40739
+ const handleUnreadCountChanged = (payload) => emits("unread-change", payload);
40670
40740
  const onSendChatText = (payload) => emits("send-chat-text", payload);
40671
40741
  const onInviteMember = (memberIds) => emits("invite-member", memberIds);
40672
40742
  provide("h5RootConfig", {
@@ -40720,11 +40790,13 @@ const _sfc_main = {
40720
40790
  checkLogin();
40721
40791
  };
40722
40792
  onMounted(() => {
40793
+ mittBus.on("IM_UNREAD_COUNT_CHANGED", handleUnreadCountChanged);
40723
40794
  if (chatMessage.getLoginStatus === IM_LOGIN_STATUS.Logged && window["imInstance"]) {
40724
40795
  router.replace("/messages");
40725
40796
  }
40726
40797
  });
40727
40798
  onBeforeUnmount(() => {
40799
+ mittBus.off("IM_UNREAD_COUNT_CHANGED", handleUnreadCountChanged);
40728
40800
  if (_loginTimer) {
40729
40801
  clearTimeout(_loginTimer);
40730
40802
  _loginTimer = null;
@@ -40743,35 +40815,36 @@ const _sfc_main = {
40743
40815
  }
40744
40816
  };
40745
40817
  export {
40746
- _sfc_main as $,
40747
- useBurnAfterReading as A,
40748
- dedupeMessages as B,
40749
- getDefaultExportFromCjs as C,
40750
- getMediaDuration as D,
40751
- getReplyDetail as E,
40752
- IM_FONT_FAMILY as F,
40753
- IM_FONT_SIZE as G,
40754
- IM_FONT_STYLE as H,
40818
+ requestInstance as $,
40819
+ isNoticeAgentUser as A,
40820
+ useBurnAfterReading as B,
40821
+ dedupeMessages as C,
40822
+ getDefaultExportFromCjs as D,
40823
+ getMediaDuration as E,
40824
+ getReplyDetail as F,
40825
+ IM_FONT_FAMILY as G,
40826
+ IM_FONT_SIZE as H,
40755
40827
  IM_CVS_TYPE as I,
40756
- IM_GROUP_STATUS as J,
40757
- uuidv4 as K,
40758
- debounce as L,
40759
- handleDateUtil as M,
40760
- GROUP_JOIN_SOURCE as N,
40761
- IM_GROUP_MEMBER_ROLE as O,
40762
- GROUP_VERIFICATION_TYPE as P,
40763
- IM_GROUP_TYPE as Q,
40764
- BURN_DEFAULT as R,
40765
- BURN_PRESETS as S,
40766
- formatBurnDuration as T,
40767
- copyToClipboard as U,
40768
- clampBurnDuration as V,
40769
- buildBurnEx as W,
40770
- downloadFileByBlob as X,
40771
- imSessionScope as Y,
40772
- IMSessionChangedError as Z,
40773
- requestInstance as _,
40828
+ IM_FONT_STYLE as J,
40829
+ IM_GROUP_STATUS as K,
40830
+ uuidv4 as L,
40831
+ debounce as M,
40832
+ handleDateUtil as N,
40833
+ GROUP_JOIN_SOURCE as O,
40834
+ IM_GROUP_MEMBER_ROLE as P,
40835
+ GROUP_VERIFICATION_TYPE as Q,
40836
+ IM_GROUP_TYPE as R,
40837
+ BURN_DEFAULT as S,
40838
+ BURN_PRESETS as T,
40839
+ formatBurnDuration as U,
40840
+ copyToClipboard as V,
40841
+ clampBurnDuration as W,
40842
+ buildBurnEx as X,
40843
+ downloadFileByBlob as Y,
40844
+ imSessionScope as Z,
40845
+ IMSessionChangedError as _,
40774
40846
  getAvatarBg as a,
40847
+ _sfc_main as a0,
40775
40848
  getAvatarText as b,
40776
40849
  cloneDeep as c,
40777
40850
  getConversationBurnSetting as d,