mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? feat(search): Optimized search functionality and user interface #3221 ### Type of change - Added similarity threshold adjustment function - Optimized mind map display logic - Adjusted search settings interface layout - Fixed related search and document viewing functions - Optimized time display and node selection logic - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -4,7 +4,7 @@ import { IReference, IReferenceChunk } from '@/interfaces/database/chat';
|
||||
import { getExtension } from '@/utils/document-util';
|
||||
import { InfoCircleOutlined } from '@ant-design/icons';
|
||||
import DOMPurify from 'dompurify';
|
||||
import { useCallback, useEffect, useMemo } from 'react';
|
||||
import { memo, useCallback, useEffect, useMemo } from 'react';
|
||||
import Markdown from 'react-markdown';
|
||||
import reactStringReplace from 'react-string-replace';
|
||||
import SyntaxHighlighter from 'react-syntax-highlighter';
|
||||
@ -82,18 +82,18 @@ const MarkdownContent = ({
|
||||
(
|
||||
documentId: string,
|
||||
chunk: IReferenceChunk,
|
||||
isPdf: boolean,
|
||||
documentUrl?: string,
|
||||
// isPdf: boolean,
|
||||
// documentUrl?: string,
|
||||
) =>
|
||||
() => {
|
||||
if (!isPdf) {
|
||||
if (!documentUrl) {
|
||||
return;
|
||||
}
|
||||
window.open(documentUrl, '_blank');
|
||||
} else {
|
||||
clickDocumentButton?.(documentId, chunk);
|
||||
}
|
||||
// if (!isPdf) {
|
||||
// if (!documentUrl) {
|
||||
// return;
|
||||
// }
|
||||
// window.open(documentUrl, '_blank');
|
||||
// } else {
|
||||
clickDocumentButton?.(documentId, chunk);
|
||||
// }
|
||||
},
|
||||
[clickDocumentButton],
|
||||
);
|
||||
@ -144,7 +144,6 @@ const MarkdownContent = ({
|
||||
const getPopoverContent = useCallback(
|
||||
(chunkIndex: number) => {
|
||||
const {
|
||||
documentUrl,
|
||||
fileThumbnail,
|
||||
fileExtension,
|
||||
imageId,
|
||||
@ -198,8 +197,8 @@ const MarkdownContent = ({
|
||||
onClick={handleDocumentButtonClick(
|
||||
documentId,
|
||||
chunkItem,
|
||||
fileExtension === 'pdf',
|
||||
documentUrl,
|
||||
// fileExtension === 'pdf',
|
||||
// documentUrl,
|
||||
)}
|
||||
>
|
||||
{document?.doc_name}
|
||||
@ -218,8 +217,7 @@ const MarkdownContent = ({
|
||||
let replacedText = reactStringReplace(text, currentReg, (match, i) => {
|
||||
const chunkIndex = getChunkIndex(match);
|
||||
|
||||
const { documentUrl, fileExtension, imageId, chunkItem, documentId } =
|
||||
getReferenceInfo(chunkIndex);
|
||||
const { imageId, chunkItem, documentId } = getReferenceInfo(chunkIndex);
|
||||
|
||||
const docType = chunkItem?.doc_type;
|
||||
|
||||
@ -232,8 +230,8 @@ const MarkdownContent = ({
|
||||
? handleDocumentButtonClick(
|
||||
documentId,
|
||||
chunkItem,
|
||||
fileExtension === 'pdf',
|
||||
documentUrl,
|
||||
// fileExtension === 'pdf',
|
||||
// documentUrl,
|
||||
)
|
||||
: () => {}
|
||||
}
|
||||
@ -243,7 +241,9 @@ const MarkdownContent = ({
|
||||
<PopoverTrigger>
|
||||
<InfoCircleOutlined className={styles.referenceIcon} />
|
||||
</PopoverTrigger>
|
||||
<PopoverContent>{getPopoverContent(chunkIndex)}</PopoverContent>
|
||||
<PopoverContent className="!w-fit">
|
||||
{getPopoverContent(chunkIndex)}
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
);
|
||||
});
|
||||
@ -292,4 +292,4 @@ const MarkdownContent = ({
|
||||
);
|
||||
};
|
||||
|
||||
export default MarkdownContent;
|
||||
export default memo(MarkdownContent);
|
||||
|
||||
Reference in New Issue
Block a user