### What problem does this PR solve? feat: Wrap the searched chunk with a Popover #2247 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
cfae63d107
commit
db0606e064
@ -1,3 +1,4 @@
|
|||||||
|
import classNames from 'classnames';
|
||||||
import Markdown from 'react-markdown';
|
import Markdown from 'react-markdown';
|
||||||
import SyntaxHighlighter from 'react-syntax-highlighter';
|
import SyntaxHighlighter from 'react-syntax-highlighter';
|
||||||
import rehypeRaw from 'rehype-raw';
|
import rehypeRaw from 'rehype-raw';
|
||||||
@ -7,14 +8,16 @@ import styles from './index.less';
|
|||||||
|
|
||||||
const HightLightMarkdown = ({
|
const HightLightMarkdown = ({
|
||||||
children,
|
children,
|
||||||
|
className,
|
||||||
}: {
|
}: {
|
||||||
children: string | null | undefined;
|
children: string | null | undefined;
|
||||||
|
className?: string;
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<Markdown
|
<Markdown
|
||||||
remarkPlugins={[remarkGfm]}
|
remarkPlugins={[remarkGfm]}
|
||||||
rehypePlugins={[rehypeRaw]}
|
rehypePlugins={[rehypeRaw]}
|
||||||
className={styles.text}
|
className={classNames(styles.text, className)}
|
||||||
components={
|
components={
|
||||||
{
|
{
|
||||||
code(props: any) {
|
code(props: any) {
|
||||||
|
|||||||
@ -1,5 +1,10 @@
|
|||||||
|
.primitiveImg {
|
||||||
|
display: inline-block;
|
||||||
|
max-height: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
.image {
|
.image {
|
||||||
width: 100px;
|
max-width: 100px;
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { api_host } from '@/utils/api';
|
import { api_host } from '@/utils/api';
|
||||||
import { Popover } from 'antd';
|
import { Popover } from 'antd';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ const Image = ({ id, className, ...props }: IImage) => {
|
|||||||
{...props}
|
{...props}
|
||||||
src={`${api_host}/document/image/${id}`}
|
src={`${api_host}/document/image/${id}`}
|
||||||
alt=""
|
alt=""
|
||||||
className={className}
|
className={classNames(styles.primitiveImg, className)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -431,6 +431,7 @@ The above is the content you need to summarize.`,
|
|||||||
tts: 'Text to speech',
|
tts: 'Text to speech',
|
||||||
ttsTip:
|
ttsTip:
|
||||||
'To play the voice using voice conversion, please select TTS (speech conversion model) in the settings first.',
|
'To play the voice using voice conversion, please select TTS (speech conversion model) in the settings first.',
|
||||||
|
relatedQuestion: 'Related question',
|
||||||
},
|
},
|
||||||
setting: {
|
setting: {
|
||||||
profile: 'Profile',
|
profile: 'Profile',
|
||||||
|
|||||||
@ -400,6 +400,7 @@ export default {
|
|||||||
read: '朗讀內容',
|
read: '朗讀內容',
|
||||||
tts: '文字轉語音',
|
tts: '文字轉語音',
|
||||||
ttsTip: '是否用語音轉換播放語音,請先在設定裡面選擇TTS(語音轉換模型)。',
|
ttsTip: '是否用語音轉換播放語音,請先在設定裡面選擇TTS(語音轉換模型)。',
|
||||||
|
relatedQuestion: '相關問題',
|
||||||
},
|
},
|
||||||
setting: {
|
setting: {
|
||||||
profile: '概述',
|
profile: '概述',
|
||||||
@ -832,7 +833,7 @@ export default {
|
|||||||
wenCai: '問財',
|
wenCai: '問財',
|
||||||
queryType: '查詢類型',
|
queryType: '查詢類型',
|
||||||
wenCaiDescription:
|
wenCaiDescription:
|
||||||
'該組件可用於獲取廣泛的金融領域的信息,包括但不限於股票、基金等...',
|
'該組件可用於獲取廣泛的金融領域的o息,包括但不限於股票、基金等...',
|
||||||
wenCaiQueryTypeOptions: {
|
wenCaiQueryTypeOptions: {
|
||||||
stock: '股票',
|
stock: '股票',
|
||||||
zhishu: '指數',
|
zhishu: '指數',
|
||||||
|
|||||||
@ -417,6 +417,7 @@ export default {
|
|||||||
read: '朗读内容',
|
read: '朗读内容',
|
||||||
tts: '文本转语音',
|
tts: '文本转语音',
|
||||||
ttsTip: '是否用语音转换播放语音,请先在设置里面选择TTS(语音转换模型)。',
|
ttsTip: '是否用语音转换播放语音,请先在设置里面选择TTS(语音转换模型)。',
|
||||||
|
relatedQuestion: '相关问题',
|
||||||
},
|
},
|
||||||
setting: {
|
setting: {
|
||||||
profile: '概要',
|
profile: '概要',
|
||||||
|
|||||||
@ -168,3 +168,9 @@
|
|||||||
background-position: 200% center;
|
background-position: 200% center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.popupMarkdown {
|
||||||
|
width: 60vw;
|
||||||
|
max-height: 40vh;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import {
|
|||||||
List,
|
List,
|
||||||
Pagination,
|
Pagination,
|
||||||
PaginationProps,
|
PaginationProps,
|
||||||
|
Popover,
|
||||||
Skeleton,
|
Skeleton,
|
||||||
Space,
|
Space,
|
||||||
Tag,
|
Tag,
|
||||||
@ -150,9 +151,21 @@ const SearchPage = () => {
|
|||||||
<ImageWithPopover
|
<ImageWithPopover
|
||||||
id={item.img_id}
|
id={item.img_id}
|
||||||
></ImageWithPopover>
|
></ImageWithPopover>
|
||||||
<HightLightMarkdown>
|
<Popover
|
||||||
{item.highlight}
|
content={
|
||||||
</HightLightMarkdown>
|
<div className={styles.popupMarkdown}>
|
||||||
|
<HightLightMarkdown>
|
||||||
|
{item.content_with_weight}
|
||||||
|
</HightLightMarkdown>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<HightLightMarkdown>
|
||||||
|
{item.highlight}
|
||||||
|
</HightLightMarkdown>
|
||||||
|
</div>
|
||||||
|
</Popover>
|
||||||
</Space>
|
</Space>
|
||||||
</Card>
|
</Card>
|
||||||
</List.Item>
|
</List.Item>
|
||||||
@ -160,7 +173,7 @@ const SearchPage = () => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{relatedQuestions?.length > 0 && (
|
{relatedQuestions?.length > 0 && (
|
||||||
<Card>
|
<Card title={t('chat.relatedQuestion')}>
|
||||||
<Flex wrap="wrap" gap={'10px 0'}>
|
<Flex wrap="wrap" gap={'10px 0'}>
|
||||||
{relatedQuestions?.map((x, idx) => (
|
{relatedQuestions?.map((x, idx) => (
|
||||||
<Tag
|
<Tag
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user