Compare commits
2 Commits
24d80e69f6
...
6b9d720134
| Author | SHA1 | Date | |
|---|---|---|---|
| 6b9d720134 | |||
| e71caa6d69 |
2
App.vue
2
App.vue
@ -40,7 +40,7 @@ export default {
|
||||
if (success) {
|
||||
console.log("IM 初始化成功");
|
||||
// IM 初始化成功后,设置全局未读消息监听
|
||||
globalUnreadListenerManager.setup();
|
||||
// globalUnreadListenerManager.setup();
|
||||
} else {
|
||||
console.warn("IM 初始化失败");
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ export default function useGroupChat(groupID) {
|
||||
const getUserAvatar = (userId) => {
|
||||
const member = chatMember.value[userId]
|
||||
if (!member) {
|
||||
return userId === openid.value ? '/static/default-patient-avatar.png' : '/static/default-avatar.png'
|
||||
return userId === openid.value ? '/static/default-patient-avatar.png' : '/static/default-avatar.svg'
|
||||
}
|
||||
|
||||
// 如果有头像且不为空字符串,返回头像
|
||||
@ -55,7 +55,7 @@ export default function useGroupChat(groupID) {
|
||||
return member.avatar
|
||||
}
|
||||
|
||||
return member.isTeamMember ? '/static/default-avatar.png' : '/static/default-patient-avatar.png'
|
||||
return member.isTeamMember ? '/static/default-avatar.svg' : '/static/default-patient-avatar.png'
|
||||
}
|
||||
// 获取群聊信息和成员头像
|
||||
async function getGroupInfo() {
|
||||
@ -76,7 +76,6 @@ export default function useGroupChat(groupID) {
|
||||
|
||||
// 2. 如果有teamId,获取团队成员头像和名称
|
||||
if (groupResult.data.teamId) {
|
||||
|
||||
const memberMap = await teamStore.getTeamMemberAvatarsAndName(groupResult.data.teamId)
|
||||
|
||||
// 3. 存储团队成员ID列表
|
||||
|
||||
@ -444,7 +444,7 @@ function getBubbleClass(message) {
|
||||
}
|
||||
|
||||
// 页面加载
|
||||
onLoad((options) => {
|
||||
onLoad(async (options) => {
|
||||
groupId.value = options.groupID || "";
|
||||
messageList.value = [];
|
||||
isLoading.value = false;
|
||||
@ -473,6 +473,9 @@ onLoad((options) => {
|
||||
}
|
||||
});
|
||||
|
||||
// 先获取群组信息和成员信息,确保 chatMember 已初始化
|
||||
await getGroupInfo();
|
||||
|
||||
checkLoginAndInitTIM();
|
||||
updateNavigationTitle();
|
||||
});
|
||||
@ -563,7 +566,7 @@ const initTIMCallbacks = async () => {
|
||||
.then(async () => {
|
||||
console.log("✓ 收到新消息后已标记为已读");
|
||||
// 标记为已读后,立即刷新 tabBar 徽章
|
||||
await globalUnreadListenerManager.refreshBadge();
|
||||
// await globalUnreadListenerManager.refreshBadge();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("✗ 标记已读失败:", error);
|
||||
@ -717,7 +720,7 @@ const loadMessageList = async () => {
|
||||
.then(async () => {
|
||||
console.log("✓ 会话已标记为已读:", chatInfo.value.conversationID);
|
||||
// 标记为已读后,立即刷新 tabBar 徽章
|
||||
await globalUnreadListenerManager.refreshBadge();
|
||||
// await globalUnreadListenerManager.refreshBadge();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("✗ 标记会话已读失败:", error);
|
||||
@ -913,10 +916,10 @@ onHide(() => {
|
||||
timChatManager.currentConversationID = null;
|
||||
console.log("✓ 页面隐藏,已清空当前会话ID");
|
||||
|
||||
// 页面隐藏时刷新 tabBar 徽章,确保显示正确的未读数
|
||||
if (globalUnreadListenerManager.isInitialized) {
|
||||
globalUnreadListenerManager.refreshBadge();
|
||||
}
|
||||
// // 页面隐藏时刷新 tabBar 徽章,确保显示正确的未读数
|
||||
// if (globalUnreadListenerManager.isInitialized) {
|
||||
// globalUnreadListenerManager.refreshBadge();
|
||||
// }
|
||||
});
|
||||
|
||||
// 处理取消申请
|
||||
|
||||
@ -380,8 +380,8 @@ const setupConversationListener = () => {
|
||||
// 将回调添加到全局未读监听器的回调链中
|
||||
// 这样不会覆盖全局未读监听器,而是与之共存
|
||||
if (globalUnreadListenerManager.isInitialized) {
|
||||
globalUnreadListenerManager.addCallback("onConversationListUpdated", handleConversationListUpdate);
|
||||
globalUnreadListenerManager.addCallback("onMessageReceived", handleMessageReceived);
|
||||
// globalUnreadListenerManager.addCallback("onConversationListUpdated", handleConversationListUpdate);
|
||||
// globalUnreadListenerManager.addCallback("onMessageReceived", handleMessageReceived);
|
||||
console.log("【消息列表页】已添加回调到全局监听器回调链");
|
||||
} else {
|
||||
console.warn("【消息列表页】全局未读监听器未初始化,使用直接回调方式");
|
||||
@ -454,7 +454,7 @@ const handleClickConversation = async (conversation) => {
|
||||
console.log("✓ 已标记会话为已读:", conversation.conversationID);
|
||||
|
||||
// 立即刷新 tabBar 徽章
|
||||
await globalUnreadListenerManager.refreshBadge();
|
||||
// await globalUnreadListenerManager.refreshBadge();
|
||||
} catch (error) {
|
||||
console.error("✗ 标记会话已读失败:", error);
|
||||
}
|
||||
@ -514,9 +514,9 @@ const cleanMessageText = (text) => {
|
||||
// 页面显示
|
||||
onShow(async () => {
|
||||
// 页面显示时刷新 tabBar 徽章
|
||||
if (globalUnreadListenerManager.isInitialized) {
|
||||
await globalUnreadListenerManager.refreshBadge();
|
||||
}
|
||||
// if (globalUnreadListenerManager.isInitialized) {
|
||||
// await globalUnreadListenerManager.refreshBadge();
|
||||
// }
|
||||
});
|
||||
|
||||
// 页面隐藏
|
||||
@ -544,12 +544,12 @@ onUnmounted(() => {
|
||||
updateTimer = null;
|
||||
}
|
||||
|
||||
// 从全局未读监听器的回调链中移除本页面的回调
|
||||
if (globalUnreadListenerManager.isInitialized) {
|
||||
globalUnreadListenerManager.removeCallback("onConversationListUpdated", handleConversationListUpdate);
|
||||
globalUnreadListenerManager.removeCallback("onMessageReceived", handleMessageReceived);
|
||||
console.log("【消息列表页】已从回调链移除回调");
|
||||
}
|
||||
// // 从全局未读监听器的回调链中移除本页面的回调
|
||||
// if (globalUnreadListenerManager.isInitialized) {
|
||||
// globalUnreadListenerManager.removeCallback("onConversationListUpdated", handleConversationListUpdate);
|
||||
// globalUnreadListenerManager.removeCallback("onMessageReceived", handleMessageReceived);
|
||||
// console.log("【消息列表页】已从回调链移除回调");
|
||||
// }
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ export default defineStore("accountStore", () => {
|
||||
console.log('IM 初始化成功');
|
||||
|
||||
// IM 初始化成功后,设置全局未读消息监听
|
||||
globalUnreadListenerManager.setup();
|
||||
// globalUnreadListenerManager.setup();
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
@ -99,7 +99,7 @@ export default defineStore("accountStore", () => {
|
||||
|
||||
// 清除全局未读监听
|
||||
if (globalUnreadListenerManager.isInitialized) {
|
||||
globalUnreadListenerManager.destroy();
|
||||
// globalUnreadListenerManager.destroy();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('退出腾讯IM失败:', error);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user