mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-01-03 11:05:30 +08:00
feat: delete the added model #503 and display an error message when the requested file fails to parse #684 (#708)
### What problem does this PR solve? feat: delete the added model #503 feat: display an error message when the requested file fails to parse #684 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
import { ExceptiveType, Images } from '@/constants/common';
|
||||
import { Images } from '@/constants/common';
|
||||
import { api_host } from '@/utils/api';
|
||||
import { Flex, Image } from 'antd';
|
||||
import FileViewer from 'react-file-viewer';
|
||||
import { useParams, useSearchParams } from 'umi';
|
||||
import Docx from './docx';
|
||||
import Excel from './excel';
|
||||
import Pdf from './pdf';
|
||||
|
||||
@ -10,18 +10,12 @@ import styles from './index.less';
|
||||
|
||||
// TODO: The interface returns an incorrect content-type for the SVG.
|
||||
|
||||
const isNotExceptiveType = (ext: string) => ExceptiveType.indexOf(ext) === -1;
|
||||
|
||||
const DocumentViewer = () => {
|
||||
const { id: documentId } = useParams();
|
||||
const api = `${api_host}/file/get/${documentId}`;
|
||||
const [currentQueryParameters] = useSearchParams();
|
||||
const ext = currentQueryParameters.get('ext');
|
||||
|
||||
const onError = (e: any) => {
|
||||
console.error(e, 'error in file-viewer');
|
||||
};
|
||||
|
||||
return (
|
||||
<section className={styles.viewerWrapper}>
|
||||
{Images.includes(ext!) && (
|
||||
@ -31,9 +25,8 @@ const DocumentViewer = () => {
|
||||
)}
|
||||
{ext === 'pdf' && <Pdf url={api}></Pdf>}
|
||||
{(ext === 'xlsx' || ext === 'xls') && <Excel filePath={api}></Excel>}
|
||||
{isNotExceptiveType(ext!) && (
|
||||
<FileViewer fileType={ext} filePath={api} onError={onError} />
|
||||
)}
|
||||
|
||||
{ext === 'docx' && <Docx filePath={api}></Docx>}
|
||||
</section>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user