This commit is contained in:
‘Liammcl’
2025-02-08 01:21:43 +08:00
parent 12bda4ab8f
commit fa91bdee65
2 changed files with 3 additions and 3 deletions

View File

@@ -108,7 +108,7 @@ export default function DifyChatDrawer({ open, onClose, onExport }) {
> >
<div className="flex flex-col h-[calc(100vh-108px)]"> <div className="flex flex-col h-[calc(100vh-108px)]">
<div className="flex-1 overflow-y-auto px-4 space-y-6"> <div className="flex-1 overflow-y-auto px-4 space-y-6">
{messages.map((message) => ( {messages.length > 0 && messages.map((message) => (
<div <div
key={message.id} key={message.id}
className={`rounded-lg p-4 transition-all ${ className={`rounded-lg p-4 transition-all ${

View File

@@ -9,7 +9,7 @@ const STORAGE_KEY = 'dify_chat_history';
const CONVERSATION_ID_KEY = 'dify_conversation_id'; const CONVERSATION_ID_KEY = 'dify_conversation_id';
export function useDifyChat() { export function useDifyChat() {
const [storedMessages, setStoredMessages] = useSessionStorage(STORAGE_KEY, '[]'); const [storedMessages, setStoredMessages] = useSessionStorage(STORAGE_KEY, []);
const [conversationId, setConversationId] = useSessionStorage(CONVERSATION_ID_KEY, ''); const [conversationId, setConversationId] = useSessionStorage(CONVERSATION_ID_KEY, '');
const [messages, setMessages] = useState([]); const [messages, setMessages] = useState([]);
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
@@ -18,7 +18,7 @@ export function useDifyChat() {
const clearHistory = () => { const clearHistory = () => {
setMessages([]); setMessages([]);
setStoredMessages('[]'); setStoredMessages([]);
setConversationId(''); setConversationId('');
message.success('历史记录已清空'); message.success('历史记录已清空');
}; };