no message

This commit is contained in:
wangdongbo 2026-02-11 17:49:48 +08:00
parent cc58301191
commit efe1b2994e

View File

@ -217,6 +217,7 @@ const timChatManager = globalTimChatManager;
const PENDING_FOLLOWUP_SEND_STORAGE_KEY = "ykt_followup_pending_send"; const PENDING_FOLLOWUP_SEND_STORAGE_KEY = "ykt_followup_pending_send";
const pendingFollowUpSendConsumed = ref(false); const pendingFollowUpSendConsumed = ref(false);
const initialMessageListLoaded = ref(false); const initialMessageListLoaded = ref(false);
const isCallbacksInitialized = ref(false); //
function normalizeGroupId(v) { function normalizeGroupId(v) {
const s = String(v || "").trim(); const s = String(v || "").trim();
@ -515,6 +516,9 @@ const checkLoginAndInitTIM = async () => {
// IM // IM
const initTIMCallbacks = async () => { const initTIMCallbacks = async () => {
//
isCallbacksInitialized.value = true;
timChatManager.setCallback("onSDKReady", () => { timChatManager.setCallback("onSDKReady", () => {
if (messageList.value.length === 0 && !isLoading.value) { if (messageList.value.length === 0 && !isLoading.value) {
loadMessageList(); loadMessageList();
@ -901,13 +905,46 @@ onShow(() => {
if (!isIMInitialized.value) { if (!isIMInitialized.value) {
checkLoginAndInitTIM(); checkLoginAndInitTIM();
} else if (timChatManager.tim && !timChatManager.isLoggedIn) { } else if (timChatManager.tim && !timChatManager.isLoggedIn) {
timChatManager.ensureIMConnection(); // IM
timChatManager.ensureIMConnection().then(() => {
//
if (timChatManager.isLoggedIn && chatInfo.value.conversationID) {
console.log("✓ 重连成功,重新注册消息监听回调");
initTIMCallbacks();
timChatManager.setConversationID(chatInfo.value.conversationID);
}
});
} else if ( } else if (
timChatManager.tim && timChatManager.tim &&
timChatManager.isLoggedIn && timChatManager.isLoggedIn &&
chatInfo.value.conversationID chatInfo.value.conversationID
) ) {
// IMID
console.log("✓ 页面显示重新设置当前会话ID");
timChatManager.setConversationID(chatInfo.value.conversationID);
//
if (!isCallbacksInitialized.value) {
console.log("✓ 回调未初始化,进行初始化");
initTIMCallbacks();
}
//
if (timChatManager.tim && timChatManager.isLoggedIn) {
timChatManager.tim
.setMessageRead({
conversationID: chatInfo.value.conversationID,
})
.then(() => {
console.log("✓ 页面显示时已标记会话为已读");
})
.catch((error) => {
console.error("✗ 标记会话已读失败:", error);
});
}
startIMMonitoring(30000); startIMMonitoring(30000);
}
// 访 // 访
uni.$on("send-followup-message", handleSendFollowUpMessage); uni.$on("send-followup-message", handleSendFollowUpMessage);