mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? fix: reference file with 'docx' type can not open #844 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -1,9 +1,8 @@
|
||||
import { ReactComponent as NavigationPointerIcon } from '@/assets/svg/navigation-pointer.svg';
|
||||
import NewDocumentLink from '@/components/new-document-link';
|
||||
import { useGetDocumentUrl } from '@/hooks/document-hooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { ITestingDocument } from '@/interfaces/database/knowledge';
|
||||
import { isPdf } from '@/utils/documentUtils';
|
||||
import { Table, TableProps } from 'antd';
|
||||
import { EyeOutlined } from '@ant-design/icons';
|
||||
import { Button, Table, TableProps, Tooltip } from 'antd';
|
||||
import { useDispatch, useSelector } from 'umi';
|
||||
|
||||
interface IProps {
|
||||
@ -14,9 +13,9 @@ const SelectFiles = ({ handleTesting }: IProps) => {
|
||||
const documents: ITestingDocument[] = useSelector(
|
||||
(state: any) => state.testingModel.documents,
|
||||
);
|
||||
const { t } = useTranslate('fileManager');
|
||||
|
||||
const dispatch = useDispatch();
|
||||
const getDocumentUrl = useGetDocumentUrl();
|
||||
|
||||
const columns: TableProps<ITestingDocument>['columns'] = [
|
||||
{
|
||||
@ -38,10 +37,15 @@ const SelectFiles = ({ handleTesting }: IProps) => {
|
||||
width: 50,
|
||||
render: (_, { doc_id, doc_name }) => (
|
||||
<NewDocumentLink
|
||||
link={getDocumentUrl(doc_id)}
|
||||
preventDefault={!isPdf(doc_name)}
|
||||
documentName={doc_name}
|
||||
documentId={doc_id}
|
||||
prefix="document"
|
||||
>
|
||||
<NavigationPointerIcon />
|
||||
<Tooltip title={t('preview')}>
|
||||
<Button type="text">
|
||||
<EyeOutlined size={20} />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</NewDocumentLink>
|
||||
),
|
||||
},
|
||||
|
||||
@ -12,9 +12,10 @@ import styles from './index.less';
|
||||
|
||||
const DocumentViewer = () => {
|
||||
const { id: documentId } = useParams();
|
||||
const api = `${api_host}/file/get/${documentId}`;
|
||||
const [currentQueryParameters] = useSearchParams();
|
||||
const ext = currentQueryParameters.get('ext');
|
||||
const prefix = currentQueryParameters.get('prefix');
|
||||
const api = `${api_host}/${prefix || 'file'}/get/${documentId}`;
|
||||
|
||||
return (
|
||||
<section className={styles.viewerWrapper}>
|
||||
|
||||
@ -13,14 +13,12 @@ import { Button, Space, Tooltip } from 'antd';
|
||||
import { useHandleDeleteFile } from '../hooks';
|
||||
|
||||
import NewDocumentLink from '@/components/new-document-link';
|
||||
import { SupportedPreviewDocumentTypes } from '@/constants/common';
|
||||
import { getExtension } from '@/utils/documentUtils';
|
||||
import {
|
||||
getExtension,
|
||||
isSupportedPreviewDocumentType,
|
||||
} from '@/utils/documentUtils';
|
||||
import styles from './index.less';
|
||||
|
||||
const isSupportedPreviewDocumentType = (fileExtension: string) => {
|
||||
return SupportedPreviewDocumentTypes.includes(fileExtension);
|
||||
};
|
||||
|
||||
interface IProps {
|
||||
record: IFile;
|
||||
setCurrentRecord: (record: any) => void;
|
||||
@ -118,8 +116,9 @@ const ActionCell = ({
|
||||
)}
|
||||
{isSupportedPreviewDocumentType(extension) && (
|
||||
<NewDocumentLink
|
||||
documentId={documentId}
|
||||
documentName={record.name}
|
||||
color="black"
|
||||
link={`/document/${documentId}?ext=${extension}`}
|
||||
>
|
||||
<Tooltip title={t('preview')}>
|
||||
<Button type="text" className={styles.iconButton}>
|
||||
|
||||
Reference in New Issue
Block a user