fix: align mail statistics dashboard

This commit is contained in:
zxyszx
2026-08-03 00:16:03 +08:00
parent 92ff7dbfaf
commit a8170dfe4d
6 changed files with 481 additions and 40 deletions
+20 -1
View File
@@ -124,7 +124,26 @@ export type MailRuleCondition = { field?: MailRuleConditionField; operator?: Mai
export type MailRuleAction = { type: "archive" | "trash" | "star" | "mark-read" | "label" | "move" | "forward"; value?: string; labelId?: string }
export type MailRule = { id: string; mailboxId: string; name: string; matchMode: "all" | "any"; conditions: MailRuleCondition[]; actions: MailRuleAction[]; applyToExisting: boolean; stopProcessing: boolean; fromContains: string; subjectContains: string; action: "archive" | "trash" | "star" | "mark-read" | "label" | "move" | "forward"; enabled: boolean; createdAt: string; appliedExistingCount?: number }
export type BlockedSender = { id: string; mailboxId: string; email: string; reason: string; createdAt: string }
export type MailStats = { totalMessages: number; unreadMessages: number; starredMessages: number; attachmentCount: number; attachmentBytes: number; storageBytes: number; quotaBytes: number; quotaUsedPct: number; byFolder: { folder: string; role: string; count: number; unread: number; bytes: number }[] }
export type MailStats = {
totalMessages: number
totalIncoming: number
totalOutgoing: number
unreadMessages: number
todayOutgoing: number
draftMessages: number
failedSends: number
starredMessages: number
attachmentCount: number
attachmentBytes: number
storageBytes: number
quotaBytes: number
quotaUsedPct: number
averageMessageBytes: number
byFolder: { folder: string; role: string; count: number; unread: number; bytes: number }[]
trend: { date: string; incoming: number; outgoing: number }[]
distribution: { key: string; label: string; count: number }[]
topContacts: { email: string; count: number }[]
}
export type ForwardingVerifiedEmail = {
id: string
email: string
+7 -1
View File
@@ -99,7 +99,13 @@ export const api = {
blockedSenders: () => request<ListResponse<BlockedSender>>("/api/me/blocked-senders"),
createBlockedSender: (payload: { mailboxId: string; email: string; reason: string }) => request<BlockedSender>("/api/me/blocked-senders", { method: "POST", body: JSON.stringify(payload) }),
deleteBlockedSender: (id: string) => request<{ ok: boolean }>(`/api/me/blocked-senders/${id}`, { method: "DELETE" }),
mailStats: (mailboxId?: string) => request<MailStats>(`/api/me/stats${mailboxId ? `?mailboxId=${encodeURIComponent(mailboxId)}` : ""}`),
mailStats: (mailboxId?: string, days?: number) => {
const query = new URLSearchParams()
if (mailboxId) query.set("mailboxId", mailboxId)
if (days) query.set("days", String(days))
const suffix = query.toString()
return request<MailStats>(`/api/me/stats${suffix ? `?${suffix}` : ""}`)
},
cleanupMail: (payload: { mailboxId: string; target: "empty-trash" | "empty-spam" | "archive-read-inbox" }) => request<{ ok: boolean; affected: number }>("/api/me/cleanup", { method: "POST", body: JSON.stringify(payload) }),
mailboxApplyOptions: () => request<MailboxApplyOptions>("/api/me/mailbox-apply-options"),
applyMailbox: (payload: { domainId: string; localPart: string; displayName: string }) => request<Mailbox>("/api/me/mailboxes/apply", { method: "POST", body: JSON.stringify(payload) }),