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

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

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-21 18:02:43 +08:00
parent e7f1d777dd
commit caeeb9a1cf
18 changed files with 748 additions and 37 deletions

View File

@ -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(