feat(admin): 新增通知中心与推送通知页
This commit is contained in:
@@ -120,6 +120,9 @@ import type {
|
||||
AdminQrCodePayload,
|
||||
AdminQrCodeStats,
|
||||
AdminQrCodeUpdatePayload,
|
||||
AdminNotificationPage,
|
||||
AdminPushChannel,
|
||||
AdminPushRule,
|
||||
ManualDisbursementPayload,
|
||||
OperatingExpensePage,
|
||||
OperatingExpensePayload,
|
||||
@@ -1704,5 +1707,92 @@ export async function deleteAdminQrCode(id: number) {
|
||||
await adminClient.delete(`/admin/chats/qrcodes/${id}`)
|
||||
}
|
||||
|
||||
export async function fetchAdminNotifications(query: {
|
||||
read?: string
|
||||
page?: number
|
||||
page_size?: number
|
||||
}) {
|
||||
const { data } = await adminClient.get<ApiResponse<Partial<AdminNotificationPage>>>(
|
||||
'/admin/notifications',
|
||||
{ params: compactParams(query) }
|
||||
)
|
||||
return {
|
||||
items: data.data.items ?? [],
|
||||
total: data.data.total ?? 0,
|
||||
page: data.data.page ?? query.page ?? 1,
|
||||
page_size: data.data.page_size ?? query.page_size ?? 20,
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchAdminNotificationUnreadCount() {
|
||||
const { data } = await adminClient.get<ApiResponse<{ unread_count: number }>>(
|
||||
'/admin/notifications/unread-count'
|
||||
)
|
||||
return data.data.unread_count ?? 0
|
||||
}
|
||||
|
||||
export async function markAdminNotificationRead(id: number) {
|
||||
await adminClient.post(`/admin/notifications/${id}/read`)
|
||||
}
|
||||
|
||||
export async function markAllAdminNotificationsRead() {
|
||||
await adminClient.put('/admin/notifications/read-all')
|
||||
}
|
||||
|
||||
export async function fetchPushChannels() {
|
||||
const { data } = await adminClient.get<ApiResponse<AdminPushChannel[]>>('/admin/push-channels')
|
||||
return data.data ?? []
|
||||
}
|
||||
|
||||
export async function createPushChannel(payload: {
|
||||
name: string
|
||||
type: string
|
||||
config: Record<string, unknown>
|
||||
}) {
|
||||
const { data } = await adminClient.post<ApiResponse<AdminPushChannel>>(
|
||||
'/admin/push-channels',
|
||||
payload
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function updatePushChannel(
|
||||
id: number,
|
||||
payload: { name?: string; config?: Record<string, unknown>; enabled?: boolean }
|
||||
) {
|
||||
const { data } = await adminClient.put<ApiResponse<AdminPushChannel>>(
|
||||
`/admin/push-channels/${id}`,
|
||||
payload
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function deletePushChannel(id: number) {
|
||||
await adminClient.delete(`/admin/push-channels/${id}`)
|
||||
}
|
||||
|
||||
export async function testPushChannel(id: number) {
|
||||
const { data } = await adminClient.post<ApiResponse<{ sent: boolean; message?: string }>>(
|
||||
`/admin/push-channels/${id}/test`
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function fetchPushRules() {
|
||||
const { data } = await adminClient.get<ApiResponse<AdminPushRule[]>>('/admin/push-rules')
|
||||
return data.data ?? []
|
||||
}
|
||||
|
||||
export async function updatePushRule(
|
||||
id: number,
|
||||
payload: { enabled?: boolean; threshold?: number; message_template?: string }
|
||||
) {
|
||||
const { data } = await adminClient.put<ApiResponse<AdminPushRule>>(
|
||||
`/admin/push-rules/${id}`,
|
||||
payload
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user