balibabu
commited on
Commit
·
52a51dc
1
Parent(s):
189ed3a
feat: Modify the style of the answer card on the search page #2247 (#2412)
Browse files### What problem does this PR solve?
feat: Modify the style of the answer card on the search page #2247
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
web/src/components/highlight-markdown/index.tsx
CHANGED
@@ -8,16 +8,14 @@ import styles from './index.less';
|
|
8 |
|
9 |
const HightLightMarkdown = ({
|
10 |
children,
|
11 |
-
className,
|
12 |
}: {
|
13 |
children: string | null | undefined;
|
14 |
-
className?: string;
|
15 |
}) => {
|
16 |
return (
|
17 |
<Markdown
|
18 |
remarkPlugins={[remarkGfm]}
|
19 |
rehypePlugins={[rehypeRaw]}
|
20 |
-
className={classNames(styles.text
|
21 |
components={
|
22 |
{
|
23 |
code(props: any) {
|
|
|
8 |
|
9 |
const HightLightMarkdown = ({
|
10 |
children,
|
|
|
11 |
}: {
|
12 |
children: string | null | undefined;
|
|
|
13 |
}) => {
|
14 |
return (
|
15 |
<Markdown
|
16 |
remarkPlugins={[remarkGfm]}
|
17 |
rehypePlugins={[rehypeRaw]}
|
18 |
+
className={classNames(styles.text)}
|
19 |
components={
|
20 |
{
|
21 |
code(props: any) {
|
web/src/locales/en.ts
CHANGED
@@ -432,6 +432,7 @@ The above is the content you need to summarize.`,
|
|
432 |
ttsTip:
|
433 |
'To play the voice using voice conversion, please select TTS (speech conversion model) in the settings first.',
|
434 |
relatedQuestion: 'Related question',
|
|
|
435 |
},
|
436 |
setting: {
|
437 |
profile: 'Profile',
|
|
|
432 |
ttsTip:
|
433 |
'To play the voice using voice conversion, please select TTS (speech conversion model) in the settings first.',
|
434 |
relatedQuestion: 'Related question',
|
435 |
+
answerTitle: 'R',
|
436 |
},
|
437 |
setting: {
|
438 |
profile: 'Profile',
|
web/src/locales/zh-traditional.ts
CHANGED
@@ -401,6 +401,7 @@ export default {
|
|
401 |
tts: '文字轉語音',
|
402 |
ttsTip: '是否用語音轉換播放語音,請先在設定裡面選擇TTS(語音轉換模型)。',
|
403 |
relatedQuestion: '相關問題',
|
|
|
404 |
},
|
405 |
setting: {
|
406 |
profile: '概述',
|
|
|
401 |
tts: '文字轉語音',
|
402 |
ttsTip: '是否用語音轉換播放語音,請先在設定裡面選擇TTS(語音轉換模型)。',
|
403 |
relatedQuestion: '相關問題',
|
404 |
+
answerTitle: '智慧回答',
|
405 |
},
|
406 |
setting: {
|
407 |
profile: '概述',
|
web/src/locales/zh.ts
CHANGED
@@ -418,6 +418,7 @@ export default {
|
|
418 |
tts: '文本转语音',
|
419 |
ttsTip: '是否用语音转换播放语音,请先在设置里面选择TTS(语音转换模型)。',
|
420 |
relatedQuestion: '相关问题',
|
|
|
421 |
},
|
422 |
setting: {
|
423 |
profile: '概要',
|
|
|
418 |
tts: '文本转语音',
|
419 |
ttsTip: '是否用语音转换播放语音,请先在设置里面选择TTS(语音转换模型)。',
|
420 |
relatedQuestion: '相关问题',
|
421 |
+
answerTitle: '智能回答',
|
422 |
},
|
423 |
setting: {
|
424 |
profile: '概要',
|
web/src/pages/search/index.less
CHANGED
@@ -93,13 +93,23 @@
|
|
93 |
width: 40%;
|
94 |
padding: 20px 10px 10px;
|
95 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
97 |
.answerWrapper {
|
98 |
-
background-color: #e6f4ff;
|
99 |
-
padding: 14px;
|
100 |
margin-top: 16px;
|
101 |
-
|
102 |
-
|
|
|
|
|
|
|
|
|
103 |
margin: 0;
|
104 |
}
|
105 |
}
|
|
|
93 |
width: 40%;
|
94 |
padding: 20px 10px 10px;
|
95 |
}
|
96 |
+
|
97 |
+
.highlightContent {
|
98 |
+
.multipleLineEllipsis(2);
|
99 |
+
em {
|
100 |
+
color: red;
|
101 |
+
font-style: normal;
|
102 |
+
}
|
103 |
+
}
|
104 |
}
|
105 |
.answerWrapper {
|
|
|
|
|
106 |
margin-top: 16px;
|
107 |
+
background: rgb(232 242 251 / 70%);
|
108 |
+
box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.08);
|
109 |
+
:global(.ant-card-head) {
|
110 |
+
background-color: #e6f4ff;
|
111 |
+
}
|
112 |
+
& p {
|
113 |
margin: 0;
|
114 |
}
|
115 |
}
|
web/src/pages/search/index.tsx
CHANGED
@@ -25,13 +25,14 @@ import {
|
|
25 |
Spin,
|
26 |
Tag,
|
27 |
} from 'antd';
|
|
|
|
|
28 |
import { useMemo, useState } from 'react';
|
29 |
import { useTranslation } from 'react-i18next';
|
30 |
import MarkdownContent from '../chat/markdown-content';
|
31 |
import { useFetchBackgroundImage, useSendQuestion } from './hooks';
|
32 |
-
import SearchSidebar from './sidebar';
|
33 |
-
|
34 |
import styles from './index.less';
|
|
|
35 |
|
36 |
const { Content } = Layout;
|
37 |
const { Search } = Input;
|
@@ -123,16 +124,28 @@ const SearchPage = () => {
|
|
123 |
className={isMindMapEmpty ? styles.largeMain : styles.main}
|
124 |
>
|
125 |
{InputSearch}
|
126 |
-
|
127 |
-
|
128 |
-
<
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
<Divider></Divider>
|
137 |
<RetrievalDocuments
|
138 |
selectedDocumentIds={selectedDocumentIds}
|
@@ -166,11 +179,14 @@ const SearchPage = () => {
|
|
166 |
</div>
|
167 |
}
|
168 |
>
|
169 |
-
<div
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
|
|
|
|
|
|
174 |
</Popover>
|
175 |
</Space>
|
176 |
</Card>
|
|
|
25 |
Spin,
|
26 |
Tag,
|
27 |
} from 'antd';
|
28 |
+
import DOMPurify from 'dompurify';
|
29 |
+
import { isEmpty } from 'lodash';
|
30 |
import { useMemo, useState } from 'react';
|
31 |
import { useTranslation } from 'react-i18next';
|
32 |
import MarkdownContent from '../chat/markdown-content';
|
33 |
import { useFetchBackgroundImage, useSendQuestion } from './hooks';
|
|
|
|
|
34 |
import styles from './index.less';
|
35 |
+
import SearchSidebar from './sidebar';
|
36 |
|
37 |
const { Content } = Layout;
|
38 |
const { Search } = Input;
|
|
|
124 |
className={isMindMapEmpty ? styles.largeMain : styles.main}
|
125 |
>
|
126 |
{InputSearch}
|
127 |
+
<Card
|
128 |
+
title={
|
129 |
+
<Flex gap={10}>
|
130 |
+
<img src="/logo.svg" alt="" width={20} />
|
131 |
+
{t('chat.answerTitle')}
|
132 |
+
</Flex>
|
133 |
+
}
|
134 |
+
className={styles.answerWrapper}
|
135 |
+
>
|
136 |
+
{isEmpty(answer) && sendingLoading ? (
|
137 |
+
<Skeleton active />
|
138 |
+
) : (
|
139 |
+
answer.answer && (
|
140 |
+
<MarkdownContent
|
141 |
+
loading={sendingLoading}
|
142 |
+
content={answer.answer}
|
143 |
+
reference={answer.reference ?? ({} as IReference)}
|
144 |
+
clickDocumentButton={clickDocumentButton}
|
145 |
+
></MarkdownContent>
|
146 |
+
)
|
147 |
+
)}
|
148 |
+
</Card>
|
149 |
<Divider></Divider>
|
150 |
<RetrievalDocuments
|
151 |
selectedDocumentIds={selectedDocumentIds}
|
|
|
179 |
</div>
|
180 |
}
|
181 |
>
|
182 |
+
<div
|
183 |
+
dangerouslySetInnerHTML={{
|
184 |
+
__html: DOMPurify.sanitize(
|
185 |
+
item.highlight,
|
186 |
+
),
|
187 |
+
}}
|
188 |
+
className={styles.highlightContent}
|
189 |
+
></div>
|
190 |
</Popover>
|
191 |
</Space>
|
192 |
</Card>
|