mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
feat: support DeepSeek (#667)
### What problem does this PR solve? #666 feat: support DeepSeek feat: preview word and excel ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
35
web/src/pages/document-viewer/excel/index.tsx
Normal file
35
web/src/pages/document-viewer/excel/index.tsx
Normal file
@ -0,0 +1,35 @@
|
||||
import jsPreviewExcel from '@js-preview/excel';
|
||||
import '@js-preview/excel/lib/index.css';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
const Excel = ({ filePath }: { filePath: string }) => {
|
||||
const fetchDocument = async () => {
|
||||
const myExcelPreviewer = jsPreviewExcel.init(
|
||||
document.getElementById('excel'),
|
||||
);
|
||||
const jsonFile = new XMLHttpRequest();
|
||||
jsonFile.open('GET', filePath, true);
|
||||
jsonFile.send();
|
||||
jsonFile.responseType = 'arraybuffer';
|
||||
jsonFile.onreadystatechange = () => {
|
||||
if (jsonFile.readyState === 4 && jsonFile.status === 200) {
|
||||
myExcelPreviewer
|
||||
.preview(jsonFile.response)
|
||||
.then((res: any) => {
|
||||
console.log('succeed');
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log('failed', e);
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchDocument();
|
||||
}, []);
|
||||
|
||||
return <div id="excel" style={{ height: '100%' }}></div>;
|
||||
};
|
||||
|
||||
export default Excel;
|
||||
8
web/src/pages/document-viewer/index.less
Normal file
8
web/src/pages/document-viewer/index.less
Normal file
@ -0,0 +1,8 @@
|
||||
.viewerWrapper {
|
||||
width: 100%;
|
||||
:global {
|
||||
.pdf-canvas {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
28
web/src/pages/document-viewer/index.tsx
Normal file
28
web/src/pages/document-viewer/index.tsx
Normal file
@ -0,0 +1,28 @@
|
||||
import { api_host } from '@/utils/api';
|
||||
import FileViewer from 'react-file-viewer';
|
||||
import { useParams, useSearchParams } from 'umi';
|
||||
import Excel from './excel';
|
||||
|
||||
import styles from './index.less';
|
||||
|
||||
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}>
|
||||
{ext === 'xlsx' && <Excel filePath={api}></Excel>}
|
||||
{ext !== 'xlsx' && (
|
||||
<FileViewer fileType={ext} filePath={api} onError={onError} />
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
};
|
||||
|
||||
export default DocumentViewer;
|
||||
Reference in New Issue
Block a user