You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
564 B
25 lines
564 B
2 years ago
|
import { defineStore } from 'pinia'
|
||
|
import { getUnreadNotifyMessageCount } from '@/api/system/notify/message'
|
||
|
|
||
|
type MessageState = {
|
||
|
unreadCount: number // 未读消息数量
|
||
|
}
|
||
|
|
||
|
export const useUserMessageStore = defineStore('userMessage', {
|
||
|
state: (): MessageState => ({
|
||
|
unreadCount: 0
|
||
|
}),
|
||
|
getters: {
|
||
|
getUnreadCount(state) {
|
||
|
return state.unreadCount
|
||
|
}
|
||
|
},
|
||
|
actions: {
|
||
|
// 更新未读消息的数量
|
||
|
async updateUnreadCount() {
|
||
|
const count = await getUnreadNotifyMessageCount()
|
||
|
this.unreadCount = count
|
||
|
}
|
||
|
}
|
||
|
})
|