站内信模块:我的站内信 vue3

This commit is contained in:
YunaiV
2023-01-29 18:31:52 +08:00
parent 91dd4a32b1
commit f7762e646e
9 changed files with 245 additions and 38 deletions

View File

@@ -4,18 +4,20 @@ import * as NotifyMessageApi from '@/api/system/notify/message'
const { push } = useRouter()
const activeName = ref('notice')
const count = ref(0) // 未读消息数量
const unreadCount = ref(0) // 未读消息数量
const list = ref([]) // 消息列表
// 获得消息列表
const getList = async () => {
list.value = await NotifyMessageApi.getUnreadNotifyMessageListApi()
// 强制设置 unreadCount 为 0避免小红点因为轮询太慢不消除
unreadCount.value = 0
}
// 获得未读消息数
const getUnreadCount = async () => {
NotifyMessageApi.getUnreadNotifyMessageCountApi().then((data) => {
count.value = data
unreadCount.value = data
})
}
@@ -40,7 +42,7 @@ onMounted(() => {
<div class="message">
<ElPopover placement="bottom" :width="400" trigger="click">
<template #reference>
<ElBadge :is-dot="count > 0" class="item">
<ElBadge :is-dot="unreadCount > 0" class="item">
<Icon icon="ep:bell" :size="18" class="cursor-pointer" @click="getList" />
</ElBadge>
</template>

View File

@@ -41,7 +41,7 @@ const loginOut = () => {
.catch(() => {})
}
const toProfile = async () => {
push('/userinfo/profile')
push('/user/profile')
}
const toDocument = () => {
window.open('https://doc.iocoder.cn/')