@jt-home/mfe-components 1.0.24 → 1.0.26

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
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),B=require("element-plus");/*! Element Plus Icons Vue v2.3.2 */var X=t.defineComponent({name:"Download",__name:"download",setup(e){return(a,n)=>(t.openBlock(),t.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[t.createElementVNode("path",{fill:"currentColor",d:"M160 832h704a32 32 0 1 1 0 64H160a32 32 0 1 1 0-64m384-253.696 236.288-236.352 45.248 45.248L508.8 704 192 387.2l45.248-45.248L480 584.704V128h64z"})]))}}),Z=X,$=t.defineComponent({name:"RefreshLeft",__name:"refresh-left",setup(e){return(a,n)=>(t.openBlock(),t.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[t.createElementVNode("path",{fill:"currentColor",d:"M289.088 296.704h92.992a32 32 0 0 1 0 64H232.96a32 32 0 0 1-32-32V179.712a32 32 0 0 1 64 0v50.56a384 384 0 0 1 643.84 282.88 384 384 0 0 1-383.936 384 384 384 0 0 1-384-384h64a320 320 0 1 0 640 0 320 320 0 0 0-555.712-216.448z"})]))}}),ee=$,te=t.defineComponent({name:"ZoomIn",__name:"zoom-in",setup(e){return(a,n)=>(t.openBlock(),t.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[t.createElementVNode("path",{fill:"currentColor",d:"m795.904 750.72 124.992 124.928a32 32 0 0 1-45.248 45.248L750.656 795.904a416 416 0 1 1 45.248-45.248zM480 832a352 352 0 1 0 0-704 352 352 0 0 0 0 704m-32-384v-96a32 32 0 0 1 64 0v96h96a32 32 0 0 1 0 64h-96v96a32 32 0 0 1-64 0v-96h-96a32 32 0 0 1 0-64z"})]))}}),ne=te,ae=t.defineComponent({name:"ZoomOut",__name:"zoom-out",setup(e){return(a,n)=>(t.openBlock(),t.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[t.createElementVNode("path",{fill:"currentColor",d:"m795.904 750.72 124.992 124.928a32 32 0 0 1-45.248 45.248L750.656 795.904a416 416 0 1 1 45.248-45.248zM480 832a352 352 0 1 0 0-704 352 352 0 0 0 0 704M352 448h256a32 32 0 0 1 0 64H352a32 32 0 0 1 0-64"})]))}}),re=ae;const oe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANgAAADYCAMAAAC+/t3fAAAAaVBMVEUAAABWapNVapKeqsLJztx3hKnGzN2yu8////9XapWcqMGps8lXapVYa5RWaZWps8lfcJjS1+KjrsVXapWapr////9sfaKrtMrV2uWBj7B4iKqWob1wgaXr7fOBj6/Ax9dhc5yhq8OKl7Wba+6tAAAAE3RSTlMAgGDuDyVLoYDe2XuXRb68cy6e4BCQEAAAAyZJREFUeNrt29tyokAUheGOQjIoeMhuCQ4e0Pd/yCE1STU4mGq7bXqzZ/23ufoqYblTqkIIIYQQQggNlM42Lzctf5nMD22bKQYVOQ30sTPt6dEO74mKXLoiCgDTi1RFbUMUBhZXluQUDKbnWxWtjMLB2pYqUjmFg8WUzSg0TL+rCKVZeJheRJj9DYWHRRnHbBSYnr+qcSsoKCyeLKcfK/emc2UqH4LFGMcVWVftTC4w/TbmhGQjwvR6RBmNAbMYx4nD7k/I1GF3ZZOH3RtHAbDhcZQAG5SJgOn1Vt0mAzYwIUJgvjJ/2OVo2pcmcoQZWehxpBGue5sJEQTryyTBeuMoCtadEFmwjkwYzIyjNJief02IONj3OAqE/ZVJhJnZj3RS1c4nld04ijiC/5EJhbUyobBWJhT2OY5CYa1MKKyVCYXpdSIUphdbobB2HIXCWplQmJGFhZUn07kyNaFgbUsx1/1tb1Jh+i1hDmu0Y+uEN4xqV9ki5Q27atfmKWtYqd1lW84wqj1kr5xhB+3RkjGMrl4yxrCm9pG984V5ytZJ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sciTg8YGGHG/ZUKcS2BI7y9/5j7SsnrXJLjW0otqIbBQisvG5NEiLRxYSl6w4KzE1m3FLonPCG5ugnCLBoN6qUmXQ0Ta/5MWAx+wuVjv1L+K/xHgNmspxSqbAuMcL0DAaMxRopCn2UWPJj+3/NJutXiYGAWaxUI/0qkbndKQhYXJTK50j9wYDF7Me+LQKBVWc2of5gwNis1kzdAYGt3nIJdQcDFpM9DTF1BgQ2u1fja2dAYMHbLqHOgMDCsW352w8iCKweWDHffhBBYOyba2Nabz+IKDB3eFk+36+IILDQXPlQRnpdKLC0d+W9sjMoMN8kJY04woEC+6kbJY05dIMC86OPSaHA0ugREQWWR7tQYP/atZcUBmEoCsNHA4FEBxHvyKJQ7P7X2EGdlHbiNYNjON8OfvIkZP2Zi9tqV7CE2V77TyxL2PdkXJ52GUuYvZbKL1IsYcfr9GPbq2WxhJ2gMIUpTGEcFKYwEgpTGAmFKYyEwhRGQmEKI+EJy3YDCeeNdgOesMH4ZTgk4zfAoxi9GR6dsctwCfRD1sNnNm7HCmtuY8wRH42dZSXCL/CW5QQcmtoax4iLIuOglQkVpIHrPlzGPqCSNE8diT4FiIiIiIjIP2/v9e/hKQXqEwAAAABJRU5ErkJggg==",ce=new Set(["jpg","jpeg","png","gif","webp","bmp","svg","avif","ico"]),le=new Set(["mp4","webm","ogg","ogv","mov","m4v"]),se=new Set(["mp3","wav","ogg","oga","m4a","aac","flac"]),ue=new Set(["html","htm","txt","json","xml","csv","md","log"]),de=new Set(["doc","docx","xls","xlsx","ppt","pptx","zip","rar","7z"]);let A=null,N=null,P=null;async function me(){return N||(N=Promise.all([Promise.resolve().then(()=>require("../pdf-Da0bm_Ya.cjs")),Promise.resolve().then(()=>require("../pdf.worker.min-BAJUPwg6.cjs"))]).then(([e,a])=>(e.GlobalWorkerOptions.workerSrc=a.default,e))),N}function ve(e){return typeof e=="string"?{url:e}:e}function H(e){const[a]=e.split(/[?#]/);return a??""}function U(e,a){if(a?.trim())return a.trim();const n=H(e).split("/").filter(Boolean).pop();if(!n)return"附件预览";try{return decodeURIComponent(n)}catch{return n}}function I(e){return H(e).match(/\.([a-z0-9]+)$/i)?.[1]?.toLowerCase()??""}function fe(e){return e?.trim().replace(/^\./,"").toLowerCase()??""}function he(e){const a=fe(e);return ce.has(a)?"image":a==="pdf"?"pdf":le.has(a)?"video":se.has(a)?"audio":ue.has(a)?"iframe":de.has(a)?"unsupported":"unknown"}function S(e){const a=e.toLowerCase().split(";")[0]?.trim()??"";return a.startsWith("image/")?"image":a==="application/pdf"?"pdf":a.startsWith("video/")?"video":a.startsWith("audio/")?"audio":a.startsWith("text/")?"iframe":"unknown"}function R(e){if(!e.url.trim())return"empty";if(e.mode&&e.mode!=="auto")return e.mode;if(e.mimeType){const n=S(e.mimeType);if(n!=="unknown")return n}const a=he(e.extension||I(e.name||"")||I(e.url));return a!=="unknown"?a:"unknown"}async function we(e){try{const n=(await fetch(e,{method:"HEAD"})).headers.get("content-type")??"";return S(n)}catch{return"unknown"}}async function z(e){const a=await fetch(e);if(!a.ok)throw new Error(`fetch failed: ${a.status}`);return a.blob()}function pe(e,a){const n=I(a);return n==="doc"||n==="docx"?"W":n==="xls"||n==="xlsx"?"X":n==="ppt"||n==="pptx"?"P":n==="zip"||n==="rar"||n==="7z"?"ZIP":e==="pdf"?"PDF":"FILE"}function W(e,a,n){return t.h("button",{class:n,type:"button",onClick:()=>{q(e,a)}},[t.h(B.ElIcon,{class:"jt-attachment-preview-service__download-icon"},()=>t.h(Z)),t.h("span",{class:"jt-attachment-preview-service__download-text"},"下载")])}function J(e){return e==="image"||e==="pdf"}function K(e){return t.h("div",{class:"jt-attachment-preview-service__preview-fallback"},[t.h("img",{class:"jt-attachment-preview-service__preview-fallback-icon",src:e.icon,alt:""}),t.h("div",{class:"jt-attachment-preview-service__unsupported-text"},"暂不支持预览此类型的文件"),t.h("div",{class:"jt-attachment-preview-service__file-name",title:e.name},e.name)])}function O(e,a){const n=document.createElement("a");n.href=e,n.download=a,n.style.display="none",document.body.appendChild(n),n.click(),n.remove()}async function q(e,a){try{const n=await z(e),c=URL.createObjectURL(n);O(c,a),URL.revokeObjectURL(c)}catch{O(e,a)}}const ge=t.defineComponent({name:"JtAttachmentPreviewPdfCanvas",props:{url:{type:String,required:!0},name:{type:String,required:!0},downloadName:{type:String,required:!0},downloadable:{type:Boolean,required:!0}},emits:{previewLoad:e=>e instanceof Event,previewError:e=>e instanceof Event},setup(e,{emit:a}){const n=t.ref("loading"),c=t.ref([]),o=t.ref([]),i=new Map,u=t.ref("");let d=null,h=[],v=0;async function m(r,s){if(!s)return null;const f=typeof s=="string"?await r.getDestination(s):s;return!Array.isArray(f)||!f[0]?null:await r.getPageIndex(f[0])+1}async function _(r,s,f=0){if(!s?.length)return[];const b=[];for(const E of s){const j=await m(r,E.dest);b.push({title:E.title||"未命名标题",pageNumber:j,level:f});const g=await _(r,E.items,f+1);b.push(...g)}return b}function p(){v+=1;for(const r of h)r.cancel();h=[],d?.destroy(),d=null,i.clear()}async function D(){p();const r=v;n.value="loading",u.value="",c.value=[],o.value=[];try{const s=await me();if(r!==v)return;d=s.getDocument({url:e.url});const f=await d.promise;if(r!==v)return;c.value=Array.from({length:f.numPages},(j,g)=>g+1),o.value=await _(f,await f.getOutline()),await t.nextTick();const b=i.values().next().value,E=Math.max((b?.parentElement?.clientWidth??800)-32,320);for(const j of c.value){if(r!==v)return;const g=await f.getPage(j),y=i.get(j),x=y?.getContext("2d");if(!y||!x)continue;const M=g.getViewport({scale:1}),Y=Math.min(E/M.width,2),l=g.getViewport({scale:Y}),L=window.devicePixelRatio||1;y.width=Math.floor(l.width*L),y.height=Math.floor(l.height*L),y.style.width=`${Math.floor(l.width)}px`,y.style.height=`${Math.floor(l.height)}px`,x.setTransform(L,0,0,L,0,0);const G=g.render({canvas:y,canvasContext:x,viewport:l});h.push(G),await G.promise}if(r!==v)return;n.value="ready",a("previewLoad",new Event("load"))}catch(s){if(r!==v)return;n.value="error",u.value=s instanceof Error?s.message:"PDF 加载失败",a("previewError",new Event("error"))}}t.watch(()=>e.url,D,{immediate:!0}),t.onBeforeUnmount(p);function w(r){if(!r)return;i.get(r)?.scrollIntoView({behavior:"smooth",block:"start"})}return()=>t.h("div",{class:"jt-attachment-preview-service__pdf-viewer"},[n.value==="loading"?t.h("div",{class:"jt-attachment-preview-service__pdf-state"},"PDF 加载中..."):null,n.value==="error"?t.h("div",{class:"jt-attachment-preview-service__pdf-state"},[K({icon:ie,name:e.name})]):null,null,null,t.h("div",{class:["jt-attachment-preview-service__pdf-layout",n.value!=="ready"?"jt-attachment-preview-service__pdf-layout--hidden":""]},[o.value.length?t.h("aside",{class:"jt-attachment-preview-service__pdf-outline"},[t.h("div",{class:"jt-attachment-preview-service__pdf-outline-title"},"目录"),t.h("div",{class:"jt-attachment-preview-service__pdf-outline-list"},o.value.map((r,s)=>t.h("button",{key:`${r.title}-${s}`,class:"jt-attachment-preview-service__pdf-outline-item",style:{paddingLeft:`${12+r.level*14}px`},type:"button",disabled:!r.pageNumber,title:r.title,onClick:()=>w(r.pageNumber)},r.title)))]):null,t.h("div",{class:"jt-attachment-preview-service__pdf-pages"},c.value.map(r=>t.h("canvas",{key:r,ref:s=>{s instanceof HTMLCanvasElement&&i.set(r,s)},class:"jt-attachment-preview-service__pdf-page"})))])])}}),ye=t.defineComponent({name:"JtAttachmentPreviewImageTransform",props:{url:{type:String,required:!0},name:{type:String,required:!0},downloadName:{type:String,required:!0},downloadable:{type:Boolean,required:!0},fit:{type:String,default:"contain"}},emits:{previewLoad:e=>e instanceof Event,previewError:e=>e instanceof Event},setup(e,{emit:a}){const n=t.ref(null),c=t.ref("ready"),o=t.ref(1),i=t.ref(!1);let u=0,d=0,h=0,v=0,m=0,_=0,p=0;const D=t.computed(()=>({"--jt-attachment-preview-service-image-fit":e.fit,transform:`translate(${u}px, ${d}px) scale(${o.value})`}));function w(){n.value&&(n.value.style.transform=`translate(${u}px, ${d}px) scale(${o.value})`)}function r(){p||(p=window.requestAnimationFrame(()=>{p=0,w()}))}function s(l){o.value=Math.min(Math.max(Number(l.toFixed(2)),.2),5),o.value<=1&&(u=0,d=0),w()}function f(){s(o.value+.2)}function b(){const l=Math.max(Number((o.value-.2).toFixed(2)),.2);o.value=l,l<=1&&(u=0,d=0),w()}function E(){u=0,d=0,s(1)}function j(l){c.value="ready",a("previewLoad",l)}function g(l){c.value="error",a("previewError",l)}function y(l){o.value<=1||(l.preventDefault(),i.value=!0,h=l.clientX,v=l.clientY,m=u,_=d,window.addEventListener("pointermove",x),window.addEventListener("pointerup",M,{once:!0}))}function x(l){i.value&&(u=m+l.clientX-h,d=_+l.clientY-v,r())}function M(){i.value=!1,window.removeEventListener("pointermove",x)}function Y(l){l.preventDefault(),s(o.value+(l.deltaY<0?.1:-.1))}return t.onMounted(w),t.watch(()=>e.url,()=>{c.value="ready",E()}),t.onBeforeUnmount(()=>{window.removeEventListener("pointermove",x),p&&window.cancelAnimationFrame(p)}),()=>t.h("div",{class:"jt-attachment-preview-service__image-viewer"},c.value==="error"?K({icon:oe,name:e.name}):[t.h("img",{ref:n,class:["jt-attachment-preview-service__media","jt-attachment-preview-service__image",o.value>1?"jt-attachment-preview-service__image--draggable":"",i.value?"jt-attachment-preview-service__image--dragging":""],src:e.url,alt:e.name,style:D.value,onLoad:j,onError:g,onPointerdown:y,onWheel:Y,onDragstart:l=>l.preventDefault(),draggable:!1}),t.h("div",{class:"jt-attachment-preview-service__image-toolbar"},[t.h("button",{class:"jt-attachment-preview-service__image-tool",type:"button",title:"缩小",onClick:b},[t.h(B.ElIcon,()=>t.h(re))]),t.h("span",{class:"jt-attachment-preview-service__image-scale"},`${Math.round(o.value*100)}%`),t.h("button",{class:"jt-attachment-preview-service__image-tool",type:"button",title:"放大",onClick:f},[t.h(B.ElIcon,()=>t.h(ne))]),t.h("button",{class:"jt-attachment-preview-service__image-tool",type:"button",title:"复位",onClick:E},[t.h(B.ElIcon,()=>t.h(ee))])])])}}),Ae=t.defineComponent({name:"JtAttachmentPreviewService",props:{options:{type:Object,required:!0},onDestroy:{type:Function,required:!0}},setup(e){const a=t.computed(()=>U(e.options.url,e.options.name)),n=t.computed(()=>e.options.downloadName||a.value),c=t.computed(()=>R(e.options)),o=t.computed(()=>pe(c.value,e.options.url)),i=t.computed(()=>({zIndex:e.options.zIndex??3e3,"--jt-attachment-preview-service-image-fit":e.options.fit??"contain"}));function u(){e.options.onClose?.(),e.onDestroy()}function d(m){m.key==="Escape"&&e.options.closeOnPressEscape!==!1&&u()}function h(m){e.options.onLoad?.(m)}function v(m){e.options.onError?.(m)}return t.onMounted(()=>{document.addEventListener("keydown",d),document.body.classList.add("jt-attachment-preview-service-lock")}),t.onBeforeUnmount(()=>{document.removeEventListener("keydown",d),document.body.classList.remove("jt-attachment-preview-service-lock")}),()=>{const m=e.options.downloadable===!1?[]:[W(e.options.url,n.value,"jt-attachment-preview-service__top-download")];return t.h("div",{class:"jt-attachment-preview-service",style:i.value},[t.h("div",{class:"jt-attachment-preview-service__modal"},[t.h("div",{class:"jt-attachment-preview-service__header"},[t.h("div",{class:"jt-attachment-preview-service__filename",title:a.value},a.value),t.h("div",{class:"jt-attachment-preview-service__header-actions"},[...m,t.h("button",{class:"jt-attachment-preview-service__close",type:"button","aria-label":"关闭",onClick:u},"×")])]),t.h("div",{class:"jt-attachment-preview-service__body"},[_e({type:c.value,url:e.options.url,name:a.value,downloadName:n.value,sandbox:e.options.sandbox,iconText:o.value,downloadable:e.options.downloadable!==!1,onLoad:h,onError:v})])])])}}}),C=t.defineComponent({name:"JtAttachmentPreviewDetectingService",props:{options:{type:Object,required:!0},onDestroy:{type:Function,required:!0},title:{type:String,default:"正在识别文件类型"},desc:{type:String,default:"请稍候,识别完成后将自动预览或下载"},spinning:{type:Boolean,default:!0}},setup(e){const a=t.computed(()=>U(e.options.url,e.options.name)),n=t.computed(()=>({zIndex:e.options.zIndex??3e3}));function c(){e.options.onClose?.(),e.onDestroy()}function o(i){i.key==="Escape"&&e.options.closeOnPressEscape!==!1&&c()}return t.onMounted(()=>{document.addEventListener("keydown",o),document.body.classList.add("jt-attachment-preview-service-lock")}),t.onBeforeUnmount(()=>{document.removeEventListener("keydown",o),document.body.classList.remove("jt-attachment-preview-service-lock")}),()=>t.h("div",{class:"jt-attachment-preview-service",style:n.value},[t.h("div",{class:"jt-attachment-preview-service__modal"},[t.h("div",{class:"jt-attachment-preview-service__header"},[t.h("div",{class:"jt-attachment-preview-service__filename",title:a.value},a.value),t.h("div",{class:"jt-attachment-preview-service__header-actions"},[t.h("button",{class:"jt-attachment-preview-service__close",type:"button","aria-label":"关闭",onClick:c},"×")])]),t.h("div",{class:"jt-attachment-preview-service__body"},[t.h("div",{class:"jt-attachment-preview-service__detecting"},[e.spinning?t.h("span",{class:"jt-attachment-preview-service__detecting-spinner"}):null,t.h("span",{class:"jt-attachment-preview-service__detecting-title"},e.title),t.h("span",{class:"jt-attachment-preview-service__detecting-desc"},e.desc)])])])])}});function _e(e){return e.type==="empty"?t.h("div",{class:"jt-attachment-preview-service__empty"},"暂无附件"):e.type==="image"?t.h(ye,{url:e.url,name:e.name,downloadName:e.downloadName,downloadable:e.downloadable,onPreviewLoad:e.onLoad,onPreviewError:e.onError}):e.type==="video"?t.h("video",{class:"jt-attachment-preview-service__media",src:e.url,controls:!0,onLoadeddata:e.onLoad,onError:e.onError}):e.type==="audio"?t.h("audio",{class:"jt-attachment-preview-service__audio",src:e.url,controls:!0,onLoadeddata:e.onLoad,onError:e.onError}):e.type==="pdf"?t.h(ge,{url:e.url,name:e.name,downloadName:e.downloadName,downloadable:e.downloadable,onPreviewLoad:e.onLoad,onPreviewError:e.onError}):e.type==="iframe"?t.h("iframe",{class:"jt-attachment-preview-service__iframe",src:e.url,title:e.name,sandbox:e.sandbox||void 0,onLoad:e.onLoad}):t.h("div",{class:"jt-attachment-preview-service__unsupported"},[t.h("div",{class:"jt-attachment-preview-service__file-card"},[t.h("div",{class:"jt-attachment-preview-service__file-icon"},e.iconText),t.h("div",{class:"jt-attachment-preview-service__unsupported-text"},"暂不支持预览此类型的文件")]),t.h("div",{class:"jt-attachment-preview-service__file-name",title:e.name},e.name),e.downloadable?W(e.url,e.downloadName,"jt-attachment-preview-service__primary-download"):null])}function k(e,a){try{t.render(e,a)}catch(n){console.error("[JtAttachmentPreview] render failed",n)}}function T(e){window.setTimeout(()=>{try{t.render(null,e)}catch(a){console.error("[JtAttachmentPreview] unmount failed",a)}e.remove()},0)}function Q(e,a){const n=ve(e),c=n.downloadName||U(n.url,n.name);let o=!1,i=a?.container??null,u=null;const d=()=>{o||(o=!0,i&&(T(i),i=null),u&&(URL.revokeObjectURL(u),u=null),a?.onClose?.(),A?.close===d&&(A=null))};function h(){o||(i||(i=document.createElement("div"),document.body.appendChild(i)),k(t.h(Ae,{options:n,onDestroy:d}),i))}function v(){o||(i||(i=document.createElement("div"),document.body.appendChild(i)),k(t.h(C,{options:n,onDestroy:d}),i))}function m(){i&&(T(i),i=null,a?.onClose?.())}function _(){o||q(n.url,c)}function p(w){if(o)return;const r=URL.createObjectURL(w);O(r,c),URL.revokeObjectURL(r)}const D=R(n);return J(D)?h():D==="unknown"?(v(),we(n.url).then(async w=>{if(!o){if(J(w)){n.mode=w,h();return}try{const r=await z(n.url),s=S(r.type);if(J(s)){u=URL.createObjectURL(r),n.url=u,n.mode=s,h();return}m(),p(r)}catch{m(),_()}}})):(m(),_()),A={close:d},A}function be(e){return typeof document>"u"?{close:()=>{}}:(A?.close(),Q(e))}function V(e){P=e}function F(e){if(typeof document>"u")return{close:()=>{}};A?.close();let a=!1,n=document.createElement("div");document.body.appendChild(n);const c=()=>{a||(a=!0,n&&(T(n),n=null),A?.close===c&&(A=null))},o={close:c};return A=o,P?(k(t.h(C,{options:{url:"",name:"附件预览"},title:"正在获取文件信息",desc:"请稍候,获取完成后将自动预览或下载",spinning:!0,onDestroy:c}),n),P.request(e).then(i=>{if(a)return;const u=P?.mapResponse(i,e);if(!u?.url){k(t.h(C,{options:{url:"",name:"附件预览"},title:"文件信息缺少 URL",desc:"请检查 mapResponse 是否返回了 url 字段",spinning:!1,onDestroy:c}),n);return}const d=Q(u,{container:n,onClose:()=>{a=!0,n=null}});o.close=d.close}).catch(i=>{if(a)return;const u=i instanceof Error?i.message:"接口请求失败";k(t.h(C,{options:{url:"",name:"附件预览"},title:"文件信息获取失败",desc:u,spinning:!1,onDestroy:c}),n)}),o):(k(t.h(C,{options:{url:"",name:"附件预览"},title:"附件预览未初始化",desc:"请先调用 setupJtAttachmentPreview 注册请求配置",spinning:!1,onDestroy:c}),n),o)}const Ee=Object.assign(be,{openByParams:F,setup:V});exports.JtAttachmentPreview=Ee;exports.JtAttachmentPreviewByParams=F;exports.setupJtAttachmentPreview=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let a=null;function n(){return a??=Promise.resolve().then(()=>require("../service-DArBf0bT.cjs")),a}function i(){let t=!1,e=null;return{handler:{close:()=>{t=!0,e?.close()}},setInnerHandler:r=>{if(t){r.close();return}e=r}}}function o(t){const e=i();return n().then(r=>{e.setInnerHandler(r.JtAttachmentPreview(t))}),e.handler}function c(t){n().then(e=>{e.setupJtAttachmentPreview(t)})}function s(t){const e=i();return n().then(r=>{e.setInnerHandler(r.JtAttachmentPreviewByParams(t))}),e.handler}const l=Object.assign(o,{openByParams:s,setup:c});exports.JtAttachmentPreview=l;exports.JtAttachmentPreviewByParams=s;exports.setupJtAttachmentPreview=c;