Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

index.tsx 1.1KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { Images } from '@/constants/common';
  2. import { api_host } from '@/utils/api';
  3. import { Flex, Image } from 'antd';
  4. import { useParams, useSearchParams } from 'umi';
  5. import Docx from './docx';
  6. import Excel from './excel';
  7. import Pdf from './pdf';
  8. import styles from './index.less';
  9. // TODO: The interface returns an incorrect content-type for the SVG.
  10. const DocumentViewer = () => {
  11. const { id: documentId } = useParams();
  12. const [currentQueryParameters] = useSearchParams();
  13. const ext = currentQueryParameters.get('ext');
  14. const prefix = currentQueryParameters.get('prefix');
  15. const api = `${api_host}/${prefix || 'file'}/get/${documentId}`;
  16. return (
  17. <section className={styles.viewerWrapper}>
  18. {Images.includes(ext!) && (
  19. <Flex className={styles.image} align="center" justify="center">
  20. <Image src={api} preview={false}></Image>
  21. </Flex>
  22. )}
  23. {ext === 'pdf' && <Pdf url={api}></Pdf>}
  24. {(ext === 'xlsx' || ext === 'xls') && <Excel filePath={api}></Excel>}
  25. {ext === 'docx' && <Docx filePath={api}></Docx>}
  26. </section>
  27. );
  28. };
  29. export default DocumentViewer;