fix: fix uploaded file time error #680 (#690)

### What problem does this PR solve?

fix: fix uploaded file time error #680
feat: support preview of word and excel #684 

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu
2024-05-09 11:30:15 +08:00
committed by GitHub
parent 99be226c7c
commit 793e29f23a
18 changed files with 137 additions and 44 deletions

View File

@@ -1,10 +1,17 @@
import { ExceptiveType, 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 Excel from './excel';
import Pdf from './pdf';
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}`;
@@ -17,8 +24,14 @@ const DocumentViewer = () => {
return (
<section className={styles.viewerWrapper}>
{ext === 'xlsx' && <Excel filePath={api}></Excel>}
{ext !== 'xlsx' && (
{Images.includes(ext!) && (
<Flex className={styles.image} align="center" justify="center">
<Image src={api} preview={false}></Image>
</Flex>
)}
{ext === 'pdf' && <Pdf url={api}></Pdf>}
{(ext === 'xlsx' || ext === 'xls') && <Excel filePath={api}></Excel>}
{isNotExceptiveType(ext!) && (
<FileViewer fileType={ext} filePath={api} onError={onError} />
)}
</section>