mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-23 00:46:42 +08:00
Refactor: Remove ant design component (#13143)
### What problem does this PR solve? _Briefly describe what this PR aims to solve. Include background context that will help reviewers understand the purpose of the PR._ ### Type of change - [x] Refactoring
This commit is contained in:
@@ -165,3 +165,24 @@ export const useFetchDocx = (filePath: string) => {
|
||||
|
||||
return { succeed, containerRef, error };
|
||||
};
|
||||
|
||||
export const useCatchDocumentError = (url: string) => {
|
||||
const httpHeaders = useMemo(() => {
|
||||
return {
|
||||
[Authorization]: getAuthorization(),
|
||||
};
|
||||
}, []);
|
||||
const [error, setError] = useState<string>('');
|
||||
|
||||
const fetchDocument = useCallback(async () => {
|
||||
const { data } = await axios.get(url, { headers: httpHeaders });
|
||||
if (data.code !== 0) {
|
||||
setError(data?.message);
|
||||
}
|
||||
}, [url, httpHeaders]);
|
||||
useEffect(() => {
|
||||
fetchDocument();
|
||||
}, [fetchDocument]);
|
||||
|
||||
return error;
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@ import { Spin } from '@/components/ui/spin';
|
||||
import { Authorization } from '@/constants/authorization';
|
||||
import FileError from '@/pages/document-viewer/file-error';
|
||||
import { getAuthorization } from '@/utils/authorization-util';
|
||||
import { useCatchDocumentError } from '../pdf-previewer/hooks';
|
||||
import { useCatchDocumentError } from './hooks';
|
||||
import styles from './index.module.less';
|
||||
type PdfLoaderProps = React.ComponentProps<typeof PdfLoader> & {
|
||||
httpHeaders?: Record<string, string>;
|
||||
|
||||
Reference in New Issue
Block a user