mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-23 15:06:50 +08:00
### 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>
|
||||
);
|
||||
};
|
||||
|
||||
@ -13,7 +13,6 @@ import {
|
||||
import { useGetPagination, useSetPagination } from '@/hooks/logicHooks';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
||||
import { IFile } from '@/interfaces/database/file-manager';
|
||||
import { getExtension } from '@/utils/documentUtils';
|
||||
import { PaginationProps } from 'antd';
|
||||
import { UploadFile } from 'antd/lib';
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
@ -339,12 +338,3 @@ export const useHandleBreadcrumbClick = () => {
|
||||
|
||||
return { handleBreadcrumbClick };
|
||||
};
|
||||
|
||||
export const useNavigateToDocument = (documentId: string, name: string) => {
|
||||
const navigate = useNavigate();
|
||||
const navigateToDocument = () => {
|
||||
navigate(`/document/${documentId}?ext=${getExtension(name)}`);
|
||||
};
|
||||
|
||||
return navigateToDocument;
|
||||
};
|
||||
|
||||
@ -96,8 +96,8 @@ const FileManager = () => {
|
||||
},
|
||||
{
|
||||
title: t('uploadDate'),
|
||||
dataIndex: 'create_date',
|
||||
key: 'create_date',
|
||||
dataIndex: 'create_time',
|
||||
key: 'create_time',
|
||||
render(text) {
|
||||
return formatDate(text);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user