forked from infiniflow/ragflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support DeepSeek (infiniflow#667)
### What problem does this PR solve? infiniflow#666 feat: support DeepSeek feat: preview word and excel ### Type of change - [x] New Feature (non-breaking change which adds functionality)
- Loading branch information
Showing
17 changed files
with
2,109 additions
and
296 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
"author": "zhaofengchao <[email protected]>", | ||
"scripts": { | ||
"build": "umi build", | ||
"dev": "cross-env PORT=9000 umi dev", | ||
"dev": "cross-env PORT=9200 umi dev", | ||
"postinstall": "umi setup", | ||
"lint": "umi lint --eslint-only", | ||
"setup": "umi setup", | ||
|
@@ -13,6 +13,7 @@ | |
"@ant-design/icons": "^5.2.6", | ||
"@ant-design/pro-components": "^2.6.46", | ||
"@ant-design/pro-layout": "^7.17.16", | ||
"@js-preview/excel": "^1.7.8", | ||
"ahooks": "^3.7.10", | ||
"antd": "^5.12.7", | ||
"axios": "^1.6.3", | ||
|
@@ -25,6 +26,7 @@ | |
"rc-tween-one": "^3.0.6", | ||
"react-chat-elements": "^12.0.13", | ||
"react-copy-to-clipboard": "^5.1.0", | ||
"react-file-viewer": "^1.2.1", | ||
"react-i18next": "^14.0.0", | ||
"react-infinite-scroll-component": "^6.1.0", | ||
"react-markdown": "^9.0.1", | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.viewerWrapper { | ||
width: 100%; | ||
:global { | ||
.pdf-canvas { | ||
text-align: center; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters