zy-react-library 1.1.8 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Pdf/index.js +1 -1
- package/package.json +1 -1
package/components/Pdf/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useFullscreen as e}from"ahooks";import{Modal as r,Button as o,Spin as i,message as n}from"antd";import{useState as t,useRef as l}from"react";import{pdfjs as a,Document as d,Page as s}from"react-pdf";import c from"../../hooks/useDownloadFile/index.js";import{getFileUrl as p}from"../../utils/index.js";import"react-pdf/dist/Page/AnnotationLayer.css";import"react-pdf/dist/Page/TextLayer.css";import"./index.less";import{
|
|
1
|
+
import{useFullscreen as e}from"ahooks";import{Modal as r,Button as o,Spin as i,message as n}from"antd";import{useState as t,useRef as l}from"react";import{pdfjs as a,Document as d,Page as s}from"react-pdf";import c from"../../hooks/useDownloadFile/index.js";import{getFileUrl as p}from"../../utils/index.js";import"react-pdf/dist/Page/AnnotationLayer.css";import"react-pdf/dist/Page/TextLayer.css";import"./index.less";import{jsx as m,Fragment as f}from"react/jsx-runtime";function h(h){const{visible:u=!1,onCancel:x,file:g,name:v,inline:y=!1,title:w="PDF预览",style:k={}}=h,C=p(),[j,F]=t(0),[P,b]=t(600),L=l(null),[S,{enterFullscreen:D,exitFullscreen:A}]=e(L),{downloadFile:N}=c();a.GlobalWorkerOptions.workerSrc=`//unpkg.com/pdfjs-dist@${a.version}/build/pdf.worker.min.mjs`;const W=({numPages:e})=>{F(e)},$=()=>{n.error("加载 PDF 文件失败"),x&&x()},z=({width:e})=>{b(e)},B=()=>m(f,{children:m("div",{style:{height:S?"calc(100vh - 40px - 24px - 8px - 32px - 12px)":"72vh",overflowY:"auto",padding:"24px",...k},children:m(d,{file:g.includes(C)?g:C+g,onLoadSuccess:W,onLoadError:$,loading:m("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"65vh"},children:m(i,{size:"large"})}),children:Array.from({length:j}).map((e,r)=>m(s,{pageNumber:r+1,onLoadSuccess:z},`page_${r+1}`))})})});return y?B():m("div",{ref:L,children:m(r,{style:{top:S?0:100,maxWidth:S?"100vw":"calc(100vw - 32px)",paddingBottom:S?0:24},open:u,maskClosable:!1,width:S?"100vw":P+100,title:w,onCancel:()=>{S&&A(),x()},getContainer:!1,footer:[m(o,{onClick:()=>{S&&A(),x()},children:"关闭"},"cancel"),m(o,{onClick:()=>{S?A():D()},children:S?"退出全屏":"全屏"},"fullScreen"),m(o,{type:"primary",onClick:()=>{S&&A(),N({url:g,name:v})},children:"下载"},"download")],children:B()})})}h.displayName="Pdf";export{h as default};
|