实现消息记录功能,包括增删改查和标记已读,优化消息列表展示和未读消息计数
This commit is contained in:
20
Web/src/stores/message.js
Normal file
20
Web/src/stores/message.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { ref } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import { getUnreadCount } from '@/api/message'
|
||||
|
||||
export const useMessageStore = defineStore('message', () => {
|
||||
const unreadCount = ref(0)
|
||||
|
||||
const updateUnreadCount = async () => {
|
||||
try {
|
||||
const res = await getUnreadCount()
|
||||
if (res.success) {
|
||||
unreadCount.value = res.data
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取未读消息数量失败', error)
|
||||
}
|
||||
}
|
||||
|
||||
return { unreadCount, updateUnreadCount }
|
||||
})
|
||||
Reference in New Issue
Block a user