zy-react-library 1.1.4 → 1.1.5
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
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{jsxs as m,jsx as f,Fragment as h}from"react/jsx-runtime";function u(u){const{visible:x=!1,onCancel:g,file:v,name:y,inline:w=!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{jsxs as m,jsx as f,Fragment as h}from"react/jsx-runtime";function u(u){const{visible:x=!1,onCancel:g,file:v,name:y,inline:w=!1,title:k="PDF预览",style:C={}}=u,j=p(),[F,P]=t(0),[b,L]=t(600),[S,D]=t(!0),A=l(null),[N,{enterFullscreen:W,exitFullscreen:$}]=e(A),{downloadFile:z}=c();a.GlobalWorkerOptions.workerSrc=`//unpkg.com/pdfjs-dist@${a.version}/build/pdf.worker.min.mjs`;const B=({numPages:e})=>{P(e),D(!1)},E=()=>{D(!1),n.error("加载 PDF 文件失败"),g&&g()},G=({width:e})=>{L(e)},I=()=>m(h,{children:[S&&f("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"72vh"},children:f(i,{size:"large"})}),f("div",{style:{height:N?"calc(100vh - 40px - 24px - 8px - 32px - 12px)":"72vh",overflowY:"auto",padding:"24px",...C},children:f(d,{file:v.includes(j)?v:j+v,onLoadSuccess:B,onLoadError:E,children:Array.from({length:F}).map((e,r)=>f(s,{pageNumber:r+1,onLoadSuccess:G},`page_${r+1}`))})})]});return w?I():f("div",{ref:A,children:f(r,{style:{top:N?0:100,maxWidth:N?"100vw":"calc(100vw - 32px)",paddingBottom:N?0:24},open:x,maskClosable:!1,width:N?"100vw":b+100,title:k,onCancel:()=>{N&&$(),g()},getContainer:!1,footer:[f(o,{onClick:()=>{N&&$(),g()},children:"关闭"},"cancel"),!S&&f(o,{onClick:()=>{N?$():W()},children:N?"退出全屏":"全屏"},"fullScreen"),f(o,{type:"primary",onClick:()=>{N&&$(),z({url:v,name:y})},children:"下载"},"download")],children:I()})})}u.displayName="Pdf";export{u as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Button as r,Image as e,Modal as i,message as t}from"antd";import n from"dayjs";import{useState as o,useRef as c,useEffect as a}from"react";import d from"react-signature-canvas";import{base642File as l}from"../../utils/index.js";import{jsxs as h,Fragment as m,jsx as s}from"react/jsx-runtime";function p(p){const{onConfirm:u,width:f=752,height:y=300,url:g="",...C}=p,[k,b]=o(!1),v=c(null),[w,x]=o("");return a(()=>{x(g)},[g]),h(m,{children:[s("div",{children:s(r,{type:"primary",onClick:()=>{b(!0)},children:w?"重新签字":"手写签字"})}),w&&s("div",{style:{border:"1px dashed #d9d9d9",width:
|
|
1
|
+
import{Button as r,Image as e,Modal as i,message as t}from"antd";import n from"dayjs";import{useState as o,useRef as c,useEffect as a}from"react";import d from"react-signature-canvas";import{base642File as l}from"../../utils/index.js";import{jsxs as h,Fragment as m,jsx as s}from"react/jsx-runtime";function p(p){const{onConfirm:u,width:f=752,height:y=300,url:g="",...C}=p,[k,b]=o(!1),v=c(null),[w,x]=o("");return a(()=>{x(g)},[g]),h(m,{children:[s("div",{children:s(r,{type:"primary",onClick:()=>{b(!0)},children:w?"重新签字":"手写签字"})}),w&&s("div",{style:{border:"1px dashed #d9d9d9",width:"100%",height:y,marginTop:16},children:s(e,{src:w,style:{width:"100%",height:y,objectFit:"contain"}})}),s(i,{title:"签字",width:800,open:k,maskClosable:!1,onCancel:()=>b(!1),footer:[s(r,{onClick:()=>v.current.clear(),children:"重签"},"clear"),s(r,{onClick:()=>{b(!1),v.current.clear()},children:"取消"},"cancel"),s(r,{type:"primary",onClick:()=>{if(v.current.isEmpty())return void t.warning("请签名");const r=v.current.toDataURL();x(r),u({time:n().format("YYYY-MM-DD HH:mm:ss"),base64:r,file:l(r)}),v.current.clear(),b(!1)},children:"确定"},"ok")],children:s("div",{style:{border:"1px dashed #d9d9d9"},children:s(d,{ref:v,penColor:"black",canvasProps:{width:f,height:y},...C})})})]})}p.displayName="Signature";export{p as default};
|