feat: 聊天页暗夜模式

This commit is contained in:
archer
2023-03-20 21:34:12 +08:00
parent 3aeb510f43
commit dc467c26b5
11 changed files with 76 additions and 61 deletions

View File

@@ -9,6 +9,7 @@ type Props = {
pushChatHistory: (e: HistoryItem) => void;
updateChatHistory: (chatId: string, title: string) => void;
removeChatHistoryByWindowId: (chatId: string) => void;
clearHistory: () => void;
generateChatWindow: (modelId: string) => Promise<string>;
};
export const useChatStore = create<Props>()(
@@ -18,7 +19,7 @@ export const useChatStore = create<Props>()(
chatHistory: [],
pushChatHistory(item: HistoryItem) {
set((state) => {
state.chatHistory = [item, ...state.chatHistory];
state.chatHistory = [item, ...state.chatHistory].slice(0, 20);
});
},
updateChatHistory(chatId: string, title: string) {
@@ -34,6 +35,11 @@ export const useChatStore = create<Props>()(
state.chatHistory = state.chatHistory.filter((item) => item.chatId !== chatId);
});
},
clearHistory() {
set((state) => {
state.chatHistory = [];
});
},
generateChatWindow(modelId: string) {
return getChatSiteId(modelId);
}