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

@@ -6,13 +6,21 @@ import {
DeleteOutlined,
DownloadOutlined,
EditOutlined,
EyeOutlined,
LinkOutlined,
} from '@ant-design/icons';
import { Button, Space, Tooltip } from 'antd';
import { useHandleDeleteFile, useNavigateToDocument } from '../hooks';
import { useHandleDeleteFile } from '../hooks';
import NewDocumentLink from '@/components/new-document-link';
import { SupportedPreviewDocumentTypes } from '@/constants/common';
import { getExtension } from '@/utils/documentUtils';
import styles from './index.less';
const isSupportedPreviewDocumentType = (fileExtension: string) => {
return SupportedPreviewDocumentTypes.includes(fileExtension);
};
interface IProps {
record: IFile;
setCurrentRecord: (record: any) => void;
@@ -35,7 +43,7 @@ const ActionCell = ({
[documentId],
setSelectedRowKeys,
);
const navigateToDocument = useNavigateToDocument(record.id, record.name);
const extension = getExtension(record.name);
const onDownloadDocument = () => {
downloadFile({
@@ -59,15 +67,6 @@ const ActionCell = ({
return (
<Space size={0}>
{/* <Tooltip title={t('addToKnowledge')}>
<Button
type="text"
className={styles.iconButton}
onClick={navigateToDocument}
>
<EyeOutlined size={20} />
</Button>
</Tooltip> */}
<Tooltip title={t('addToKnowledge')}>
<Button
type="text"
@@ -110,6 +109,18 @@ const ActionCell = ({
</Button>
</Tooltip>
)}
{isSupportedPreviewDocumentType(extension) && (
<NewDocumentLink
color="black"
link={`/document/${documentId}?ext=${extension}`}
>
<Tooltip title={t('preview')}>
<Button type="text" className={styles.iconButton}>
<EyeOutlined size={20} />
</Button>
</Tooltip>
</NewDocumentLink>
)}
</Space>
);
};