mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-14 05:36:01 +08:00
### What problem does this PR solve? feat: Catching errors with IndentedTree #2247 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
333608a1d4
commit
6000c3e304
12
web/package-lock.json
generated
12
web/package-lock.json
generated
@ -31,6 +31,7 @@
|
|||||||
"openai-speech-stream-player": "^1.0.8",
|
"openai-speech-stream-player": "^1.0.8",
|
||||||
"rc-tween-one": "^3.0.6",
|
"rc-tween-one": "^3.0.6",
|
||||||
"react-copy-to-clipboard": "^5.1.0",
|
"react-copy-to-clipboard": "^5.1.0",
|
||||||
|
"react-error-boundary": "^4.0.13",
|
||||||
"react-force-graph": "^1.44.4",
|
"react-force-graph": "^1.44.4",
|
||||||
"react-i18next": "^14.0.0",
|
"react-i18next": "^14.0.0",
|
||||||
"react-markdown": "^9.0.1",
|
"react-markdown": "^9.0.1",
|
||||||
@ -23119,6 +23120,17 @@
|
|||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/react-error-boundary": {
|
||||||
|
"version": "4.0.13",
|
||||||
|
"resolved": "https://registry.npmmirror.com/react-error-boundary/-/react-error-boundary-4.0.13.tgz",
|
||||||
|
"integrity": "sha512-b6PwbdSv8XeOSYvjt8LpgpKrZ0yGdtZokYwkwV2wlcZbxgopHX/hgPl5VgpnoVOWd868n1hktM8Qm4b+02MiLQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/runtime": "^7.12.5"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": ">=16.13.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/react-error-overlay": {
|
"node_modules/react-error-overlay": {
|
||||||
"version": "6.0.9",
|
"version": "6.0.9",
|
||||||
"resolved": "https://registry.npmmirror.com/react-error-overlay/-/react-error-overlay-6.0.9.tgz",
|
"resolved": "https://registry.npmmirror.com/react-error-overlay/-/react-error-overlay-6.0.9.tgz",
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
"openai-speech-stream-player": "^1.0.8",
|
"openai-speech-stream-player": "^1.0.8",
|
||||||
"rc-tween-one": "^3.0.6",
|
"rc-tween-one": "^3.0.6",
|
||||||
"react-copy-to-clipboard": "^5.1.0",
|
"react-copy-to-clipboard": "^5.1.0",
|
||||||
|
"react-error-boundary": "^4.0.13",
|
||||||
"react-force-graph": "^1.44.4",
|
"react-force-graph": "^1.44.4",
|
||||||
"react-i18next": "^14.0.0",
|
"react-i18next": "^14.0.0",
|
||||||
"react-markdown": "^9.0.1",
|
"react-markdown": "^9.0.1",
|
||||||
|
@ -17,6 +17,7 @@ import {
|
|||||||
import { TreeData } from '@antv/g6/lib/types';
|
import { TreeData } from '@antv/g6/lib/types';
|
||||||
import isEmpty from 'lodash/isEmpty';
|
import isEmpty from 'lodash/isEmpty';
|
||||||
import React, { useCallback, useEffect, useRef } from 'react';
|
import React, { useCallback, useEffect, useRef } from 'react';
|
||||||
|
import { ErrorBoundary, FallbackProps } from 'react-error-boundary';
|
||||||
|
|
||||||
const rootId = 'root';
|
const rootId = 'root';
|
||||||
|
|
||||||
@ -297,6 +298,17 @@ interface IProps {
|
|||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fallbackRender({ error }: FallbackProps) {
|
||||||
|
// Call resetErrorBoundary() to reset the error boundary and retry the render.
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div role="alert">
|
||||||
|
<p>Something went wrong:</p>
|
||||||
|
<pre style={{ color: 'red' }}>{error.message}</pre>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const IndentedTree = ({ data, show, style = {} }: IProps) => {
|
const IndentedTree = ({ data, show, style = {} }: IProps) => {
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const graphRef = useRef<Graph | null>(null);
|
const graphRef = useRef<Graph | null>(null);
|
||||||
@ -382,16 +394,18 @@ const IndentedTree = ({ data, show, style = {} }: IProps) => {
|
|||||||
}, [render, data]);
|
}, [render, data]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<ErrorBoundary fallbackRender={fallbackRender}>
|
||||||
id="tree"
|
<div
|
||||||
ref={containerRef}
|
id="tree"
|
||||||
style={{
|
ref={containerRef}
|
||||||
width: '90vw',
|
style={{
|
||||||
height: '80vh',
|
width: '90vw',
|
||||||
display: show ? 'block' : 'none',
|
height: '80vh',
|
||||||
...style,
|
display: show ? 'block' : 'none',
|
||||||
}}
|
...style,
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
</ErrorBoundary>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -494,7 +494,7 @@ export const useFetchMindMap = () => {
|
|||||||
mutationFn: async (params: IAskRequestBody) => {
|
mutationFn: async (params: IAskRequestBody) => {
|
||||||
try {
|
try {
|
||||||
const ret = await chatService.getMindMap(params);
|
const ret = await chatService.getMindMap(params);
|
||||||
return ret?.data?.data ?? [];
|
return ret?.data?.data ?? {};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (has(error, 'message')) {
|
if (has(error, 'message')) {
|
||||||
message.error(error.message);
|
message.error(error.message);
|
||||||
|
@ -57,15 +57,22 @@
|
|||||||
|
|
||||||
.content {
|
.content {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
.main {
|
.hide {
|
||||||
width: 60%;
|
display: none;
|
||||||
// background-color: aqua;
|
}
|
||||||
|
|
||||||
|
.mainMixin() {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
padding: 20px 10px 10px;
|
padding: 20px 10px 10px;
|
||||||
.chunks {
|
}
|
||||||
// overflow: auto;
|
|
||||||
// height: 60vh;
|
.largeMain {
|
||||||
}
|
width: 100%;
|
||||||
|
.mainMixin();
|
||||||
|
}
|
||||||
|
.main {
|
||||||
|
width: 60%;
|
||||||
|
.mainMixin();
|
||||||
}
|
}
|
||||||
|
|
||||||
.graph {
|
.graph {
|
||||||
@ -111,6 +118,9 @@
|
|||||||
}
|
}
|
||||||
.partialInput {
|
.partialInput {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 1;
|
||||||
.input();
|
.input();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import {
|
|||||||
Space,
|
Space,
|
||||||
Tag,
|
Tag,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import { useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import MarkdownContent from '../chat/markdown-content';
|
import MarkdownContent from '../chat/markdown-content';
|
||||||
import { useFetchBackgroundImage, useSendQuestion } from './hooks';
|
import { useFetchBackgroundImage, useSendQuestion } from './hooks';
|
||||||
@ -35,7 +35,6 @@ const SearchPage = () => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [checkedList, setCheckedList] = useState<string[]>([]);
|
const [checkedList, setCheckedList] = useState<string[]>([]);
|
||||||
const { chunks, total } = useSelectTestingResult();
|
const { chunks, total } = useSelectTestingResult();
|
||||||
// const appConf = useFetchAppConf();
|
|
||||||
const {
|
const {
|
||||||
sendQuestion,
|
sendQuestion,
|
||||||
handleClickRelatedQuestion,
|
handleClickRelatedQuestion,
|
||||||
@ -62,6 +61,14 @@ const SearchPage = () => {
|
|||||||
handleTestChunk(selectedDocumentIds, pageNumber, pageSize);
|
handleTestChunk(selectedDocumentIds, pageNumber, pageSize);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isMindMapEmpty = useMemo(() => {
|
||||||
|
return (
|
||||||
|
!mindMapLoading &&
|
||||||
|
((Array.isArray(mindMap?.children) && mindMap.children.length === 0) ||
|
||||||
|
!Array.isArray(mindMap?.children))
|
||||||
|
);
|
||||||
|
}, [mindMap, mindMapLoading]);
|
||||||
|
|
||||||
const InputSearch = (
|
const InputSearch = (
|
||||||
<Search
|
<Search
|
||||||
value={searchStr}
|
value={searchStr}
|
||||||
@ -103,7 +110,9 @@ const SearchPage = () => {
|
|||||||
</Flex>
|
</Flex>
|
||||||
) : (
|
) : (
|
||||||
<Flex className={styles.content}>
|
<Flex className={styles.content}>
|
||||||
<section className={styles.main}>
|
<section
|
||||||
|
className={isMindMapEmpty ? styles.largeMain : styles.main}
|
||||||
|
>
|
||||||
{InputSearch}
|
{InputSearch}
|
||||||
{answer.answer && (
|
{answer.answer && (
|
||||||
<div className={styles.answerWrapper}>
|
<div className={styles.answerWrapper}>
|
||||||
@ -165,7 +174,9 @@ const SearchPage = () => {
|
|||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
<section className={styles.graph}>
|
<section
|
||||||
|
className={isMindMapEmpty ? styles.hide : styles.graph}
|
||||||
|
>
|
||||||
{mindMapLoading ? (
|
{mindMapLoading ? (
|
||||||
<Skeleton active />
|
<Skeleton active />
|
||||||
) : (
|
) : (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user