feat: clear session only

This commit is contained in:
AprilNEA
2023-04-02 13:42:47 +08:00
parent c93a46a02f
commit 506cdbc83c
2 changed files with 13 additions and 5 deletions

View File

@@ -177,6 +177,7 @@ interface ChatStore {
config: ChatConfig;
sessions: ChatSession[];
currentSessionIndex: number;
clearSessions: () => void;
removeSession: (index: number) => void;
selectSession: (index: number) => void;
newSession: () => void;
@@ -211,6 +212,13 @@ export const useChatStore = create<ChatStore>()(
...DEFAULT_CONFIG,
},
clearSessions(){
set(() => ({
sessions: [createEmptySession()],
currentSessionIndex: 0,
}));
},
resetConfig() {
set(() => ({ config: { ...DEFAULT_CONFIG } }));
},