瀏覽代碼

Fix: Fixed the issue where message references could not be displayed (#7691)

### What problem does this PR solve?

Fix: Fixed the issue where message references could not be displayed

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
tags/v0.19.0
balibabu 5 月之前
父節點
當前提交
d73a08b9eb
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 9 行新增8 行删除
  1. 9
    8
      web/src/pages/chat/markdown-content/index.tsx

+ 9
- 8
web/src/pages/chat/markdown-content/index.tsx 查看文件

const fileThumbnail = documentId ? fileThumbnails[documentId] : ''; const fileThumbnail = documentId ? fileThumbnails[documentId] : '';
const fileExtension = documentId ? getExtension(document?.doc_name) : ''; const fileExtension = documentId ? getExtension(document?.doc_name) : '';
const imageId = chunkItem?.image_id; const imageId = chunkItem?.image_id;
const docType = chunkItem?.doc_type;

return showImage(docType) ? (
<Image id={imageId} className={styles.referenceChunkImage}></Image>
) : null;


return ( return (
<div key={chunkItem?.id} className="flex gap-2"> <div key={chunkItem?.id} className="flex gap-2">
const renderReference = useCallback( const renderReference = useCallback(
(text: string) => { (text: string) => {
let replacedText = reactStringReplace(text, reg, (match, i) => { let replacedText = reactStringReplace(text, reg, (match, i) => {
const chunks = reference?.chunks ?? [];
const chunkIndex = getChunkIndex(match); const chunkIndex = getChunkIndex(match);
return getPopoverContent(chunkIndex);
return (
const chunkItem = chunks[chunkIndex];
const imageId = chunkItem?.image_id;
const docType = chunkItem?.doc_type;

return showImage(docType) ? (
<Image id={imageId} className={styles.referenceChunkImage}></Image>
) : (
<Popover content={getPopoverContent(chunkIndex)} key={i}> <Popover content={getPopoverContent(chunkIndex)} key={i}>
<InfoCircleOutlined className={styles.referenceIcon} /> <InfoCircleOutlined className={styles.referenceIcon} />
</Popover> </Popover>


return replacedText; return replacedText;
}, },
[getPopoverContent],
[getPopoverContent, reference?.chunks],
); );


return ( return (

Loading…
取消
儲存