添加红点
This commit is contained in:
40
src/services/messageService.ts
Normal file
40
src/services/messageService.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import httpService, { ApiResponse } from './httpService';
|
||||
|
||||
// 红点信息响应接口
|
||||
export interface ReddotInfo {
|
||||
comment_unread_count: number; // 评论/回复未读数量
|
||||
follow_unread_count: number; // 新增关注未读数量
|
||||
total_unread_count: number; // 总未读数量
|
||||
has_reddot: boolean; // 是否显示红点
|
||||
}
|
||||
|
||||
// 标记已读类型
|
||||
export type MarkAsReadType = 'comment' | 'follow' | 'all';
|
||||
|
||||
// 标记已读响应
|
||||
export interface MarkAsReadResponse {
|
||||
updated_count: number;
|
||||
detail: {
|
||||
comment_count: number;
|
||||
follow_count: number;
|
||||
};
|
||||
message: string;
|
||||
}
|
||||
|
||||
class MessageService {
|
||||
// 获取红点信息
|
||||
async getReddotInfo(): Promise<ApiResponse<ReddotInfo>> {
|
||||
return httpService.post('/message/reddot_info', {}, { showLoading: false });
|
||||
}
|
||||
|
||||
// 标记消息已读
|
||||
async markAsRead(type: MarkAsReadType, ids?: number[]): Promise<ApiResponse<MarkAsReadResponse>> {
|
||||
const data: { type: MarkAsReadType; ids?: number[] } = { type };
|
||||
if (ids && ids.length > 0) {
|
||||
data.ids = ids;
|
||||
}
|
||||
return httpService.post('/message/mark_as_read', data, { showLoading: false });
|
||||
}
|
||||
}
|
||||
|
||||
export default new MessageService();
|
||||
Reference in New Issue
Block a user