新增消息管理页面,整合消息API,支持消息列表展示、未读消息统计、消息标记为已读及删除功能,提升用户消息管理体验。

This commit is contained in:
zyh
2025-04-10 09:07:31 +00:00
parent 948cd5263e
commit d5c31777d2
4 changed files with 383 additions and 3 deletions

View File

@@ -3,7 +3,9 @@ import type { MinioUploadPolicy, OSSUploadPolicy } from '@d8d-appcontainer/types
import 'dayjs/locale/zh-cn';
import type {
User, FileLibrary, FileCategory, ThemeSettings,
SystemSetting, SystemSettingGroupData, LoginLocation, LoginLocationDetail
SystemSetting, SystemSettingGroupData,
LoginLocation, LoginLocationDetail,
Message, UserMessage
} from '../share/types.ts';
@@ -502,6 +504,90 @@ export const ChartAPI = {
}
};
// 消息API接口类型
interface MessagesResponse {
data: UserMessage[];
pagination: {
total: number;
current: number;
pageSize: number;
totalPages: number;
};
}
interface MessageResponse {
data: Message;
message?: string;
}
interface MessageCountResponse {
count: number;
}
// 消息API
export const MessageAPI = {
// 获取消息列表
getMessages: async (params?: {
page?: number,
pageSize?: number,
type?: string,
status?: string,
search?: string
}): Promise<MessagesResponse> => {
try {
const response = await axios.get(`${API_BASE_URL}/messages`, { params });
return response.data;
} catch (error) {
throw error;
}
},
// 发送消息
sendMessage: async (data: {
title: string,
content: string,
type: string,
receiver_ids: number[]
}): Promise<MessageResponse> => {
try {
const response = await axios.post(`${API_BASE_URL}/messages`, data);
return response.data;
} catch (error) {
throw error;
}
},
// 获取未读消息数
getUnreadCount: async (): Promise<MessageCountResponse> => {
try {
const response = await axios.get(`${API_BASE_URL}/messages/count/unread`);
return response.data;
} catch (error) {
throw error;
}
},
// 标记消息为已读
markAsRead: async (id: number): Promise<MessageResponse> => {
try {
const response = await axios.post(`${API_BASE_URL}/messages/${id}/read`);
return response.data;
} catch (error) {
throw error;
}
},
// 删除消息
deleteMessage: async (id: number): Promise<MessageResponse> => {
try {
const response = await axios.delete(`${API_BASE_URL}/messages/${id}`);
return response.data;
} catch (error) {
throw error;
}
}
};
// 地图相关API的接口类型定义
export interface LoginLocationResponse {
message: string;