2025-06-17 22:37:37 +08:00
|
|
|
|
import type { ChatMessageVo, GetChatListParams, SendDTO } from './types';
|
2026-01-31 17:39:23 +08:00
|
|
|
|
import { del, get, post } from '@/utils/request';
|
|
|
|
|
|
|
|
|
|
|
|
// 删除消息接口
|
|
|
|
|
|
export interface DeleteMessageParams {
|
|
|
|
|
|
ids: (number | string)[];
|
|
|
|
|
|
isDeleteSubsequent?: boolean;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function deleteMessages(data: DeleteMessageParams) {
|
|
|
|
|
|
const idsQuery = data.ids.map(id => `ids=${encodeURIComponent(id)}`).join('&');
|
|
|
|
|
|
const subsequentQuery = data.isDeleteSubsequent !== undefined ? `isDeleteSubsequent=${data.isDeleteSubsequent}` : '';
|
|
|
|
|
|
const query = [idsQuery, subsequentQuery].filter(Boolean).join('&');
|
|
|
|
|
|
const url = `/message${query ? `?${query}` : ''}`;
|
|
|
|
|
|
return del<void>(url).json();
|
|
|
|
|
|
}
|
2025-06-17 22:37:37 +08:00
|
|
|
|
|
2026-01-11 00:15:31 +08:00
|
|
|
|
// 发送消息(旧接口)
|
2025-08-03 21:56:51 +08:00
|
|
|
|
export function send(data: SendDTO) {
|
|
|
|
|
|
const url = data.sessionId !== 'not_login'
|
|
|
|
|
|
? `/ai-chat/send/?sessionId=${data.sessionId}`
|
|
|
|
|
|
: '/ai-chat/send';
|
|
|
|
|
|
return post(url, data);
|
|
|
|
|
|
}
|
2025-06-17 22:37:37 +08:00
|
|
|
|
|
2026-01-11 00:15:31 +08:00
|
|
|
|
// 统一发送消息接口,支持4种API类型
|
|
|
|
|
|
export function unifiedSend(data: any, apiType: string, modelId: string, sessionId: string) {
|
|
|
|
|
|
const url = `/ai-chat/unified/send?apiType=${apiType}&modelId=${modelId}&sessionId=${sessionId}`;
|
|
|
|
|
|
return post(url, data);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-17 22:37:37 +08:00
|
|
|
|
// 新增对应会话聊天记录
|
|
|
|
|
|
export function addChat(data: ChatMessageVo) {
|
2025-06-28 23:07:32 +08:00
|
|
|
|
return post('/system/message', data).json();
|
2025-06-17 22:37:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前会话的聊天记录
|
|
|
|
|
|
export function getChatList(params: GetChatListParams) {
|
2025-06-21 22:12:21 +08:00
|
|
|
|
// return get<ChatMessageVo[]>('/system/message/list', params);
|
2025-06-28 23:07:32 +08:00
|
|
|
|
return get<ChatMessageVo[]>('/message', params).json();
|
2025-06-17 22:37:37 +08:00
|
|
|
|
}
|
2025-12-23 00:15:32 +08:00
|
|
|
|
|
|
|
|
|
|
// 新增对应会话聊天记录
|
|
|
|
|
|
export function aiChatTool() {
|
|
|
|
|
|
return post('/ai-chat/tool').json();
|
|
|
|
|
|
}
|