### 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:
@@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user