fix share link chat quote number (#4690)

* fix share link chat quote number

* fix ts

* usememo
This commit is contained in:
heheer
2025-04-28 10:33:33 +08:00
committed by GitHub
parent d6fed3d23a
commit cc01aa4ab8
12 changed files with 39 additions and 8 deletions

View File

@@ -251,6 +251,7 @@ const ChatItem = (props: Props) => {
chatId: chatId,
chatItemDataId: chat.dataId,
collectionId: collectionId,
collectionIdList,
sourceId: sourceId || '',
sourceName: sourceName || '',
datasetId: datasetId || '',
@@ -272,11 +273,12 @@ const ChatItem = (props: Props) => {
);
useEffect(() => {
if (chat.obj !== ChatRoleEnum.AI) return;
eventBus.on(EventNameEnum.openQuoteReader, handleOpenQuoteReader);
return () => {
eventBus.off(EventNameEnum.openQuoteReader);
};
}, [handleOpenQuoteReader]);
}, [chat.obj, handleOpenQuoteReader]);
return (
<Box

View File

@@ -29,6 +29,8 @@ import { useTranslation } from 'next-i18next';
import { eventBus, EventNameEnum } from '@/web/common/utils/eventbus';
import { SelectOptionsComponent, FormInputComponent } from './Interactive/InteractiveComponents';
import { extractDeepestInteractive } from '@fastgpt/global/core/workflow/runtime/utils';
import { useContextSelector } from 'use-context-selector';
import { ChatItemContext } from '@/web/core/chat/context/chatItemContext';
const accordionButtonStyle = {
w: 'auto',
@@ -88,9 +90,17 @@ const RenderText = React.memo(function RenderText({
text
}: {
showAnimation: boolean;
text?: string;
text: string;
}) {
let source = text || '';
const isResponseDetail = useContextSelector(ChatItemContext, (v) => v.isResponseDetail);
const source = useMemo(() => {
if (!text) return '';
// Remove quote references if not showing response detail
return isResponseDetail ? text : text.replace(/\[[a-f0-9]{24}\]\(QUOTE\)/g, '');
}, [text, isResponseDetail]);
// First empty line
// if (!source && !isLastChild) return null;