fix: 修复消息中心已读计数更新问题

This commit is contained in:
秋帆
2025-04-13 22:21:11 +08:00
parent 070484f53f
commit 50cd13e2e5
2 changed files with 12 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
<template> <template>
<GiTable <GiTable
v-model:selectedKeys="selectedKeys" v-model:selected-keys="selectedKeys"
row-key="id" row-key="id"
:data="dataList" :data="dataList"
:columns="columns" :columns="columns"
@@ -62,6 +62,7 @@ import { Message, Modal } from '@arco-design/web-vue'
import { type MessageQuery, deleteMessage, listMessage, readAllMessage, readMessage } from '@/apis' import { type MessageQuery, deleteMessage, listMessage, readAllMessage, readMessage } from '@/apis'
import { useTable } from '@/hooks' import { useTable } from '@/hooks'
import { useDict } from '@/hooks/app' import { useDict } from '@/hooks/app'
import mittBus from '@/utils/mitt'
defineOptions({ name: 'SystemMessage' }) defineOptions({ name: 'SystemMessage' })
@@ -70,7 +71,10 @@ const { message_type } = useDict('message_type')
const queryForm = reactive<MessageQuery>({ const queryForm = reactive<MessageQuery>({
sort: ['createTime,desc'], sort: ['createTime,desc'],
}) })
// 表格更新回调
const onSuccess = () => {
mittBus.emit('count-refresh')
}
const { const {
tableData: dataList, tableData: dataList,
loading, loading,
@@ -80,7 +84,7 @@ const {
selectAll, selectAll,
search, search,
handleDelete, handleDelete,
} = useTable((page) => listMessage({ ...queryForm, ...page }), { immediate: true }) } = useTable((page) => listMessage({ ...queryForm, ...page }), { immediate: true, onSuccess })
const columns: TableInstance['columns'] = [ const columns: TableInstance['columns'] = [
{ {

View File

@@ -30,6 +30,7 @@ import MyMessage from './components/MyMessage.vue'
import MyNotice from './components/MyNotice.vue' import MyNotice from './components/MyNotice.vue'
import { useDevice } from '@/hooks' import { useDevice } from '@/hooks'
import { type MessageResp, type NoticeResp, listMessage, listNotice } from '@/apis' import { type MessageResp, type NoticeResp, listMessage, listNotice } from '@/apis'
import mittBus from '@/utils/mitt'
defineOptions({ name: 'UserMessage' }) defineOptions({ name: 'UserMessage' })
@@ -84,6 +85,9 @@ const getNoticeData = async () => {
onMounted(() => { onMounted(() => {
getMessageData() getMessageData()
getNoticeData() getNoticeData()
mittBus.on('count-refresh', () => {
getMessageData()
})
}) })
const menuList = [ const menuList = [