feat: 接入聊天历史界面与外链会话恢复
- 新增管理端与用户端聊天历史接口和页面 - 外链聊天支持访问令牌登录、身份保活与当前会话恢复 - 聊天执行链路切到统一 runtime 与 chatlog 查询接口
This commit is contained in:
@@ -148,6 +148,7 @@ export const api = createRequestClient(apiURL, {
|
||||
export const baseRequestClient = new RequestClient({ baseURL: apiURL });
|
||||
|
||||
export interface SseOptions {
|
||||
headers?: HeadersInit;
|
||||
onMessage?: (message: ServerSentEventMessage) => void;
|
||||
onError?: (err: any) => void;
|
||||
onFinished?: () => void;
|
||||
@@ -186,7 +187,7 @@ export class SseClient {
|
||||
const res = await fetch(apiURL + url, {
|
||||
method: 'POST',
|
||||
signal, // 使用局部变量 signal
|
||||
headers: this.getHeaders(),
|
||||
headers: this.getHeaders(options?.headers),
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
|
||||
@@ -233,13 +234,20 @@ export class SseClient {
|
||||
}
|
||||
}
|
||||
|
||||
private getHeaders() {
|
||||
private getHeaders(extraHeaders?: HeadersInit) {
|
||||
const accessStore = useAccessStore();
|
||||
return {
|
||||
const headers: Record<string, string> = {
|
||||
Accept: 'text/event-stream',
|
||||
'Content-Type': 'application/json',
|
||||
'easyflow-token': accessStore.accessToken || '',
|
||||
};
|
||||
if (!extraHeaders) {
|
||||
return headers;
|
||||
}
|
||||
new Headers(extraHeaders).forEach((value, key) => {
|
||||
headers[key] = value;
|
||||
});
|
||||
return headers;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user