From 49cd2d7a3c72800ee5727578821d734c3941b203 Mon Sep 17 00:00:00 2001 From: papapatrick <109422393+Patrickill@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:47:18 +0800 Subject: [PATCH] add chatType (#3060) --- packages/global/common/string/time.ts | 4 ++-- .../core/chat/ChatContainer/ChatBox/Provider.tsx | 7 ++++--- .../chat/ChatContainer/ChatBox/components/ChatItem.tsx | 9 +++++---- .../pages/app/detail/components/Logs/DetailLogsModal.tsx | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/global/common/string/time.ts b/packages/global/common/string/time.ts index 2c0ecc4b3..51f6b2370 100644 --- a/packages/global/common/string/time.ts +++ b/packages/global/common/string/time.ts @@ -30,7 +30,7 @@ export const formatTimeToChatTime = (time: Date) => { // 如果时间是今天,展示几时:几分 //用#占位,i18n生效后replace成: if (now.isSame(target, 'day')) { - return 'common:' + target.format('HH#mm'); + return target.format('HH#mm'); } // 如果是昨天,展示昨天 @@ -54,7 +54,7 @@ export const formatTimeToChatItemTime = (time: Date) => { // 如果时间是今天,展示几时:几分 if (now.isSame(target, 'day')) { - return 'common:' + detailTime; + return detailTime; } // 如果是昨天,展示昨天+几时:几分 diff --git a/projects/app/src/components/core/chat/ChatContainer/ChatBox/Provider.tsx b/projects/app/src/components/core/chat/ChatContainer/ChatBox/Provider.tsx index 31b470974..57fbc6e0a 100644 --- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/Provider.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/Provider.tsx @@ -34,7 +34,7 @@ export type ChatProviderProps = OutLinkChatAuthProps & { // not chat test params chatId?: string; - isLog?: boolean; + chatType?: 'log' | 'chat'; }; type useChatStoreType = OutLinkChatAuthProps & @@ -138,7 +138,7 @@ const Provider = ({ chatHistories, setChatHistories, variablesForm, - + chatType = 'chat', chatConfig = {}, children, ...props @@ -240,7 +240,8 @@ const Provider = ({ chatInputGuide, outLinkAuthData, variablesForm, - getHistoryResponseData + getHistoryResponseData, + chatType }; return {children}; diff --git a/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/ChatItem.tsx b/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/ChatItem.tsx index 33d382418..8af57c663 100644 --- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/ChatItem.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/ChatItem.tsx @@ -137,8 +137,8 @@ const ChatItem = (props: Props) => { }; const { t } = useTranslation(); - const { isChatting, isLog } = useContextSelector(ChatBoxContext, (v) => { - return { isChatting: v.isChatting, isLog: v.isLog }; + const { isChatting, chatType } = useContextSelector(ChatBoxContext, (v) => { + return { isChatting: v.isChatting, chatType: v.chatType }; }); const { copyData } = useCopyData(); @@ -218,13 +218,14 @@ const ChatItem = (props: Props) => { {isChatting && type === ChatRoleEnum.AI && isLastChild ? null : ( - {chat.time && type === ChatRoleEnum.Human && (isPc || isLog) && ( + {chat.time && (isPc || chatType === 'log') && ( {t(formatTimeToChatItemTime(chat.time) as any, { time: dayjs(chat.time).format('HH:mm') diff --git a/projects/app/src/pages/app/detail/components/Logs/DetailLogsModal.tsx b/projects/app/src/pages/app/detail/components/Logs/DetailLogsModal.tsx index 763d4ba89..76ed968e3 100644 --- a/projects/app/src/pages/app/detail/components/Logs/DetailLogsModal.tsx +++ b/projects/app/src/pages/app/detail/components/Logs/DetailLogsModal.tsx @@ -180,7 +180,7 @@ const DetailLogsModal = ({ chatConfig={chat?.app?.chatConfig} appId={appId} chatId={chatId} - isLog={true} + chatType="log" /> )}