From 4bdab3560ed528cf9efa142703b75815f0a16b8a Mon Sep 17 00:00:00 2001 From: MyGit <3282299728@qq.com> Date: Thu, 11 Jul 2024 20:09:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BC=9A=E8=AF=9D=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=AE=9E=E6=97=B6=E5=B1=95=E7=A4=BA=EF=BC=8C=E7=AB=8B=E5=88=BB?= =?UTF-8?q?=E5=81=9C=E6=AD=A2=E5=87=BA=E7=8E=B0object?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bs-comp/chatComponent/ChatInput.tsx | 15 ++++++++------- .../bs-comp/chatComponent/MessageBs.tsx | 4 ++-- .../bs-comp/chatComponent/MessageUser.tsx | 8 ++++---- .../bs-comp/chatComponent/messageStore.ts | 14 +++++++------- src/frontend/src/pages/ChatAppPage/index.tsx | 12 +++++++----- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/frontend/src/components/bs-comp/chatComponent/ChatInput.tsx b/src/frontend/src/components/bs-comp/chatComponent/ChatInput.tsx index 6d52cfafb..7607d0114 100644 --- a/src/frontend/src/components/bs-comp/chatComponent/ChatInput.tsx +++ b/src/frontend/src/components/bs-comp/chatComponent/ChatInput.tsx @@ -1,15 +1,16 @@ +import { ClearIcon } from "@/components/bs-icons/clear"; import { FormIcon } from "@/components/bs-icons/form"; import { SendIcon } from "@/components/bs-icons/send"; +import { Button } from "@/components/bs-ui/button"; import { Textarea } from "@/components/bs-ui/input"; import { useToast } from "@/components/bs-ui/toast/use-toast"; import { locationContext } from "@/contexts/locationContext"; +import { PauseIcon } from "@radix-ui/react-icons"; import { useContext, useEffect, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; -import { useMessageStore } from "./messageStore"; import GuideQuestions from "./GuideQuestions"; -import { ClearIcon } from "@/components/bs-icons/clear"; -import { Button } from "@/components/bs-ui/button"; -import { PauseIcon, StopIcon } from "@radix-ui/react-icons"; +import { useMessageStore } from "./messageStore"; +import { formatDate } from "@/util/utils"; export default function ChatInput({ clear, form, stop, questions, inputForm, wsUrl, onBeforSend }) { const { toast } = useToast() @@ -198,6 +199,7 @@ export default function ChatInput({ clear, form, stop, questions, inputForm, wsU const handleWsMessage = (data) => { if (Array.isArray(data) && data.length) return if (data.type === 'start') { + setStoped(false) createWsMsg(data) } else if (data.type === 'stream') { //@ts-ignore @@ -213,13 +215,12 @@ export default function ChatInput({ clear, form, stop, questions, inputForm, wsU thought: data.intermediate_steps || '', messageId: data.message_id, noAccess: false, - liked: 0 + liked: 0, + update_time: formatDate(new Date(), 'yyyy-MM-ddTHH:mm:ss') }, data.type === 'end_cover') } else if (data.type === "close") { setStoped(true) setInputLock({ locked: false, reason: '' }) - } else if (data.type === 'begin') { - setStoped(false) } } diff --git a/src/frontend/src/components/bs-comp/chatComponent/MessageBs.tsx b/src/frontend/src/components/bs-comp/chatComponent/MessageBs.tsx index 67346538a..2899e453c 100644 --- a/src/frontend/src/components/bs-comp/chatComponent/MessageBs.tsx +++ b/src/frontend/src/components/bs-comp/chatComponent/MessageBs.tsx @@ -79,8 +79,8 @@ export default function MessageBs({ data, onUnlike = () => { }, onSource }: { da const chatId = useMessageStore(state => state.chatId) return
{data.sender}
} diff --git a/src/frontend/src/components/bs-comp/chatComponent/MessageUser.tsx b/src/frontend/src/components/bs-comp/chatComponent/MessageUser.tsx index 51ac9480d..81ef6c47f 100644 --- a/src/frontend/src/components/bs-comp/chatComponent/MessageUser.tsx +++ b/src/frontend/src/components/bs-comp/chatComponent/MessageUser.tsx @@ -1,9 +1,9 @@ import { locationContext } from "@/contexts/locationContext"; import { ChatMessageType } from "@/types/chat"; +import { formatStrTime } from "@/util/utils"; import { MagnifyingGlassIcon, Pencil2Icon, ReloadIcon } from "@radix-ui/react-icons"; -import { useContext, useState } from "react"; +import { useContext } from "react"; import { useMessageStore } from "./messageStore"; -import { formatStrTime } from "@/util/utils"; export default function MessageUser({ useName = 'xxx', data }: { data: ChatMessageType }) { const msg = data.message[data.chatKey] @@ -26,8 +26,8 @@ export default function MessageUser({ useName = 'xxx', data }: { data: ChatMessa } return{useName}
} diff --git a/src/frontend/src/components/bs-comp/chatComponent/messageStore.ts b/src/frontend/src/components/bs-comp/chatComponent/messageStore.ts index 61184ab2a..a0d0d3e00 100644 --- a/src/frontend/src/components/bs-comp/chatComponent/messageStore.ts +++ b/src/frontend/src/components/bs-comp/chatComponent/messageStore.ts @@ -1,9 +1,8 @@ -import { message } from '@/components/bs-ui/toast/use-toast'; -import { generateUUID } from '@/components/bs-ui/utils' -import { MessageDB, getChatHistory } from '@/controllers/API' -import { ChatMessageType } from '@/types/chat' -import { cloneDeep } from 'lodash' -import { create } from 'zustand' +import { getChatHistory } from '@/controllers/API'; +import { ChatMessageType } from '@/types/chat'; +import { cloneDeep } from 'lodash'; +import { create } from 'zustand'; +import { formatDate } from '@/util/utils'; /** * 会话消息管理 @@ -138,7 +137,8 @@ export const useMessageStore = create