feat: 接入聊天历史界面与外链会话恢复

- 新增管理端与用户端聊天历史接口和页面

- 外链聊天支持访问令牌登录、身份保活与当前会话恢复

- 聊天执行链路切到统一 runtime 与 chatlog 查询接口
This commit is contained in:
2026-04-05 11:37:25 +08:00
parent 25e80433a5
commit a4f75a5e4c
48 changed files with 3724 additions and 972 deletions

View File

@@ -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;
}
}