feat: 重构公告及消息,公告支持系统消息推送提醒、定时发布、置顶、记录读取状态

This commit is contained in:
2025-05-20 22:37:06 +08:00
parent feef35f541
commit abf3f13041
19 changed files with 316 additions and 151 deletions

View File

@@ -29,7 +29,10 @@ import { useRoute, useRouter } from 'vue-router'
import MyMessage from './components/MyMessage.vue'
import MyNotice from './components/MyNotice.vue'
import { useDevice } from '@/hooks'
import { type MessageResp, type NoticeResp, listMessage, listNotice } from '@/apis'
import {
getUnreadMessageCount,
getUnreadNoticeCount,
} from '@/apis'
import mittBus from '@/utils/mitt'
defineOptions({ name: 'UserMessage' })
@@ -51,35 +54,22 @@ const TabPaneTitle = defineComponent({
const { isDesktop } = useDevice()
const messageList = ref<MessageResp[]>()
const noticeList = ref<NoticeResp[]>()
const unreadMessageCount = ref(0)
const unreadNoticeCount = ref(0)
const tabItems = computed(() => [
{ key: 'msg', title: '我的消息', count: messageList.value?.length ?? 0 },
{ key: 'notice', title: '我的公告' },
{ key: 'msg', title: '我的消息', count: unreadMessageCount },
{ key: 'notice', title: '我的公告', count: unreadNoticeCount },
])
const messageQueryParam = reactive({
isRead: false,
sort: ['createTime,desc'],
page: 1,
size: 5,
})
const noticeQueryParam = reactive({
sort: ['createTime,desc'],
page: 1,
size: 5,
})
const getMessageData = async () => {
const { data } = await listMessage(messageQueryParam)
messageList.value = data.list.filter((item) => !item.isRead)
const { data } = await getUnreadMessageCount()
unreadMessageCount.value = data.total
}
const getNoticeData = async () => {
const { data } = await listNotice(noticeQueryParam)
noticeList.value = data.list
const { data } = await getUnreadNoticeCount()
unreadNoticeCount.value = data.total
}
onMounted(() => {