feat: 添加订阅提醒功能和相关配置
This commit is contained in:
parent
3e09131356
commit
be54f97bab
@ -20,7 +20,11 @@
|
|||||||
>
|
>
|
||||||
<text class="badge-text">{{ chatStatusInfo.badgeText }}</text>
|
<text class="badge-text">{{ chatStatusInfo.badgeText }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="remind-btn" @click="handleSubscribeReminder">
|
<view
|
||||||
|
v-if="showSubscribeEntry"
|
||||||
|
class="remind-btn"
|
||||||
|
@click="handleSubscribeReminder"
|
||||||
|
>
|
||||||
<text class="remind-btn-text">接收提醒</text>
|
<text class="remind-btn-text">接收提醒</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -195,7 +199,10 @@ import ChatInput from "./components/chat-input.vue";
|
|||||||
import SystemMessage from "./components/system-message.vue";
|
import SystemMessage from "./components/system-message.vue";
|
||||||
import ConsultCancel from "./components/consult-cancel.vue";
|
import ConsultCancel from "./components/consult-cancel.vue";
|
||||||
import ConsultApply from "./components/consult-apply.vue";
|
import ConsultApply from "./components/consult-apply.vue";
|
||||||
import { requestConversationSubscribeMessage } from "@/utils/subscribe-message";
|
import {
|
||||||
|
checkConversationSubscribeEntryVisible,
|
||||||
|
requestConversationSubscribeMessage,
|
||||||
|
} from "@/utils/subscribe-message";
|
||||||
import {
|
import {
|
||||||
SUBSCRIBE_MESSAGE_ROLE,
|
SUBSCRIBE_MESSAGE_ROLE,
|
||||||
SUBSCRIBE_MESSAGE_SCENE,
|
SUBSCRIBE_MESSAGE_SCENE,
|
||||||
@ -205,6 +212,7 @@ const timChatManager = globalTimChatManager;
|
|||||||
|
|
||||||
// corpId 从群组信息中获取
|
// corpId 从群组信息中获取
|
||||||
const corpId = ref("");
|
const corpId = ref("");
|
||||||
|
const showSubscribeEntry = ref(false);
|
||||||
|
|
||||||
// 获取登录状态
|
// 获取登录状态
|
||||||
const { account, openid, isIMInitialized } = storeToRefs(useAccountStore());
|
const { account, openid, isIMInitialized } = storeToRefs(useAccountStore());
|
||||||
@ -867,6 +875,7 @@ const handleScrollToUpper = async () => {
|
|||||||
|
|
||||||
// 页面显示
|
// 页面显示
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
|
loadSubscribeEntryState();
|
||||||
if (!account.value || !openid.value) {
|
if (!account.value || !openid.value) {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: "/pages/login/login",
|
url: "/pages/login/login",
|
||||||
@ -918,6 +927,14 @@ onShow(() => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => corpId.value,
|
||||||
|
() => {
|
||||||
|
loadSubscribeEntryState();
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
// 页面隐藏
|
// 页面隐藏
|
||||||
onHide(() => {
|
onHide(() => {
|
||||||
stopIMMonitoring();
|
stopIMMonitoring();
|
||||||
@ -1091,6 +1108,13 @@ const handleSubscribeReminder = async () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const loadSubscribeEntryState = async () => {
|
||||||
|
showSubscribeEntry.value = await checkConversationSubscribeEntryVisible(
|
||||||
|
corpId.value || "",
|
||||||
|
true
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// 页面卸载
|
// 页面卸载
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
clearMessageCache();
|
clearMessageCache();
|
||||||
|
|||||||
@ -52,7 +52,11 @@
|
|||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
<view class="subscribe-entry" @click="handleSubscribeReminder">
|
<view
|
||||||
|
v-if="showSubscribeEntry"
|
||||||
|
class="subscribe-entry"
|
||||||
|
@click="handleSubscribeReminder"
|
||||||
|
>
|
||||||
<text class="subscribe-entry-text">接收提醒</text>
|
<text class="subscribe-entry-text">接收提醒</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -68,7 +72,10 @@ import { mergeConversationWithGroupDetails } from "@/utils/conversation-merger.j
|
|||||||
import { globalUnreadListenerManager } from "@/utils/global-unread-listener.js";
|
import { globalUnreadListenerManager } from "@/utils/global-unread-listener.js";
|
||||||
import useGroupAvatars from "./hooks/use-group-avatars.js";
|
import useGroupAvatars from "./hooks/use-group-avatars.js";
|
||||||
import GroupAvatar from "@/components/group-avatar.vue";
|
import GroupAvatar from "@/components/group-avatar.vue";
|
||||||
import { requestConversationSubscribeMessage } from "@/utils/subscribe-message";
|
import {
|
||||||
|
checkConversationSubscribeEntryVisible,
|
||||||
|
requestConversationSubscribeMessage,
|
||||||
|
} from "@/utils/subscribe-message";
|
||||||
import {
|
import {
|
||||||
SUBSCRIBE_MESSAGE_ROLE,
|
SUBSCRIBE_MESSAGE_ROLE,
|
||||||
SUBSCRIBE_MESSAGE_SCENE,
|
SUBSCRIBE_MESSAGE_SCENE,
|
||||||
@ -86,6 +93,7 @@ const loading = ref(false);
|
|||||||
const loadingMore = ref(false);
|
const loadingMore = ref(false);
|
||||||
const hasMore = ref(false);
|
const hasMore = ref(false);
|
||||||
const refreshing = ref(false);
|
const refreshing = ref(false);
|
||||||
|
const showSubscribeEntry = ref(false);
|
||||||
|
|
||||||
// 群聊头像管理
|
// 群聊头像管理
|
||||||
const { loadGroupAvatars, getAvatarList } = useGroupAvatars();
|
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 () => {
|
onShow(async () => {
|
||||||
// 页面显示时刷新 tabBar 徽章
|
// 页面显示时刷新 tabBar 徽章
|
||||||
// if (globalUnreadListenerManager.isInitialized) {
|
// if (globalUnreadListenerManager.isInitialized) {
|
||||||
// await globalUnreadListenerManager.refreshBadge();
|
// await globalUnreadListenerManager.refreshBadge();
|
||||||
// }
|
// }
|
||||||
|
await loadSubscribeEntryState();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => teams.value.map((item) => item?.corpId).join(","),
|
||||||
|
() => {
|
||||||
|
loadSubscribeEntryState();
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
// 页面隐藏
|
// 页面隐藏
|
||||||
onHide(() => {
|
onHide(() => {
|
||||||
console.log("【消息列表页】页面隐藏");
|
console.log("【消息列表页】页面隐藏");
|
||||||
|
|||||||
@ -73,6 +73,7 @@ const urlsConfig = {
|
|||||||
createConsultGroup: "createConsultGroup",
|
createConsultGroup: "createConsultGroup",
|
||||||
cancelConsultApplication: "cancelConsultApplication",
|
cancelConsultApplication: "cancelConsultApplication",
|
||||||
getGroupList: "getGroupList",
|
getGroupList: "getGroupList",
|
||||||
|
getConversationSubscribeConfig: "getConversationSubscribeConfig",
|
||||||
saveConversationSubscribeResult: "saveConversationSubscribeResult",
|
saveConversationSubscribeResult: "saveConversationSubscribeResult",
|
||||||
sendConversationSubscribeEvent: "sendConversationSubscribeEvent"
|
sendConversationSubscribeEvent: "sendConversationSubscribeEvent"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -8,6 +8,7 @@ const SUBSCRIBE_BAN_STATUS = "ban";
|
|||||||
const SUBSCRIBE_FILTER_STATUS = "filter";
|
const SUBSCRIBE_FILTER_STATUS = "filter";
|
||||||
const SUBSCRIBE_CANCEL_STATUS = "cancel";
|
const SUBSCRIBE_CANCEL_STATUS = "cancel";
|
||||||
const SUBSCRIBE_FAILED_STATUS = "failed";
|
const SUBSCRIBE_FAILED_STATUS = "failed";
|
||||||
|
const subscribeDisplayConfigCache = new Map();
|
||||||
|
|
||||||
function canUseSubscribeMessage() {
|
function canUseSubscribeMessage() {
|
||||||
return (
|
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 = {}) {
|
export async function requestConversationSubscribeMessage(context = {}) {
|
||||||
const templates = resolveSubscribeTemplates({
|
const templates = resolveSubscribeTemplates({
|
||||||
role: context.role,
|
role: context.role,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user