/* eslint-disable */ import { Modal } from "antd"; import React, { useEffect, useRef } from "react"; import * as commonConfig from "@/utils/config"; import PrintPdf from "@/components/PrintPdf/PrintPdf"; import jsPreviewDocx from "@js-preview/docx"; import jsPreviewExcel from "@js-preview/excel"; import "@js-preview/docx/lib/index.css"; import "@js-preview/excel/lib/index.css"; const OfficePreview = props => { const { officePreviewVisible, officeFileUrl, onCancel, app } = props; const title = officeFileUrl .split("/") .pop() .split("_") .pop(); const fileUrl = `${ commonConfig.server_host }file/download?savePathStr=${encodeURIComponent( officeFileUrl )}&sModelsId=100&token=${app.token}`; const fileType = title .split(".") .pop() .toUpperCase(); const officeRef = useRef(null); useEffect(() => { if (fileType === "XLSX") { const myExcelPreviewer = jsPreviewExcel.init(officeRef.current); myExcelPreviewer.preview(fileUrl); } else if (fileType === "DOCX") { const myDocxPreviewer = jsPreviewDocx.init(officeRef.current); myDocxPreviewer.preview(fileUrl); } }, []); return (
{fileType === "PDF" && ( )}
); }; export default OfficePreview;