import { defineStore } from 'pinia' import { api } from '@/api' export interface INotifyState { websocketId?: string // 预留 unreadCount: number // 未读消息数量 } export const useNotifyStore = defineStore('useNotifyStore', { state: (): INotifyState => { return { websocketId: undefined, unreadCount: 0, } }, actions: { UPDATE_UNREAD_COUNT(unreadCount: number) { this.unreadCount = unreadCount }, UPDATE_WEBSOCKET_ID(websocketId: string) { this.websocketId = websocketId }, async updateUnreadCount() { const res = await api.get('/api/Notify/UnReadedCount') this.UPDATE_UNREAD_COUNT(res.data.count) return res.data }, }, })