kongdeqiang
2026-10-09 f55d84f8479f35f780c535d2d4f4836727363255
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import http from './axios'
 
/** 会话列表 */
export function listChats() {
  return http.get('/chats')
}
 
/**
 * 搜索历史对话。
 *
 * 后端同时匹配标题与消息内容,返回的每一项带:
 *   - matchSnippet:命中处的上下文片段
 *   - matchType:title / message / both
 */
export function searchChats(keyword, limit = 30) {
  return http.get('/chats/search', { params: { q: keyword, limit } })
}
 
/** 新建会话 */
export function createChat(payload = {}) {
  return http.post('/chats', payload)
}
 
/**
 * 修改会话标题或模型参数。
 * meta 是整体覆盖语义,请提交完整的参数对象。
 */
export function updateChat(chatId, payload) {
  return http.put(`/chats/${chatId}`, payload)
}
 
/** 删除会话(级联删除消息) */
export function deleteChat(chatId) {
  return http.delete(`/chats/${chatId}`)
}
 
/** 获取会话的消息树(根节点数组,节点内嵌 children) */
export function listMessages(chatId) {
  return http.get(`/chats/${chatId}/messages`)
}
 
/** 编辑消息内容 */
export function updateMessage(chatId, messageId, payload) {
  return http.put(`/chats/${chatId}/messages/${messageId}`, payload)
}
 
/** 删除消息及其全部子孙 */
export function deleteMessage(chatId, messageId) {
  return http.delete(`/chats/${chatId}/messages/${messageId}`)
}