zy-react-library 1.4.15 → 1.4.17

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.
@@ -1 +1 @@
1
- import{Modal as e,Button as t,message as r,Spin as n}from"antd";import i from"exceljs";import{useRef as o,useState as l,useEffect as c}from"react";import a from"x-data-spreadsheet";import u from"../../hooks/useDownloadFile/index.js";import{getFileUrl as s}from"../../utils/index.js";import"x-data-spreadsheet/dist/xspreadsheet.css";import{jsx as d}from"react/jsx-runtime";function h(h){const{visible:x=!1,onCancel:p,file:w,name:v,inline:g=!1,title:y="Excel预览",style:C={},extraButtons:E}=h,k=o(null),I=o(null),T=o(!1),b=s(),[j,S]=l(!1),{downloadFile:D}=u();c(()=>{if(!x&&!g||!w)return;T.current=!1;const e=setTimeout(()=>{(async()=>{S(!0),k.current.innerHTML="";try{const e=await fetch(w.includes(b)?w:b+w);if(!e.ok)return void r.error("加载 Excel 文件失败");const t=await e.arrayBuffer(),n=new i.Workbook;if(await n.xlsx.load(t),T.current)return;new a(k.current,{mode:"read",showToolbar:!1,showContextmenu:!1,view:{height:()=>k.current?.clientHeight||520,width:()=>k.current?.clientWidth||800}}).loadData(function(e){const t=[];return e.worksheets.forEach(e=>{t.push(function(e){const t={name:e.name,rows:{},cols:{len:e.columnCount||26},merges:e.model?.merges||[]};return e.columns.forEach((e,r)=>{e.width&&(t.cols[r]={width:Math.round(8*e.width)})}),e.eachRow({includeEmpty:!0},(e,r)=>{const n={cells:{}};e.height&&(n.height=Math.round(1.4*e.height)),e.eachCell({includeEmpty:!0},(e,t)=>{n.cells[t-1]={text:m(e)}}),t.rows[r-1]=n}),(t.merges||[]).forEach(e=>{const r=function(e){const[t,r=t]=e.split(":"),n=f(t),i=f(r);return{sri:n.rowIndex,sci:n.colIndex,eri:i.rowIndex,eci:i.colIndex}}(e),n=t.rows[r.sri]?.cells?.[r.sci];n&&(n.merge=[r.eri-r.sri,r.eci-r.sci])}),t}(e))}),t.length>0?t:[{name:"Sheet1",rows:{}}]}(n))}catch{r.error("加载 Excel 文件失败"),p&&p()}finally{T.current||S(!1)}})()},100);return()=>{T.current=!0,k.current&&(k.current.innerHTML=""),e&&clearTimeout(e)}},[x,g,w]);const M=()=>d(n,{spinning:j,children:d("div",{style:{height:"72vh",overflow:"hidden",...C},children:d("div",{ref:k,style:{width:"100%",height:"100%"}})})});return g?M():d("div",{ref:I,children:d(e,{style:{top:100,maxWidth:"calc(100vw - 32px)",paddingBottom:24},open:x,maskClosable:!1,width:1e3,title:y,onCancel:()=>{p()},getContainer:!1,footer:[d(t,{onClick:()=>{p()},children:"关闭"},"cancel"),d(t,{type:"primary",onClick:()=>{D({url:w,name:v})},children:"下载"},"download"),...E||[]],children:M()})})}function m(e){if(null===e.value||void 0===e.value)return"";if(e.formula)return null===e.result||void 0===e.result?`=${e.formula}`:String(e.result);if(e.text)return e.text;if(e.value instanceof Date)return e.value.toLocaleDateString();if("object"==typeof e.value){if(e.value.text)return e.value.text;if(e.value.richText)return e.value.richText.map(e=>e.text).join("");if(void 0!==e.value.result)return String(e.value.result)}return String(e.value)}function f(e){const t=/^([A-Z]+)(\d+)$/i.exec(e);return t?{rowIndex:Number(t[2])-1,colIndex:(r=t[1],r.toUpperCase().split("").reduce((e,t)=>26*e+t.charCodeAt(0)-64,0)-1)}:{rowIndex:0,colIndex:0};var r}h.displayName="Excel";export{h as default};
1
+ import{Modal as e,Button as t,message as r,Spin as n}from"antd";import i from"exceljs";import{useRef as o,useState as l,useEffect as c}from"react";import a from"x-data-spreadsheet";import u from"../../hooks/useDownloadFile/index.js";import{HTTP_URL as s}from"../../regular/index.js";import{getFileUrl as d}from"../../utils/index.js";import"x-data-spreadsheet/dist/xspreadsheet.css";import{jsx as h}from"react/jsx-runtime";function m(m){const{visible:p=!1,onCancel:w,file:v,name:g,inline:y=!1,title:C="Excel预览",style:E={},extraButtons:k}=m,I=o(null),j=o(null),T=o(!1),b=d(),[S,D]=l(!1),{downloadFile:M}=u();c(()=>{if(!p&&!y||!v)return;T.current=!1;const e=setTimeout(()=>{(async()=>{D(!0),I.current.innerHTML="";try{const e=await fetch(v.includes(b)||s.test(v)?v:b+v);if(!e.ok)return void r.error("加载 Excel 文件失败");const t=await e.arrayBuffer(),n=new i.Workbook;if(await n.xlsx.load(t),T.current)return;new a(I.current,{mode:"read",showToolbar:!1,showContextmenu:!1,view:{height:()=>I.current?.clientHeight||520,width:()=>I.current?.clientWidth||800}}).loadData(function(e){const t=[];return e.worksheets.forEach(e=>{t.push(function(e){const t={name:e.name,rows:{},cols:{len:e.columnCount||26},merges:e.model?.merges||[]};return e.columns.forEach((e,r)=>{e.width&&(t.cols[r]={width:Math.round(8*e.width)})}),e.eachRow({includeEmpty:!0},(e,r)=>{const n={cells:{}};e.height&&(n.height=Math.round(1.4*e.height)),e.eachCell({includeEmpty:!0},(e,t)=>{n.cells[t-1]={text:f(e)}}),t.rows[r-1]=n}),(t.merges||[]).forEach(e=>{const r=function(e){const[t,r=t]=e.split(":"),n=x(t),i=x(r);return{sri:n.rowIndex,sci:n.colIndex,eri:i.rowIndex,eci:i.colIndex}}(e),n=t.rows[r.sri]?.cells?.[r.sci];n&&(n.merge=[r.eri-r.sri,r.eci-r.sci])}),t}(e))}),t.length>0?t:[{name:"Sheet1",rows:{}}]}(n))}catch{r.error("加载 Excel 文件失败"),w&&w()}finally{T.current||D(!1)}})()},100);return()=>{T.current=!0,I.current&&(I.current.innerHTML=""),e&&clearTimeout(e)}},[p,y,v]);const B=()=>h(n,{spinning:S,children:h("div",{style:{height:"72vh",overflow:"hidden",...E},children:h("div",{ref:I,style:{width:"100%",height:"100%"}})})});return y?B():h("div",{ref:j,children:h(e,{style:{top:100,maxWidth:"calc(100vw - 32px)",paddingBottom:24},open:p,maskClosable:!1,width:1e3,title:C,onCancel:()=>{w()},getContainer:!1,footer:[h(t,{onClick:()=>{w()},children:"关闭"},"cancel"),h(t,{type:"primary",onClick:()=>{M({url:v,name:g})},children:"下载"},"download"),...k||[]],children:B()})})}function f(e){if(null===e.value||void 0===e.value)return"";if(e.formula)return null===e.result||void 0===e.result?`=${e.formula}`:String(e.result);if(e.text)return e.text;if(e.value instanceof Date)return e.value.toLocaleDateString();if("object"==typeof e.value){if(e.value.text)return e.value.text;if(e.value.richText)return e.value.richText.map(e=>e.text).join("");if(void 0!==e.value.result)return String(e.value.result)}return String(e.value)}function x(e){const t=/^([A-Z]+)(\d+)$/i.exec(e);return t?{rowIndex:Number(t[2])-1,colIndex:(r=t[1],r.toUpperCase().split("").reduce((e,t)=>26*e+t.charCodeAt(0)-64,0)-1)}:{rowIndex:0,colIndex:0};var r}m.displayName="Excel";export{m as default};
@@ -1 +1 @@
1
- import{useFullscreen as e}from"ahooks";import{Modal as t,Button as r,Spin as o,message as n}from"antd";import{useState as i,useRef as a}from"react";import{pdfjs as l,Document as c,Page as s}from"react-pdf";import d 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:y,file:g,name:x,inline:v=!1,title:w="PDF预览",style:k={},extraButtons:b,usePrint:C=!1}=h,L=p(),j=g.includes(L)?g:L+g,[P,F]=i(0),[D,R]=i(600),S=a(null),[U,{enterFullscreen:E,exitFullscreen:O}]=e(S),{downloadFile:W}=d();l.GlobalWorkerOptions.workerSrc=`//unpkg.com/pdfjs-dist@${l.version}/build/pdf.worker.min.mjs`;const A=({numPages:e})=>{F(e)},B=()=>{n.error("加载 PDF 文件失败"),y&&y()},N=({width:e})=>{R(e)},T=()=>m(f,{children:m("div",{style:{height:U?"calc(100vh - 40px - 24px - 8px - 32px - 12px)":"72vh",overflowY:"auto",padding:"24px",...k},children:m(c,{file:j,onLoadSuccess:A,onLoadError:B,loading:m("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"65vh"},children:m(o,{size:"large"})}),children:Array.from({length:P}).map((e,t)=>m(s,{pageNumber:t+1,onLoadSuccess:N},`page_${t+1}`))})})});return v?T():m("div",{ref:S,children:m(t,{style:{top:U?0:100,maxWidth:U?"100vw":"calc(100vw - 32px)",paddingBottom:U?0:24},open:u,maskClosable:!1,width:U?"100vw":D+100,styles:{body:{maxHeight:"auto !important",overflow:"auto"}},title:w,onCancel:()=>{U&&O(),y()},getContainer:!1,footer:[m(r,{onClick:()=>{U&&O(),y()},children:"关闭"},"cancel"),m(r,{onClick:()=>{U?O():E()},children:U?"退出全屏":"全屏"},"fullScreen"),m(r,{type:"primary",onClick:()=>{U&&O(),W({url:g,name:x})},children:"下载"},"download"),C&&m(r,{type:"primary",onClick:async()=>{try{const e=await fetch(j);if(!e.ok)return void n.warning("获取 PDF 文件失败");const t=URL.createObjectURL(await e.blob()),r=document.createElement("iframe");r.style.cssText="position:fixed;width:0;height:0;border:0",r.onload=()=>{const e=r.contentWindow,o=()=>{URL.revokeObjectURL(t),r.remove()};e.addEventListener("afterprint",o,{once:!0});try{e.focus(),e.print()}catch(e){o(),n.error(e.message||"打印失败,请稍后重试")}},r.src=t,document.body.appendChild(r)}catch(e){n.error(e.message||"打印失败,请稍后重试")}},children:"打印"},"print"),...b||[]],children:T()})})}h.displayName="Pdf";export{h as default};
1
+ import{useFullscreen as e}from"ahooks";import{Modal as t,Button as r,Spin as o,message as i}from"antd";import{useState as n,useRef as a}from"react";import{pdfjs as l,Document as c,Page as s}from"react-pdf";import d from"../../hooks/useDownloadFile/index.js";import{HTTP_URL as p}from"../../regular/index.js";import{getFileUrl as m}from"../../utils/index.js";import"react-pdf/dist/Page/AnnotationLayer.css";import"react-pdf/dist/Page/TextLayer.css";import"./index.less";import{jsx as f,Fragment as h}from"react/jsx-runtime";function u(u){const{visible:g=!1,onCancel:x,file:y,name:v,inline:w=!1,title:k="PDF预览",style:b={},extraButtons:C,usePrint:L=!1}=u,j=m(),P=y.includes(j)||p.test(y)?y:j+y,[F,D]=n(0),[R,S]=n(600),U=a(null),[E,{enterFullscreen:O,exitFullscreen:W}]=e(U),{downloadFile:A}=d();l.GlobalWorkerOptions.workerSrc=`//unpkg.com/pdfjs-dist@${l.version}/build/pdf.worker.min.mjs`;const B=({numPages:e})=>{D(e)},N=()=>{i.error("加载 PDF 文件失败"),x&&x()},T=({width:e})=>{S(e)},$=()=>f(h,{children:f("div",{style:{height:E?"calc(100vh - 40px - 24px - 8px - 32px - 12px)":"72vh",overflowY:"auto",padding:"24px",...b},children:f(c,{file:P,onLoadSuccess:B,onLoadError:N,loading:f("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"65vh"},children:f(o,{size:"large"})}),children:Array.from({length:F}).map((e,t)=>f(s,{pageNumber:t+1,onLoadSuccess:T},`page_${t+1}`))})})});return w?$():f("div",{ref:U,children:f(t,{style:{top:E?0:100,maxWidth:E?"100vw":"calc(100vw - 32px)",paddingBottom:E?0:24},open:g,maskClosable:!1,width:E?"100vw":R+100,styles:{body:{maxHeight:"auto !important",overflow:"auto"}},title:k,onCancel:()=>{E&&W(),x()},getContainer:!1,footer:[f(r,{onClick:()=>{E&&W(),x()},children:"关闭"},"cancel"),f(r,{onClick:()=>{E?W():O()},children:E?"退出全屏":"全屏"},"fullScreen"),f(r,{type:"primary",onClick:()=>{E&&W(),A({url:y,name:v})},children:"下载"},"download"),L&&f(r,{type:"primary",onClick:async()=>{try{const e=await fetch(P);if(!e.ok)return void i.warning("获取 PDF 文件失败");const t=URL.createObjectURL(await e.blob()),r=document.createElement("iframe");r.style.cssText="position:fixed;width:0;height:0;border:0",r.onload=()=>{const e=r.contentWindow,o=()=>{URL.revokeObjectURL(t),r.remove()};e.addEventListener("afterprint",o,{once:!0});try{e.focus(),e.print()}catch(e){o(),i.error(e.message||"打印失败,请稍后重试")}},r.src=t,document.body.appendChild(r)}catch(e){i.error(e.message||"打印失败,请稍后重试")}},children:"打印"},"print"),...C||[]],children:$()})})}u.displayName="Pdf";export{u as default};
@@ -1 +1 @@
1
- import{Image as r}from"antd";import{getFileUrl as e}from"../../utils/index.js";import{jsx as t}from"react/jsx-runtime";const i=i=>{const{files:o=[],fileUrlKey:a="filePath"}=i,m=e();return t(r.PreviewGroup,{children:o.filter(Boolean).map(e=>t(r,{src:e[a]?m+e[a]:m+e,wrapperStyle:{marginRight:10,marginBottom:10},width:100,height:100,alt:""},e[a]||e))})};i.displayName="PreviewImg";export{i as default};
1
+ import{Image as r}from"antd";import{HTTP_URL as e}from"../../regular/index.js";import{getFileUrl as t}from"../../utils/index.js";import{jsx as i}from"react/jsx-runtime";const o=o=>{const{files:m=[],fileUrlKey:a="filePath"}=o,l=t();return i(r.PreviewGroup,{children:m.filter(Boolean).map(t=>{const o=t[a]||t,m=o.includes(l)||e.test(o)?o:l+o;return i(r,{src:m,wrapperStyle:{marginRight:10,marginBottom:10},width:100,height:100,alt:""},o)})})};o.displayName="PreviewImg";export{o as default};
@@ -1 +1 @@
1
- import{Modal as e,Button as r}from"antd";import{forwardRef as t,useState as n,useRef as a,useImperativeHandle as o,useEffect as i}from"react";import{getFileUrl as l}from"../../utils/index.js";import s from"./AliPlayer.js";import{jsx as c}from"react/jsx-runtime";const u=t(({source:t="",vid:u="",playAuth:p="",cover:d="",autoplay:m=!0,showProgress:y=!0,playTime:h=0,inline:P=!1,isLive:f=!1,width:v="100%",height:g="600px",title:w="视频",visible:x=!1,onCancel:C,onEnded:I,onTimeupdate:T,onGetPlayerInstance:j,aliPlayerProps:A={}},b)=>{const[k,E]=n(!1),G=a(null);o(b,()=>({play:()=>{G.current&&G.current.play()},pause:()=>{G.current&&G.current.pause()},getPlayerInstance:()=>G.current&&G.current.getPlayerInstance()}));const L=C?x:k,N=C||E;i(()=>{P||(L?G.current&&G.current.play():G.current&&G.current.pause())},[L,P]);const V=c(s,{ref:G,source:(()=>{if(t)return t.includes("http")||t.includes("https")?t:l()+t})(),vid:u,playAuth:p,cover:d,autoplay:m,showProgress:y,playTime:h,isLive:f,width:v,height:g,aliPlayerProps:A,onEnded:I,onTimeupdate:T,onGetPlayerInstance:j});return P?V:c(e,{open:L,width:800,title:w,footer:[c(r,{onClick:()=>N(!1),children:"关闭"},"cancel")],maskClosable:!1,onCancel:()=>N(!1),children:V})});u.displayName="Video";export{u as default};
1
+ import{Modal as e,Button as r}from"antd";import{forwardRef as t,useState as n,useRef as o,useImperativeHandle as a,useEffect as i}from"react";import{HTTP_URL as l}from"../../regular/index.js";import{getFileUrl as s}from"../../utils/index.js";import c from"./AliPlayer.js";import{jsx as u}from"react/jsx-runtime";const p=t(({source:t="",vid:p="",playAuth:d="",cover:m="",autoplay:y=!0,showProgress:h=!0,playTime:P=0,inline:f=!1,isLive:g=!1,width:v="100%",height:w="600px",title:x="视频",visible:j=!1,onCancel:C,onEnded:I,onTimeupdate:T,onGetPlayerInstance:A,aliPlayerProps:b={}},k)=>{const[E,G]=n(!1),L=o(null);a(k,()=>({play:()=>{L.current&&L.current.play()},pause:()=>{L.current&&L.current.pause()},getPlayerInstance:()=>L.current&&L.current.getPlayerInstance()}));const N=C?j:E,V=C||G;i(()=>{f||(N?L.current&&L.current.play():L.current&&L.current.pause())},[N,f]);const q=u(c,{ref:L,source:(()=>{if(t)return l.test(t)?t:s()+t})(),vid:p,playAuth:d,cover:m,autoplay:y,showProgress:h,playTime:P,isLive:g,width:v,height:w,aliPlayerProps:b,onEnded:I,onTimeupdate:T,onGetPlayerInstance:A});return f?q:u(e,{open:N,width:800,title:x,footer:[u(r,{onClick:()=>V(!1),children:"关闭"},"cancel")],maskClosable:!1,onCancel:()=>V(!1),children:q})});p.displayName="Video";export{p as default};
@@ -1 +1 @@
1
- import{Modal as r,Button as e,message as n,Spin as t}from"antd";import{renderAsync as i}from"docx-preview";import{useRef as o,useState as a,useEffect as l}from"react";import c from"../../hooks/useDownloadFile/index.js";import{getFileUrl as d}from"../../utils/index.js";import{jsx as u}from"react/jsx-runtime";function s(s){const{visible:f=!1,onCancel:m,file:p,name:h,inline:w=!1,title:g="Word预览",style:v={},extraButtons:x}=s,y=o(null),k=o(null),W=o(!1),C=d(),[b,T]=a(!1),{downloadFile:j}=c();l(()=>{if(!f&&!w||!p)return;W.current=!1;const r=setTimeout(()=>{(async()=>{T(!0),y.current.innerHTML="";try{const r=await fetch(p.includes(C)?p:C+p);if(!r.ok)return void n.error("加载 Word 文件失败");const e=await r.arrayBuffer();if(W.current)return;await i(e,y.current,null,{className:"docx-preview",inWrapper:!0,ignoreWidth:!1,ignoreHeight:!1,breakPages:!0})}catch{n.error("加载 Word 文件失败"),m&&m()}finally{W.current||T(!1)}})()},100);return()=>{W.current=!0,y.current&&(y.current.innerHTML=""),r&&clearTimeout(r)}},[f,w,p]);const B=()=>u(t,{spinning:b,children:u("div",{style:{height:"72vh",overflowY:"auto",padding:"24px",background:"#f5f5f5",...v},children:u("div",{ref:y})})});return w?B():u("div",{ref:k,children:u(r,{style:{top:100,maxWidth:"calc(100vw - 32px)",paddingBottom:24},open:f,maskClosable:!1,width:900,title:g,onCancel:()=>{m()},getContainer:!1,footer:[u(e,{onClick:()=>{m()},children:"关闭"},"cancel"),u(e,{type:"primary",onClick:()=>{j({url:p,name:h})},children:"下载"},"download"),...x||[]],children:B()})})}s.displayName="Word";export{s as default};
1
+ import{Modal as r,Button as e,message as n,Spin as t}from"antd";import{renderAsync as i}from"docx-preview";import{useRef as o,useState as a,useEffect as l}from"react";import c from"../../hooks/useDownloadFile/index.js";import{HTTP_URL as d}from"../../regular/index.js";import{getFileUrl as u}from"../../utils/index.js";import{jsx as s}from"react/jsx-runtime";function m(m){const{visible:f=!1,onCancel:p,file:h,name:g,inline:w=!1,title:x="Word预览",style:v={},extraButtons:y}=m,k=o(null),W=o(null),C=o(!1),b=u(),[j,T]=a(!1),{downloadFile:B}=c();l(()=>{if(!f&&!w||!h)return;C.current=!1;const r=setTimeout(()=>{(async()=>{T(!0),k.current.innerHTML="";try{const r=await fetch(h.includes(b)||d.test(h)?h:b+h);if(!r.ok)return void n.error("加载 Word 文件失败");const e=await r.arrayBuffer();if(C.current)return;await i(e,k.current,null,{className:"docx-preview",inWrapper:!0,ignoreWidth:!1,ignoreHeight:!1,breakPages:!0})}catch{n.error("加载 Word 文件失败"),p&&p()}finally{C.current||T(!1)}})()},100);return()=>{C.current=!0,k.current&&(k.current.innerHTML=""),r&&clearTimeout(r)}},[f,w,h]);const H=()=>s(t,{spinning:j,children:s("div",{style:{height:"72vh",overflowY:"auto",padding:"24px",background:"#f5f5f5",...v},children:s("div",{ref:k})})});return w?H():s("div",{ref:W,children:s(r,{style:{top:100,maxWidth:"calc(100vw - 32px)",paddingBottom:24},open:f,maskClosable:!1,width:900,title:x,onCancel:()=>{p()},getContainer:!1,footer:[s(e,{onClick:()=>{p()},children:"关闭"},"cancel"),s(e,{type:"primary",onClick:()=>{B({url:h,name:g})},children:"下载"},"download"),...y||[]],children:H()})})}m.displayName="Word";export{m as default};
@@ -1 +1 @@
1
- import{Modal as o,message as e}from"antd";import{useState as n}from"react";import{getFileUrl as t,getFileSuffix as c,getFileName as r}from"../../utils/index.js";function l(l="object"){const[d,a]=n(!1);let i=0;const m=n=>{i++,i>0&&a(!0);const{url:l,name:d}=n;l?o.confirm({title:"提示",content:"确定要下载此文件吗?",onOk:()=>{const o=t();let n=d;n?!c(n)&&c(l)&&(n=`${n}.${c(l)}`):n=r(l),fetch(l.includes(o)?l:o+l).then(o=>o.blob()).then(o=>{const e=document.createElement("a");document.body.appendChild(e),e.style.display="none";const t=window.URL.createObjectURL(o);e.href=t,e.download=`${n}`,e.click(),document.body.removeChild(e),window.URL.revokeObjectURL(t)}).catch(()=>{e.error("下载失败")}).finally(()=>{i--,i<=0&&a(!1)})},onCancel:()=>{i--,i<=0&&a(!1)}}):console.error("【downloadFile】 缺少 url 参数")};return"array"===l?[d,m]:{loading:d,downloadFile:m}}export{l as default};
1
+ import{Modal as e,message as o}from"antd";import{useState as t}from"react";import{HTTP_URL as n}from"../../regular/index.js";import{getFileUrl as r,getFileSuffix as c,getFileName as l}from"../../utils/index.js";function d(d="object"){const[i,a]=t(!1);let m=0;const s=t=>{m++,m>0&&a(!0);const{url:d,name:i}=t;d?e.confirm({title:"提示",content:"确定要下载此文件吗?",onOk:()=>{const e=r();let t=i;t?!c(t)&&c(d)&&(t=`${t}.${c(d)}`):t=l(d),fetch(d.includes(e)||n.test(e)?d:e+d).then(e=>e.blob()).then(e=>{const o=document.createElement("a");document.body.appendChild(o),o.style.display="none";const n=window.URL.createObjectURL(e);o.href=n,o.download=`${t}`,o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(n)}).catch(()=>{o.error("下载失败")}).finally(()=>{m--,m<=0&&a(!1)})},onCancel:()=>{m--,m<=0&&a(!1)}}):console.error("【downloadFile】 缺少 url 参数")};return"array"===d?[i,s]:{loading:i,downloadFile:s}}export{d as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zy-react-library",
3
3
  "private": false,
4
- "version": "1.4.15",
4
+ "version": "1.4.17",
5
5
  "type": "module",
6
6
  "description": "",
7
7
  "author": "LiuJiaNan",
@@ -57,3 +57,7 @@ export const POSTAL_CODE: RegExp;
57
57
  * 匹配座机号码。
58
58
  */
59
59
  export const TEL_PHONE: RegExp;
60
+ /**
61
+ * 匹配以 http:// 或 https:// 开头的完整 URL(协议部分)。
62
+ */
63
+ export const HTTP_URL: RegExp;
package/regular/index.js CHANGED
@@ -1 +1 @@
1
- const d=/^(?:(?:\+|00)86)?1(?:3\d|4[5-7|9]|5[0-3|5-9]|6[5-7]|7[0-8]|8\d|9[1|89])\d{8}$/,$=/^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/,A=/^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[12]\d|30|31)\d{3}[\dX]$/i,H=/^(13\d|14[579]|15[0-3,5-9]|166|17[0135-8]|18\d|19[89])\d{8}$/,J=/(^[1-9](\d+)?(\.\d{1,2})?$)|(^(0)$)|(^\d\.\d(\d)?$)/,N=/^\d+\.\d{2}$/,P=/^\d+(\.\d?)?$/,Z=/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]$/,X=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^a-zA-Z\d]).{8,}$/,a=/<[^>]*>/g,g=/^(0[1-7]|1[0-356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[0-5]|8[013-6])\d{4}$/g,o=/^(?:(?:\d{3}-)?\d{8}|^(?:\d{4}-)?\d{7,8})(?:-\d+)?$/;export{J as FLOATING_POINT_NUMBER,a as HTML_TAG,A as ID_NUMBER,Z as LICENSE_PLATE_NUMBER,H as MOBILE_PHONE,P as ONE_DECIMAL_PLACES,d as PHONE,g as POSTAL_CODE,X as STRONG_PASSWORD,o as TEL_PHONE,N as TWO_DECIMAL_PLACES,$ as UNIFIED_SOCIAL_CREDIT_CODE};
1
+ const d=/^(?:(?:\+|00)86)?1(?:3\d|4[5-7|9]|5[0-3|5-9]|6[5-7]|7[0-8]|8\d|9[1|89])\d{8}$/,$=/^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/,A=/^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[12]\d|30|31)\d{3}[\dX]$/i,H=/^(13\d|14[579]|15[0-3,5-9]|166|17[0135-8]|18\d|19[89])\d{8}$/,J=/(^[1-9](\d+)?(\.\d{1,2})?$)|(^(0)$)|(^\d\.\d(\d)?$)/,N=/^\d+\.\d{2}$/,P=/^\d+(\.\d?)?$/,Z=/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]$/,t=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^a-zA-Z\d]).{8,}$/,X=/<[^>]*>/g,a=/^(0[1-7]|1[0-356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[0-5]|8[013-6])\d{4}$/g,g=/^(?:(?:\d{3}-)?\d{8}|^(?:\d{4}-)?\d{7,8})(?:-\d+)?$/,i=/^https?:\/\//i;export{J as FLOATING_POINT_NUMBER,X as HTML_TAG,i as HTTP_URL,A as ID_NUMBER,Z as LICENSE_PLATE_NUMBER,H as MOBILE_PHONE,P as ONE_DECIMAL_PLACES,d as PHONE,a as POSTAL_CODE,t as STRONG_PASSWORD,g as TEL_PHONE,N as TWO_DECIMAL_PLACES,$ as UNIFIED_SOCIAL_CREDIT_CODE};
@@ -1,32 +0,0 @@
1
- import type { FC } from "react";
2
- import type { BasicSelectTreeProps } from "../../Basic";
3
-
4
- export interface HiddenLevelSelectTreeItem {
5
- dictValue: string;
6
- dictLabel: string;
7
- children: HiddenLevelSelectTreeItem[];
8
- [key: string]: any;
9
- }
10
-
11
- /**
12
- * 组件属性
13
- */
14
- export interface HiddenLevelSelectTreeProps extends Omit<BasicSelectTreeProps, "treeData" | "nameKey" | "idKey" | "childrenKey" | "level" | "onGetNodePaths" | "onGetData"> {
15
- /** 是否显示忽略隐患,默认 true */
16
- isShowNeglect?: boolean;
17
- /** 是否显示较大隐患,默认 true */
18
- isShowLarger?: boolean;
19
- /** 是否显示重大隐患,默认 true */
20
- isShowMajor?: boolean;
21
- /** 获取父级节点 */
22
- onGetNodePaths?: (nodes: HiddenLevelSelectTreeItem[]) => void;
23
- /** 获取数据 */
24
- onGetData?: (data: HiddenLevelSelectTreeItem[], processedData: HiddenLevelSelectTreeItem[]) => void;
25
- }
26
-
27
- /**
28
- * 隐患级别下拉树组件(港务局版本)
29
- */
30
- declare const HiddenLevelSelectTree: FC<HiddenLevelSelectTreeProps>;
31
-
32
- export default HiddenLevelSelectTree;
@@ -1 +0,0 @@
1
- import{request as e}from"@cqsjjb/jjb-common-lib/http.js";import{useState as t,useEffect as i}from"react";import{DICTIONARY_APP_KEY_ENUM as r}from"zy-react-data/enum/dictionary";import a from"../../Basic/index.js";import{jsx as d}from"react/jsx-runtime";function c(c){const{isShowNeglect:l=!0,isShowLarger:n=!0,isShowMajor:o=!0,...s}=c,[m,h]=t([]);return i(()=>{(async()=>{h([]);const{data:t}=await e("/config/dict-trees/list/by/dictValues","get",{appKey:r.GWJ,dictValue:"hiddenLevel"}),i=(e=>{const t=e=>e&&Array.isArray(e)?e.filter(e=>"hiddenLevel1001"===e.dictValue?l:"jdyh001"===e.dictValue?n:"hiddenLevel0002"===e.dictValue?o:(e.children&&e.children.length>0&&(e.children=t(e.children)),!0)):[];return t(e)})(t);h(i)})()},[]),d(a,{treeData:m,placeholder:"隐患级别",onlyLastLevel:!0,nameKey:"dictLabel",idKey:"dictValue",...s})}c.displayName="HiddenLevelSelectTree";export{c as default};