diff --git a/src/stores/FormStore.js b/src/stores/FormStore.js index 7fef332..e303415 100644 --- a/src/stores/FormStore.js +++ b/src/stores/FormStore.js @@ -7,7 +7,10 @@ import { devtools } from 'zustand/middleware'; import { WS_URL } from '@/config'; export const useFormStore = create(devtools((set, get) => ({ - chatHistory: {}, - setChatHistory: (chatHistory) => set({ chatHistory }), + // 历史记录页面 + chatHistoryForm: {}, + setChatHistoryForm: (chatHistoryForm) => set({ chatHistoryForm, chatHistorySelectChat: {} }), + chatHistorySelectChat: {}, + setChatHistorySelectChat: (chatHistorySelectChat) => set({ chatHistorySelectChat }), }))); export default useFormStore; diff --git a/src/views/ChatHistory.jsx b/src/views/ChatHistory.jsx index 4cfcfa1..84dc708 100644 --- a/src/views/ChatHistory.jsx +++ b/src/views/ChatHistory.jsx @@ -188,10 +188,8 @@ const SearchForm = memo(function ({ initialValues, onSubmit }) { function ChatHistory() { // const [formValues, setFormValues] = useState({}); - const [formValues, setFormValues] = useFormStore( - useShallow((state) => [state.chatHistory, state.setChatHistory]), - ) - + const [formValues, setFormValues] = useFormStore(useShallow((state) => [state.chatHistoryForm, state.setChatHistoryForm])); + const [selectedConversation, setSelectedConversation] = useFormStore(useShallow((state) => [state.chatHistorySelectChat, state.setChatHistorySelectChat])); const handleSubmit = useCallback((values) => { setFormValues({ ...values }); @@ -199,7 +197,6 @@ function ChatHistory() { const [loading, setLoading] = useState(false); const [conversationsList, setConversationsList] = useState([]); - const [selectedConversation, setSelectedConversation] = useState({}); const [chatItemMessages, setChatItemMessages] = useState([]); const getConversationsList = async () => { setLoading(true);