mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-16 05:53:42 +08:00
feat: 优化聊天窗口,使支持复制会话
This commit is contained in:
@@ -208,6 +208,28 @@ export const useChatStore = createPersistStore(
|
||||
});
|
||||
},
|
||||
|
||||
copySession() {
|
||||
set((state) => {
|
||||
const { sessions, currentSessionIndex } = state;
|
||||
const emptySession = createEmptySession();
|
||||
|
||||
// copy the session
|
||||
const curSession = JSON.parse(
|
||||
JSON.stringify(sessions[currentSessionIndex]),
|
||||
);
|
||||
curSession.id = emptySession.id;
|
||||
curSession.lastUpdate = emptySession.lastUpdate;
|
||||
|
||||
const newSessions = [...sessions];
|
||||
newSessions.splice(0, 0, curSession);
|
||||
|
||||
return {
|
||||
currentSessionIndex: 0,
|
||||
sessions: newSessions,
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
moveSession(from: number, to: number) {
|
||||
set((state) => {
|
||||
const { sessions, currentSessionIndex: oldIndex } = state;
|
||||
|
||||
Reference in New Issue
Block a user