first commit
This commit is contained in:
20
src/renderer/http/api.js
Normal file
20
src/renderer/http/api.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { getAction, postAction, deleteAction } from './manage.js'
|
||||
import url, { getBaseUrl } from './url.js'
|
||||
|
||||
// 健康检查
|
||||
export const getHealthAction = () => getAction(url.health)
|
||||
|
||||
// 会话
|
||||
export const createSessionAction = (data) => postAction(url.session.create, data)
|
||||
export const getSessionAction = (id) => getAction(url.session.detail(id))
|
||||
export const listSessionsAction = () => getAction(url.session.list)
|
||||
export const deleteSessionAction = (id) => deleteAction(url.session.delete(id))
|
||||
|
||||
// 消息
|
||||
export const sendMessageAction = (sessionId, data) => postAction(url.message.send(sessionId), data)
|
||||
export const listMessagesAction = (sessionId) => getAction(url.message.list(sessionId))
|
||||
|
||||
// SSE 事件流(返回 EventSource 实例,由调用方管理生命周期)
|
||||
export function createEventSource() {
|
||||
return new EventSource(`${getBaseUrl()}${url.event}`)
|
||||
}
|
||||
Reference in New Issue
Block a user