feat: show unread message count

This commit is contained in:
Tim
2025-07-07 19:26:38 +08:00
parent 60b789759a
commit 87d0441ef6
7 changed files with 94 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
import { API_BASE_URL } from '../main'
import { getToken } from './auth'
export async function fetchUnreadCount() {
try {
const token = getToken()
if (!token) return 0
const res = await fetch(`${API_BASE_URL}/api/notifications/unread-count`, {
headers: { Authorization: `Bearer ${token}` }
})
if (!res.ok) return 0
const data = await res.json()
return data.count
} catch (e) {
return 0
}
}