Selaa lähdekoodia

feat: When the mindmap data is empty, it will not be displayed on the search page #2247 (#2414)

### What problem does this PR solve?

feat: When the mindmap data is empty, it will not be displayed on the
search page #2247
### Type of change

- [ ] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)
tags/v0.11.0
balibabu 1 vuosi sitten
vanhempi
commit
ec4def9a44
No account linked to committer's email address

+ 1
- 0
web/src/interfaces/database/knowledge.ts Näytä tiedosto

vector_similarity: number; vector_similarity: number;
highlight: string; highlight: string;
positions: number[][]; positions: number[][];
docnm_kwd: string;
} }


export interface ITestingDocument { export interface ITestingDocument {

+ 3
- 1
web/src/pages/search/index.less Näytä tiedosto

background-size: cover; background-size: cover;
.card { .card {
width: 100%; width: 100%;
cursor: pointer;
:global(.ant-card-body) { :global(.ant-card-body) {
padding: 14px; padding: 14px;
} }
font-style: normal; font-style: normal;
} }
} }
.documentReference {
cursor: pointer;
}
} }
.answerWrapper { .answerWrapper {
margin-top: 16px; margin-top: 16px;

+ 45
- 38
web/src/pages/search/index.tsx Näytä tiedosto

import FileIcon from '@/components/file-icon';
import HightLightMarkdown from '@/components/highlight-markdown'; import HightLightMarkdown from '@/components/highlight-markdown';
import { ImageWithPopover } from '@/components/image'; import { ImageWithPopover } from '@/components/image';
import IndentedTree from '@/components/indented-tree/indented-tree'; import IndentedTree from '@/components/indented-tree/indented-tree';
sendingLoading, sendingLoading,
relatedQuestions, relatedQuestions,
mindMap, mindMap,
mindMapLoading,
searchStr, searchStr,
loading, loading,
isFirstRender, isFirstRender,


const isMindMapEmpty = useMemo(() => { const isMindMapEmpty = useMemo(() => {
return ( return (
!mindMapLoading &&
((Array.isArray(mindMap?.children) && mindMap.children.length === 0) ||
!Array.isArray(mindMap?.children))
(Array.isArray(mindMap?.children) && mindMap.children.length === 0) ||
!Array.isArray(mindMap?.children)
); );
}, [mindMap, mindMapLoading]);
}, [mindMap]);


const InputSearch = ( const InputSearch = (
<Search <Search
className={styles.chunks} className={styles.chunks}
renderItem={(item) => ( renderItem={(item) => (
<List.Item> <List.Item>
<Card
className={styles.card}
onClick={() =>
clickDocumentButton(item.doc_id, item as any)
}
>
<Card className={styles.card}>
<Space> <Space>
<ImageWithPopover <ImageWithPopover
id={item.img_id} id={item.img_id}
></ImageWithPopover> ></ImageWithPopover>
<Popover
content={
<div className={styles.popupMarkdown}>
<HightLightMarkdown>
{item.content_with_weight}
</HightLightMarkdown>
</div>
}
>
<div
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(
item.highlight,
),
}}
className={styles.highlightContent}
></div>
</Popover>
<Flex vertical gap={10}>
<Popover
content={
<div className={styles.popupMarkdown}>
<HightLightMarkdown>
{item.content_with_weight}
</HightLightMarkdown>
</div>
}
>
<div
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(
`${item.highlight}...`,
),
}}
className={styles.highlightContent}
></div>
</Popover>
<Space
className={styles.documentReference}
onClick={() =>
clickDocumentButton(
item.doc_id,
item as any,
)
}
>
<FileIcon
id={item.img_id}
name={item.docnm_kwd}
></FileIcon>
{item.docnm_kwd}
</Space>
</Flex>
</Space> </Space>
</Card> </Card>
</List.Item> </List.Item>
<section <section
className={isMindMapEmpty ? styles.hide : styles.graph} className={isMindMapEmpty ? styles.hide : styles.graph}
> >
{mindMapLoading ? (
<Skeleton active />
) : (
<IndentedTree
data={mindMap}
show
style={{ width: '100%', height: '100%' }}
></IndentedTree>
)}
<IndentedTree
data={mindMap}
show
style={{ width: '100%', height: '100%' }}
></IndentedTree>
</section> </section>
</Flex> </Flex>
)} )}

Loading…
Peruuta
Tallenna