mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-12-27 10:35:58 +08:00
在进行 socket 连接前先关闭之前连接。实现新建会话功能。
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
/* eslint-disable no-constant-condition */
|
||||
import {dateFormat} from "@/utils/libs";
|
||||
import Storage from 'good-storage'
|
||||
|
||||
/**
|
||||
* storage handler
|
||||
*/
|
||||
|
||||
const SessionUserKey = 'LOGIN_USER';
|
||||
export const Global = {}
|
||||
const ChatHistoryKey = "CHAT_HISTORY";
|
||||
|
||||
export function getSessionId() {
|
||||
const user = getLoginUser();
|
||||
@@ -35,4 +36,27 @@ export function getUserInfo() {
|
||||
return user;
|
||||
}
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
// 追加历史记录
|
||||
export function appendChatHistory(chatId, message) {
|
||||
let history = Storage.get(ChatHistoryKey);
|
||||
if (!history) {
|
||||
history = {};
|
||||
}
|
||||
if (!history[chatId]) {
|
||||
history[chatId] = [message];
|
||||
} else {
|
||||
history[chatId].push(message);
|
||||
}
|
||||
Storage.set(ChatHistoryKey, history);
|
||||
}
|
||||
|
||||
// 获取指定会话的历史记录
|
||||
export function getChatHistory(chatId) {
|
||||
const history = Storage.get(ChatHistoryKey);
|
||||
if (history && history[chatId]) {
|
||||
return history[chatId];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user