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

@ -32,6 +32,46 @@ enum MessageJSONValue: Decodable, Hashable, Sendable {
}
}
///
struct MessageUnreadCountResponse: Decodable, Equatable, Sendable {
let unreadCount: Int
enum CodingKeys: String, CodingKey {
case unreadCount = "unread_count"
}
init(unreadCount: Int = 0) {
self.unreadCount = max(unreadCount, 0)
}
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
unreadCount = max(try container.decodeLossyInt(forKey: .unreadCount) ?? 0, 0)
}
}
///
struct MessageReadAllResponse: Decodable, Equatable, Sendable {
let updatedCount: Int
let unreadCount: Int
enum CodingKeys: String, CodingKey {
case updatedCount = "updated_count"
case unreadCount = "unread_count"
}
init(updatedCount: Int = 0, unreadCount: Int = 0) {
self.updatedCount = max(updatedCount, 0)
self.unreadCount = max(unreadCount, 0)
}
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
updatedCount = max(try container.decodeLossyInt(forKey: .updatedCount) ?? 0, 0)
unreadCount = max(try container.decodeLossyInt(forKey: .unreadCount) ?? 0, 0)
}
}
/// Android `MsgResponse`
struct MessageListResponse: Decodable, Equatable, Sendable {
let hasMore: Bool