feat: 添加订阅提醒功能和相关配置

This commit is contained in:
Jafeng 2026-04-16 17:32:14 +08:00
parent 3e09131356
commit be54f97bab
4 changed files with 93 additions and 15 deletions

View File

@ -20,7 +20,11 @@
>
<text class="badge-text">{{ chatStatusInfo.badgeText }}</text>
</view>
<view class="remind-btn" @click="handleSubscribeReminder">
<view
v-if="showSubscribeEntry"
class="remind-btn"
@click="handleSubscribeReminder"
>
<text class="remind-btn-text">接收提醒</text>
</view>
</view>
@ -195,7 +199,10 @@ import ChatInput from "./components/chat-input.vue";
import SystemMessage from "./components/system-message.vue";
import ConsultCancel from "./components/consult-cancel.vue";
import ConsultApply from "./components/consult-apply.vue";
import { requestConversationSubscribeMessage } from "@/utils/subscribe-message";
import {
checkConversationSubscribeEntryVisible,
requestConversationSubscribeMessage,
} from "@/utils/subscribe-message";
import {
SUBSCRIBE_MESSAGE_ROLE,
SUBSCRIBE_MESSAGE_SCENE,
@ -203,8 +210,9 @@ import {
const timChatManager = globalTimChatManager;
// corpId
const corpId = ref("");
// corpId
const corpId = ref("");
const showSubscribeEntry = ref(false);
//
const { account, openid, isIMInitialized } = storeToRefs(useAccountStore());
@ -866,10 +874,11 @@ const handleScrollToUpper = async () => {
};
//
onShow(() => {
if (!account.value || !openid.value) {
uni.redirectTo({
url: "/pages/login/login",
onShow(() => {
loadSubscribeEntryState();
if (!account.value || !openid.value) {
uni.redirectTo({
url: "/pages/login/login",
});
return;
}
@ -915,8 +924,16 @@ onShow(() => {
}
startIMMonitoring(30000);
}
});
}
});
watch(
() => corpId.value,
() => {
loadSubscribeEntryState();
},
{ immediate: true }
);
//
onHide(() => {
@ -1090,9 +1107,16 @@ const handleSubscribeReminder = async () => {
},
});
};
//
onUnmounted(() => {
const loadSubscribeEntryState = async () => {
showSubscribeEntry.value = await checkConversationSubscribeEntryVisible(
corpId.value || "",
true
);
};
//
onUnmounted(() => {
clearMessageCache();
//

View File

@ -52,7 +52,11 @@
</view>
</scroll-view>
<view class="subscribe-entry" @click="handleSubscribeReminder">
<view
v-if="showSubscribeEntry"
class="subscribe-entry"
@click="handleSubscribeReminder"
>
<text class="subscribe-entry-text">接收提醒</text>
</view>
</view>
@ -68,7 +72,10 @@ import { mergeConversationWithGroupDetails } from "@/utils/conversation-merger.j
import { globalUnreadListenerManager } from "@/utils/global-unread-listener.js";
import useGroupAvatars from "./hooks/use-group-avatars.js";
import GroupAvatar from "@/components/group-avatar.vue";
import { requestConversationSubscribeMessage } from "@/utils/subscribe-message";
import {
checkConversationSubscribeEntryVisible,
requestConversationSubscribeMessage,
} from "@/utils/subscribe-message";
import {
SUBSCRIBE_MESSAGE_ROLE,
SUBSCRIBE_MESSAGE_SCENE,
@ -86,6 +93,7 @@ const loading = ref(false);
const loadingMore = ref(false);
const hasMore = ref(false);
const refreshing = ref(false);
const showSubscribeEntry = ref(false);
//
const { loadGroupAvatars, getAvatarList } = useGroupAvatars();
@ -516,14 +524,31 @@ const handleSubscribeReminder = async () => {
});
};
const loadSubscribeEntryState = async () => {
const currentCorpId = teams.value.find((item) => item?.corpId)?.corpId || "";
showSubscribeEntry.value = await checkConversationSubscribeEntryVisible(
currentCorpId,
true
);
};
//
onShow(async () => {
// tabBar
// if (globalUnreadListenerManager.isInitialized) {
// await globalUnreadListenerManager.refreshBadge();
// }
await loadSubscribeEntryState();
});
watch(
() => teams.value.map((item) => item?.corpId).join(","),
() => {
loadSubscribeEntryState();
},
{ immediate: true }
);
//
onHide(() => {
console.log("【消息列表页】页面隐藏");

View File

@ -73,6 +73,7 @@ const urlsConfig = {
createConsultGroup: "createConsultGroup",
cancelConsultApplication: "cancelConsultApplication",
getGroupList: "getGroupList",
getConversationSubscribeConfig: "getConversationSubscribeConfig",
saveConversationSubscribeResult: "saveConversationSubscribeResult",
sendConversationSubscribeEvent: "sendConversationSubscribeEvent"
},

View File

@ -8,6 +8,7 @@ const SUBSCRIBE_BAN_STATUS = "ban";
const SUBSCRIBE_FILTER_STATUS = "filter";
const SUBSCRIBE_CANCEL_STATUS = "cancel";
const SUBSCRIBE_FAILED_STATUS = "failed";
const subscribeDisplayConfigCache = new Map();
function canUseSubscribeMessage() {
return (
@ -142,6 +143,33 @@ async function reportSubscribeResult(records = []) {
}
}
export async function checkConversationSubscribeEntryVisible(
corpId = "",
forceRefresh = false
) {
const normalizedCorpId = String(corpId || "").trim();
if (!normalizedCorpId) return false;
if (!forceRefresh && subscribeDisplayConfigCache.has(normalizedCorpId)) {
return subscribeDisplayConfigCache.get(normalizedCorpId);
}
try {
const result = await api(
"getConversationSubscribeConfig",
{ corpId: normalizedCorpId },
false
);
const enabled = !!result?.data?.enabled;
subscribeDisplayConfigCache.set(normalizedCorpId, enabled);
return enabled;
} catch (error) {
console.error("获取订阅提醒显示配置失败:", error);
subscribeDisplayConfigCache.set(normalizedCorpId, false);
return false;
}
}
export async function requestConversationSubscribeMessage(context = {}) {
const templates = resolveSubscribeTemplates({
role: context.role,