@jt-home/mfe-components 1.0.23 → 1.0.25

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.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),L=require("element-plus");/*! Element Plus Icons Vue v2.3.2 */var V=t.defineComponent({name:"Download",__name:"download",setup(e){return(n,a)=>(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"})]))}}),F=V,X=t.defineComponent({name:"RefreshLeft",__name:"refresh-left",setup(e){return(n,a)=>(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"})]))}}),Z=X,$=t.defineComponent({name:"ZoomIn",__name:"zoom-in",setup(e){return(n,a)=>(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"})]))}}),ee=$,te=t.defineComponent({name:"ZoomOut",__name:"zoom-out",setup(e){return(n,a)=>(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"})]))}}),ne=te;const ae="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANgAAADYCAMAAAC+/t3fAAAAaVBMVEUAAABWapNVapKeqsLJztx3hKnGzN2yu8////9XapWcqMGps8lXapVYa5RWaZWps8lfcJjS1+KjrsVXapWapr////9sfaKrtMrV2uWBj7B4iKqWob1wgaXr7fOBj6/Ax9dhc5yhq8OKl7Wba+6tAAAAE3RSTlMAgGDuDyVLoYDe2XuXRb68cy6e4BCQEAAAAyZJREFUeNrt29tyokAUheGOQjIoeMhuCQ4e0Pd/yCE1STU4mGq7bXqzZ/23ufoqYblTqkIIIYQQQggNlM42Lzctf5nMD22bKQYVOQ30sTPt6dEO74mKXLoiCgDTi1RFbUMUBhZXluQUDKbnWxWtjMLB2pYqUjmFg8WUzSg0TL+rCKVZeJheRJj9DYWHRRnHbBSYnr+qcSsoKCyeLKcfK/emc2UqH4LFGMcVWVftTC4w/TbmhGQjwvR6RBmNAbMYx4nD7k/I1GF3ZZOH3RtHAbDhcZQAG5SJgOn1Vt0mAzYwIUJgvjJ/2OVo2pcmcoQZWehxpBGue5sJEQTryyTBeuMoCtadEFmwjkwYzIyjNJief02IONj3OAqE/ZVJhJnZj3RS1c4nld04ijiC/5EJhbUyobBWJhT2OY5CYa1MKKyVCYXpdSIUphdbobB2HIXCWplQmJGFhZUn07kyNaFgbUsx1/1tb1Jh+i1hDmu0Y+uEN4xqV9ki5Q27atfmKWtYqd1lW84wqj1kr5xhB+3RkjGMrl4yxrCm9pG984V5ytZ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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==",oe=new Set(["jpg","jpeg","png","gif","webp","bmp","svg","avif","ico"]),ie=new Set(["mp4","webm","ogg","ogv","mov","m4v"]),ce=new Set(["mp3","wav","ogg","oga","m4a","aac","flac"]),le=new Set(["html","htm","txt","json","xml","csv","md","log"]),se=new Set(["doc","docx","xls","xlsx","ppt","pptx","zip","rar","7z"]);let A=null,Y=null,B=null;async function ue(){return Y||(Y=Promise.all([Promise.resolve().then(()=>require("./pdf-Da0bm_Ya.cjs")),Promise.resolve().then(()=>require("./pdf.worker.min-BAJUPwg6.cjs"))]).then(([e,n])=>(e.GlobalWorkerOptions.workerSrc=n.default,e))),Y}function de(e){return typeof e=="string"?{url:e}:e}function S(e){const[n]=e.split(/[?#]/);return n??""}function O(e,n){if(n?.trim())return n.trim();const a=S(e).split("/").filter(Boolean).pop();if(!a)return"附件预览";try{return decodeURIComponent(a)}catch{return a}}function I(e){return S(e).match(/\.([a-z0-9]+)$/i)?.[1]?.toLowerCase()??""}function me(e){return e?.trim().replace(/^\./,"").toLowerCase()??""}function ve(e){const n=me(e);return oe.has(n)?"image":n==="pdf"?"pdf":ie.has(n)?"video":ce.has(n)?"audio":le.has(n)?"iframe":se.has(n)?"unsupported":"unknown"}function T(e){const n=e.toLowerCase().split(";")[0]?.trim()??"";return n.startsWith("image/")?"image":n==="application/pdf"?"pdf":n.startsWith("video/")?"video":n.startsWith("audio/")?"audio":n.startsWith("text/")?"iframe":"unknown"}function G(e){if(!e.url.trim())return"empty";if(e.mode&&e.mode!=="auto")return e.mode;if(e.mimeType){const a=T(e.mimeType);if(a!=="unknown")return a}const n=ve(e.extension||I(e.name||"")||I(e.url));return n!=="unknown"?n:"unknown"}async function fe(e){try{const a=(await fetch(e,{method:"HEAD"})).headers.get("content-type")??"";return T(a)}catch{return"unknown"}}async function R(e){const n=await fetch(e);if(!n.ok)throw new Error(`fetch failed: ${n.status}`);return n.blob()}function he(e,n){const a=I(n);return a==="doc"||a==="docx"?"W":a==="xls"||a==="xlsx"?"X":a==="ppt"||a==="pptx"?"P":a==="zip"||a==="rar"||a==="7z"?"ZIP":e==="pdf"?"PDF":"FILE"}function z(e,n,a){return t.h("button",{class:a,type:"button",onClick:()=>{W(e,n)}},[t.h(L.ElIcon,{class:"jt-attachment-preview-service__download-icon"},()=>t.h(F)),t.h("span",{class:"jt-attachment-preview-service__download-text"},"下载")])}function N(e){return e==="image"||e==="pdf"}function H(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 J(e,n){const a=document.createElement("a");a.href=e,a.download=n,a.style.display="none",document.body.appendChild(a),a.click(),a.remove()}async function W(e,n){try{const a=await R(e),o=URL.createObjectURL(a);J(o,n),URL.revokeObjectURL(o)}catch{J(e,n)}}const pe=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:n}){const a=t.ref("loading"),o=t.ref([]),r=t.ref([]),l=new Map,s=t.ref("");let d=null,w=[],m=0;async function v(i,u){if(!u)return null;const h=typeof u=="string"?await i.getDestination(u):u;return!Array.isArray(h)||!h[0]?null:await i.getPageIndex(h[0])+1}async function j(i,u,h=0){if(!u?.length)return[];const b=[];for(const E of u){const x=await v(i,E.dest);b.push({title:E.title||"未命名标题",pageNumber:x,level:h});const g=await j(i,E.items,h+1);b.push(...g)}return b}function p(){m+=1;for(const i of w)i.cancel();w=[],d?.destroy(),d=null,l.clear()}async function _(){p();const i=m;a.value="loading",s.value="",o.value=[],r.value=[];try{const u=await ue();if(i!==m)return;d=u.getDocument({url:e.url});const h=await d.promise;if(i!==m)return;o.value=Array.from({length:h.numPages},(x,g)=>g+1),r.value=await j(h,await h.getOutline()),await t.nextTick();const b=l.values().next().value,E=Math.max((b?.parentElement?.clientWidth??800)-32,320);for(const x of o.value){if(i!==m)return;const g=await h.getPage(x),y=l.get(x),D=y?.getContext("2d");if(!y||!D)continue;const M=g.getViewport({scale:1}),P=Math.min(E/M.width,2),c=g.getViewport({scale:P}),C=window.devicePixelRatio||1;y.width=Math.floor(c.width*C),y.height=Math.floor(c.height*C),y.style.width=`${Math.floor(c.width)}px`,y.style.height=`${Math.floor(c.height)}px`,D.setTransform(C,0,0,C,0,0);const U=g.render({canvas:y,canvasContext:D,viewport:c});w.push(U),await U.promise}if(i!==m)return;a.value="ready",n("previewLoad",new Event("load"))}catch(u){if(i!==m)return;a.value="error",s.value=u instanceof Error?u.message:"PDF 加载失败",n("previewError",new Event("error"))}}t.watch(()=>e.url,_,{immediate:!0}),t.onBeforeUnmount(p);function f(i){if(!i)return;l.get(i)?.scrollIntoView({behavior:"smooth",block:"start"})}return()=>t.h("div",{class:"jt-attachment-preview-service__pdf-viewer"},[a.value==="loading"?t.h("div",{class:"jt-attachment-preview-service__pdf-state"},"PDF 加载中..."):null,a.value==="error"?t.h("div",{class:"jt-attachment-preview-service__pdf-state"},[H({icon:re,name:e.name})]):null,null,null,t.h("div",{class:["jt-attachment-preview-service__pdf-layout",a.value!=="ready"?"jt-attachment-preview-service__pdf-layout--hidden":""]},[r.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"},r.value.map((i,u)=>t.h("button",{key:`${i.title}-${u}`,class:"jt-attachment-preview-service__pdf-outline-item",style:{paddingLeft:`${12+i.level*14}px`},type:"button",disabled:!i.pageNumber,title:i.title,onClick:()=>f(i.pageNumber)},i.title)))]):null,t.h("div",{class:"jt-attachment-preview-service__pdf-pages"},o.value.map(i=>t.h("canvas",{key:i,ref:u=>{u instanceof HTMLCanvasElement&&l.set(i,u)},class:"jt-attachment-preview-service__pdf-page"})))])])}}),we=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:n}){const a=t.ref(null),o=t.ref("ready"),r=t.ref(1),l=t.ref(!1);let s=0,d=0,w=0,m=0,v=0,j=0,p=0;const _=t.computed(()=>({"--jt-attachment-preview-service-image-fit":e.fit,transform:`translate(${s}px, ${d}px) scale(${r.value})`}));function f(){a.value&&(a.value.style.transform=`translate(${s}px, ${d}px) scale(${r.value})`)}function i(){p||(p=window.requestAnimationFrame(()=>{p=0,f()}))}function u(c){r.value=Math.min(Math.max(Number(c.toFixed(2)),.2),5),r.value<=1&&(s=0,d=0),f()}function h(){u(r.value+.2)}function b(){const c=Math.max(Number((r.value-.2).toFixed(2)),.2);r.value=c,c<=1&&(s=0,d=0),f()}function E(){s=0,d=0,u(1)}function x(c){o.value="ready",n("previewLoad",c)}function g(c){o.value="error",n("previewError",c)}function y(c){r.value<=1||(c.preventDefault(),l.value=!0,w=c.clientX,m=c.clientY,v=s,j=d,window.addEventListener("pointermove",D),window.addEventListener("pointerup",M,{once:!0}))}function D(c){l.value&&(s=v+c.clientX-w,d=j+c.clientY-m,i())}function M(){l.value=!1,window.removeEventListener("pointermove",D)}function P(c){c.preventDefault(),u(r.value+(c.deltaY<0?.1:-.1))}return t.onMounted(f),t.watch(()=>e.url,()=>{o.value="ready",E()}),t.onBeforeUnmount(()=>{window.removeEventListener("pointermove",D),p&&window.cancelAnimationFrame(p)}),()=>t.h("div",{class:"jt-attachment-preview-service__image-viewer"},o.value==="error"?H({icon:ae,name:e.name}):[t.h("img",{ref:a,class:["jt-attachment-preview-service__media","jt-attachment-preview-service__image",r.value>1?"jt-attachment-preview-service__image--draggable":"",l.value?"jt-attachment-preview-service__image--dragging":""],src:e.url,alt:e.name,style:_.value,onLoad:x,onError:g,onPointerdown:y,onWheel:P,onDragstart:c=>c.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(L.ElIcon,()=>t.h(ne))]),t.h("span",{class:"jt-attachment-preview-service__image-scale"},`${Math.round(r.value*100)}%`),t.h("button",{class:"jt-attachment-preview-service__image-tool",type:"button",title:"放大",onClick:h},[t.h(L.ElIcon,()=>t.h(ee))]),t.h("button",{class:"jt-attachment-preview-service__image-tool",type:"button",title:"复位",onClick:E},[t.h(L.ElIcon,()=>t.h(Z))])])])}}),ge=t.defineComponent({name:"JtAttachmentPreviewService",props:{options:{type:Object,required:!0},onDestroy:{type:Function,required:!0}},setup(e){const n=t.computed(()=>O(e.options.url,e.options.name)),a=t.computed(()=>e.options.downloadName||n.value),o=t.computed(()=>G(e.options)),r=t.computed(()=>he(o.value,e.options.url)),l=t.computed(()=>({zIndex:e.options.zIndex??3e3,"--jt-attachment-preview-service-image-fit":e.options.fit??"contain"}));function s(){e.options.onClose?.(),e.onDestroy()}function d(v){v.key==="Escape"&&e.options.closeOnPressEscape!==!1&&s()}function w(v){e.options.onLoad?.(v)}function m(v){e.options.onError?.(v)}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 v=e.options.downloadable===!1?[]:[z(e.options.url,a.value,"jt-attachment-preview-service__top-download")];return t.h("div",{class:"jt-attachment-preview-service",style:l.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:n.value},n.value),t.h("div",{class:"jt-attachment-preview-service__header-actions"},[...v,t.h("button",{class:"jt-attachment-preview-service__close",type:"button","aria-label":"关闭",onClick:s},"×")])]),t.h("div",{class:"jt-attachment-preview-service__body"},[ye({type:o.value,url:e.options.url,name:n.value,downloadName:a.value,sandbox:e.options.sandbox,iconText:r.value,downloadable:e.options.downloadable!==!1,onLoad:w,onError:m})])])])}}}),k=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 n=t.computed(()=>O(e.options.url,e.options.name)),a=t.computed(()=>({zIndex:e.options.zIndex??3e3}));function o(){e.options.onClose?.(),e.onDestroy()}function r(l){l.key==="Escape"&&e.options.closeOnPressEscape!==!1&&o()}return t.onMounted(()=>{document.addEventListener("keydown",r),document.body.classList.add("jt-attachment-preview-service-lock")}),t.onBeforeUnmount(()=>{document.removeEventListener("keydown",r),document.body.classList.remove("jt-attachment-preview-service-lock")}),()=>t.h("div",{class:"jt-attachment-preview-service",style:a.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:n.value},n.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:o},"×")])]),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 ye(e){return e.type==="empty"?t.h("div",{class:"jt-attachment-preview-service__empty"},"暂无附件"):e.type==="image"?t.h(we,{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(pe,{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?z(e.url,e.downloadName,"jt-attachment-preview-service__primary-download"):null])}function K(e){if(typeof document>"u")return{close:()=>{}};A?.close();const n=de(e),a=n.downloadName||O(n.url,n.name);let o=!1,r=null,l=null;const s=()=>{o=!0,r&&(t.render(null,r),r.remove(),r=null),l&&(URL.revokeObjectURL(l),l=null),A?.close===s&&(A=null)};function d(){o||(r||(r=document.createElement("div"),document.body.appendChild(r)),t.render(t.h(ge,{options:n,onDestroy:s}),r))}function w(){o||(r||(r=document.createElement("div"),document.body.appendChild(r)),t.render(t.h(k,{options:n,onDestroy:s}),r))}function m(){r&&(t.render(null,r),r.remove(),r=null)}function v(){o||W(n.url,a)}function j(_){if(o)return;const f=URL.createObjectURL(_);J(f,a),URL.revokeObjectURL(f)}const p=G(n);return N(p)?d():p==="unknown"?(w(),fe(n.url).then(async _=>{if(!o){if(N(_)){n.mode=_,d();return}try{const f=await R(n.url),i=T(f.type);if(N(i)){l=URL.createObjectURL(f),n.url=l,n.mode=i,d();return}m(),j(f)}catch{m(),v()}}})):v(),A={close:s},A}function q(e){B=e}function Q(e){if(typeof document>"u")return{close:()=>{}};A?.close();let n=!1,a=document.createElement("div");document.body.appendChild(a);const o=()=>{n=!0,a&&(t.render(null,a),a.remove(),a=null),A?.close===o&&(A=null)},r={close:o};return A=r,B?(t.render(t.h(k,{options:{url:"",name:"附件预览"},title:"正在获取文件信息",desc:"请稍候,获取完成后将自动预览或下载",spinning:!0,onDestroy:o}),a),B.request(e).then(l=>{if(n)return;const s=B?.mapResponse(l,e);if(!s?.url){t.render(t.h(k,{options:{url:"",name:"附件预览"},title:"文件信息缺少 URL",desc:"请检查 mapResponse 是否返回了 url 字段",spinning:!1,onDestroy:o}),a);return}K(s)}).catch(l=>{if(n)return;const s=l instanceof Error?l.message:"接口请求失败";t.render(t.h(k,{options:{url:"",name:"附件预览"},title:"文件信息获取失败",desc:s,spinning:!1,onDestroy:o}),a)}),r):(t.render(t.h(k,{options:{url:"",name:"附件预览"},title:"附件预览未初始化",desc:"请先调用 setupJtAttachmentPreview 注册请求配置",spinning:!1,onDestroy:o}),a),r)}const Ae=Object.assign(K,{openByParams:Q,setup:q});exports.JtAttachmentPreview=Ae;exports.JtAttachmentPreviewByParams=Q;exports.setupJtAttachmentPreview=q;