add chatType (#3060)

This commit is contained in:
papapatrick 2024-11-04 13:47:18 +08:00 committed by archer
parent 727bd7144c
commit 49cd2d7a3c
No known key found for this signature in database
GPG Key ID: 4446499B846D4A9E
4 changed files with 12 additions and 10 deletions

View File

@ -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;
}
// 如果是昨天,展示昨天+几时:几分

View File

@ -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 <ChatBoxContext.Provider value={value}>{children}</ChatBoxContext.Provider>;

View File

@ -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) => {
<Flex w={'100%'} alignItems={'flex-end'} gap={2} justifyContent={styleMap.justifyContent}>
{isChatting && type === ChatRoleEnum.AI && isLastChild ? null : (
<Flex order={styleMap.order} ml={styleMap.ml} align={'center'} gap={'0.62rem'}>
{chat.time && type === ChatRoleEnum.Human && (isPc || isLog) && (
{chat.time && (isPc || chatType === 'log') && (
<Box
order={type === ChatRoleEnum.AI ? 2 : 0}
className={'time-label'}
fontSize={styleMap.fontSize}
color={styleMap.color}
fontWeight={styleMap.fontWeight}
display={isLog ? 'block' : 'none'}
display={chatType === 'log' ? 'block' : 'none'}
>
{t(formatTimeToChatItemTime(chat.time) as any, {
time: dayjs(chat.time).format('HH:mm')

View File

@ -180,7 +180,7 @@ const DetailLogsModal = ({
chatConfig={chat?.app?.chatConfig}
appId={appId}
chatId={chatId}
isLog={true}
chatType="log"
/>
)}
</Box>