feat: 添加订阅提醒功能和相关配置
This commit is contained in:
parent
3e09131356
commit
be54f97bab
@ -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();
|
||||
|
||||
// 移除键盘监听
|
||||
|
||||
@ -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("【消息列表页】页面隐藏");
|
||||
|
||||
@ -73,6 +73,7 @@ const urlsConfig = {
|
||||
createConsultGroup: "createConsultGroup",
|
||||
cancelConsultApplication: "cancelConsultApplication",
|
||||
getGroupList: "getGroupList",
|
||||
getConversationSubscribeConfig: "getConversationSubscribeConfig",
|
||||
saveConversationSubscribeResult: "saveConversationSubscribeResult",
|
||||
sendConversationSubscribeEvent: "sendConversationSubscribeEvent"
|
||||
},
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user