feat: 接入消息未读数、全部已读与首页红点角标同步。

固定消息中心为首页入口,并在推送到达、已读后刷新桌面角标。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-21 18:02:43 +08:00
co-authored by Cursor
parent e7f1d777dd
commit caeeb9a1cf
18 changed files with 748 additions and 37 deletions
@@ -11,8 +11,14 @@ protocol MessageCenterServing {
/// 拉取消息列表。
func list(lastId: Int, limit: Int, unread: Int) async throws -> MessageListResponse
/// 标记消息已读。
func markAsRead(messageId: Int) async throws
/// 获取当前账号未读消息总数。
func unreadCount() async throws -> MessageUnreadCountResponse
/// 标记消息已读并返回最新未读数量。
func markAsRead(messageId: Int) async throws -> MessageUnreadCountResponse
/// 将当前账号全部消息标记已读。
func markAllAsRead() async throws -> MessageReadAllResponse
/// 删除消息。
func delete(messageId: Int) async throws
@@ -43,9 +49,16 @@ final class MessageCenterAPI: MessageCenterServing {
)
}
/// GET /api/app/msg/unread-count
func unreadCount() async throws -> MessageUnreadCountResponse {
try await client.send(
APIRequest(method: .get, path: "/api/app/msg/unread-count")
)
}
/// POST /api/app/msg/read
func markAsRead(messageId: Int) async throws {
let _: EmptyPayload = try await client.send(
func markAsRead(messageId: Int) async throws -> MessageUnreadCountResponse {
try await client.send(
APIRequest(
method: .post,
path: "/api/app/msg/read",
@@ -54,6 +67,13 @@ final class MessageCenterAPI: MessageCenterServing {
)
}
/// POST /api/app/msg/read-all
func markAllAsRead() async throws -> MessageReadAllResponse {
try await client.send(
APIRequest(method: .post, path: "/api/app/msg/read-all")
)
}
/// POST /api/app/msg/delete
func delete(messageId: Int) async throws {
let _: EmptyPayload = try await client.send(