@jt-home/mfe-components 1.0.23 → 1.0.24

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"),L=require("element-plus");/*! Element Plus Icons Vue v2.3.2 */var F=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"})]))}}),X=F,Z=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"})]))}}),$=Z,ee=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"})]))}}),te=ee,ne=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"})]))}}),ae=ne;const re="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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MsciTg8YGGHG/ZUKcS2BI7y9/5j7SsnrXJLjW0otqIbBQisvG5NEiLRxYSl6w4KzE1m3FLonPCG5ugnCLBoN6qUmXQ0Ta/5MWAx+wuVjv1L+K/xHgNmspxSqbAuMcL0DAaMxRopCn2UWPJj+3/NJutXiYGAWaxUI/0qkbndKQhYXJTK50j9wYDF7Me+LQKBVWc2of5gwNis1kzdAYGt3nIJdQcDFpM9DTF1BgQ2u1fja2dAYMHbLqHOgMDCsW352w8iCKweWDHffhBBYOyba2Nabz+IKDB3eFk+36+IILDQXPlQRnpdKLC0d+W9sjMoMN8kJY04woEC+6kbJY05dIMC86OPSaHA0ugREQWWR7tQYP/atZcUBmEoCsNHA4FEBxHvyKJQ7P7X2EGdlHbiNYNjON8OfvIkZP2Zi9tqV7CE2V77TyxL2PdkXJ52GUuYvZbKL1IsYcfr9GPbq2WxhJ2gMIUpTGEcFKYwEgpTGAmFKYyEwhRGQmEKI+EJy3YDCeeNdgOesMH4ZTgk4zfAoxi9GR6dsctwCfRD1sNnNm7HCmtuY8wRH42dZSXCL/CW5QQcmtoax4iLIuOglQkVpIHrPlzGPqCSNE8diT4FiIiIiIjIP2/v9e/hKQXqEwAAAABJRU5ErkJggg==",ie=new Set(["jpg","jpeg","png","gif","webp","bmp","svg","avif","ico"]),ce=new Set(["mp4","webm","ogg","ogv","mov","m4v"]),le=new Set(["mp3","wav","ogg","oga","m4a","aac","flac"]),se=new Set(["html","htm","txt","json","xml","csv","md","log"]),ue=new Set(["doc","docx","xls","xlsx","ppt","pptx","zip","rar","7z"]);let A=null,Y=null,B=null;async function de(){return Y||(Y=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))),Y}function me(e){return typeof e=="string"?{url:e}:e}function G(e){const[a]=e.split(/[?#]/);return a??""}function T(e,a){if(a?.trim())return a.trim();const n=G(e).split("/").filter(Boolean).pop();if(!n)return"附件预览";try{return decodeURIComponent(n)}catch{return n}}function I(e){return G(e).match(/\.([a-z0-9]+)$/i)?.[1]?.toLowerCase()??""}function ve(e){return e?.trim().replace(/^\./,"").toLowerCase()??""}function fe(e){const a=ve(e);return ie.has(a)?"image":a==="pdf"?"pdf":ce.has(a)?"video":le.has(a)?"audio":se.has(a)?"iframe":ue.has(a)?"unsupported":"unknown"}function U(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 H(e){if(!e.url.trim())return"empty";if(e.mode&&e.mode!=="auto")return e.mode;if(e.mimeType){const n=U(e.mimeType);if(n!=="unknown")return n}const a=fe(e.extension||I(e.name||"")||I(e.url));return a!=="unknown"?a:"unknown"}async function he(e){try{const n=(await fetch(e,{method:"HEAD"})).headers.get("content-type")??"";return U(n)}catch{return"unknown"}}async function R(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 z(e,a,n){return t.h("button",{class:n,type:"button",onClick:()=>{K(e,a)}},[t.h(L.ElIcon,{class:"jt-attachment-preview-service__download-icon"},()=>t.h(X)),t.h("span",{class:"jt-attachment-preview-service__download-text"},"下载")])}function N(e){return e==="image"||e==="pdf"}function W(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,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 K(e,a){try{const n=await R(e),c=URL.createObjectURL(n);J(c,a),URL.revokeObjectURL(c)}catch{J(e,a)}}const we=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 w(){v+=1;for(const r of h)r.cancel();h=[],d?.destroy(),d=null,i.clear()}async function D(){w();const r=v;n.value="loading",u.value="",c.value=[],o.value=[];try{const s=await de();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}),P=Math.min(E/M.width,2),l=g.getViewport({scale:P}),C=window.devicePixelRatio||1;y.width=Math.floor(l.width*C),y.height=Math.floor(l.height*C),y.style.width=`${Math.floor(l.width)}px`,y.style.height=`${Math.floor(l.height)}px`,x.setTransform(C,0,0,C,0,0);const S=g.render({canvas:y,canvasContext:x,viewport:l});h.push(S),await S.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(w);function p(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"},[W({icon:oe,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:()=>p(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"})))])])}}),ge=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,w=0;const D=t.computed(()=>({"--jt-attachment-preview-service-image-fit":e.fit,transform:`translate(${u}px, ${d}px) scale(${o.value})`}));function p(){n.value&&(n.value.style.transform=`translate(${u}px, ${d}px) scale(${o.value})`)}function r(){w||(w=window.requestAnimationFrame(()=>{w=0,p()}))}function s(l){o.value=Math.min(Math.max(Number(l.toFixed(2)),.2),5),o.value<=1&&(u=0,d=0),p()}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),p()}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 P(l){l.preventDefault(),s(o.value+(l.deltaY<0?.1:-.1))}return t.onMounted(p),t.watch(()=>e.url,()=>{c.value="ready",E()}),t.onBeforeUnmount(()=>{window.removeEventListener("pointermove",x),w&&window.cancelAnimationFrame(w)}),()=>t.h("div",{class:"jt-attachment-preview-service__image-viewer"},c.value==="error"?W({icon:re,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:P,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(L.ElIcon,()=>t.h(ae))]),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(L.ElIcon,()=>t.h(te))]),t.h("button",{class:"jt-attachment-preview-service__image-tool",type:"button",title:"复位",onClick:E},[t.h(L.ElIcon,()=>t.h($))])])])}}),ye=t.defineComponent({name:"JtAttachmentPreviewService",props:{options:{type:Object,required:!0},onDestroy:{type:Function,required:!0}},setup(e){const a=t.computed(()=>T(e.options.url,e.options.name)),n=t.computed(()=>e.options.downloadName||a.value),c=t.computed(()=>H(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?[]:[z(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"},[Ae({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})])])])}}}),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 a=t.computed(()=>T(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 Ae(e){return e.type==="empty"?t.h("div",{class:"jt-attachment-preview-service__empty"},"暂无附件"):e.type==="image"?t.h(ge,{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(we,{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 O(e){t.render(null,e),queueMicrotask(()=>{e.remove()})}function q(e,a){const n=me(e),c=n.downloadName||T(n.url,n.name);let o=!1,i=a?.container??null,u=null;const d=()=>{o||(o=!0,i&&(O(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)),t.render(t.h(ye,{options:n,onDestroy:d}),i))}function v(){o||(i||(i=document.createElement("div"),document.body.appendChild(i)),t.render(t.h(k,{options:n,onDestroy:d}),i))}function m(){i&&(O(i),i=null,a?.onClose?.())}function _(){o||K(n.url,c)}function w(p){if(o)return;const r=URL.createObjectURL(p);J(r,c),URL.revokeObjectURL(r)}const D=H(n);return N(D)?h():D==="unknown"?(v(),he(n.url).then(async p=>{if(!o){if(N(p)){n.mode=p,h();return}try{const r=await R(n.url),s=U(r.type);if(N(s)){u=URL.createObjectURL(r),n.url=u,n.mode=s,h();return}m(),w(r)}catch{m(),_()}}})):(m(),_()),A={close:d},A}function _e(e){return typeof document>"u"?{close:()=>{}}:(A?.close(),q(e))}function Q(e){B=e}function V(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&&(O(n),n=null),A?.close===c&&(A=null))},o={close:c};return A=o,B?(t.render(t.h(k,{options:{url:"",name:"附件预览"},title:"正在获取文件信息",desc:"请稍候,获取完成后将自动预览或下载",spinning:!0,onDestroy:c}),n),B.request(e).then(i=>{if(a)return;const u=B?.mapResponse(i,e);if(!u?.url){t.render(t.h(k,{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:"接口请求失败";t.render(t.h(k,{options:{url:"",name:"附件预览"},title:"文件信息获取失败",desc:u,spinning:!1,onDestroy:c}),n)}),o):(t.render(t.h(k,{options:{url:"",name:"附件预览"},title:"附件预览未初始化",desc:"请先调用 setupJtAttachmentPreview 注册请求配置",spinning:!1,onDestroy:c}),n),o)}const be=Object.assign(_e,{openByParams:V,setup:Q});exports.JtAttachmentPreview=be;exports.JtAttachmentPreviewByParams=V;exports.setupJtAttachmentPreview=Q;
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/2OVo2pcmcoQZWehxpBGue5sJEQTryyTBeuMoCtadEFmwjkwYzIyjNJief02IONj3OA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LDrFkXEOW5L4/vaWlMtnBgBVdA+N2kOW6yuYnIymQDgosGSt7dtOHcZXOAYHta30L+09luteBwMR+xzJ/KNO9DgTG+wVwh0xt61BgojZTTdb1MILA+NViikO68tiXgsDE6sMcxNsEv4Ra+Jm5rOKsQwYgMJ7OzTmWxb2r7jK3izdc2OmGxTX56871WMsciTg8YGGHG/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,64 +1,64 @@
1
- import { defineComponent as D, openBlock as O, createElementBlock as I, createElementVNode as J, ref as x, watch as F, onBeforeUnmount as T, h as n, computed as E, onMounted as K, nextTick as re, render as C } from "vue";
1
+ import { defineComponent as D, openBlock as J, createElementBlock as O, createElementVNode as I, ref as x, watch as F, onBeforeUnmount as T, h as a, computed as E, onMounted as K, nextTick as oe, render as X } from "vue";
2
2
  import { ElIcon as P } from "element-plus";
3
3
  /*! Element Plus Icons Vue v2.3.2 */
4
4
  var ie = /* @__PURE__ */ D({
5
5
  name: "Download",
6
6
  __name: "download",
7
7
  setup(e) {
8
- return (a, t) => (O(), I("svg", {
8
+ return (n, t) => (J(), O("svg", {
9
9
  xmlns: "http://www.w3.org/2000/svg",
10
10
  viewBox: "0 0 1024 1024"
11
11
  }, [
12
- J("path", {
12
+ I("path", {
13
13
  fill: "currentColor",
14
14
  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"
15
15
  })
16
16
  ]));
17
17
  }
18
- }), oe = ie, ce = /* @__PURE__ */ D({
18
+ }), ce = ie, se = /* @__PURE__ */ D({
19
19
  name: "RefreshLeft",
20
20
  __name: "refresh-left",
21
21
  setup(e) {
22
- return (a, t) => (O(), I("svg", {
22
+ return (n, t) => (J(), O("svg", {
23
23
  xmlns: "http://www.w3.org/2000/svg",
24
24
  viewBox: "0 0 1024 1024"
25
25
  }, [
26
- J("path", {
26
+ I("path", {
27
27
  fill: "currentColor",
28
28
  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"
29
29
  })
30
30
  ]));
31
31
  }
32
- }), se = ce, le = /* @__PURE__ */ D({
32
+ }), le = se, ue = /* @__PURE__ */ D({
33
33
  name: "ZoomIn",
34
34
  __name: "zoom-in",
35
35
  setup(e) {
36
- return (a, t) => (O(), I("svg", {
36
+ return (n, t) => (J(), O("svg", {
37
37
  xmlns: "http://www.w3.org/2000/svg",
38
38
  viewBox: "0 0 1024 1024"
39
39
  }, [
40
- J("path", {
40
+ I("path", {
41
41
  fill: "currentColor",
42
42
  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"
43
43
  })
44
44
  ]));
45
45
  }
46
- }), ue = le, de = /* @__PURE__ */ D({
46
+ }), de = ue, ve = /* @__PURE__ */ D({
47
47
  name: "ZoomOut",
48
48
  __name: "zoom-out",
49
49
  setup(e) {
50
- return (a, t) => (O(), I("svg", {
50
+ return (n, t) => (J(), O("svg", {
51
51
  xmlns: "http://www.w3.org/2000/svg",
52
52
  viewBox: "0 0 1024 1024"
53
53
  }, [
54
- J("path", {
54
+ I("path", {
55
55
  fill: "currentColor",
56
56
  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"
57
57
  })
58
58
  ]));
59
59
  }
60
- }), ve = de;
61
- const me = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANgAAADYCAMAAAC+/t3fAAAAaVBMVEUAAABWapNVapKeqsLJztx3hKnGzN2yu8////9XapWcqMGps8lXapVYa5RWaZWps8lfcJjS1+KjrsVXapWapr////9sfaKrtMrV2uWBj7B4iKqWob1wgaXr7fOBj6/Ax9dhc5yhq8OKl7Wba+6tAAAAE3RSTlMAgGDuDyVLoYDe2XuXRb68cy6e4BCQEAAAAyZJREFUeNrt29tyokAUheGOQjIoeMhuCQ4e0Pd/yCE1STU4mGq7bXqzZ/23ufoqYblTqkIIIYQQQggNlM42Lzctf5nMD22bKQYVOQ30sTPt6dEO74mKXLoiCgDTi1RFbUMUBhZXluQUDKbnWxWtjMLB2pYqUjmFg8WUzSg0TL+rCKVZeJheRJj9DYWHRRnHbBSYnr+qcSsoKCyeLKcfK/emc2UqH4LFGMcVWVftTC4w/TbmhGQjwvR6RBmNAbMYx4nD7k/I1GF3ZZOH3RtHAbDhcZQAG5SJgOn1Vt0mAzYwIUJgvjJ/2OVo2pcmcoQZWehxpBGue5sJEQTryyTBeuMoCtadEFmwjkwYzIyjNJief02IONj3OAqE/ZVJhJnZj3RS1c4nld04ijiC/5EJhbUyobBWJhT2OY5CYa1MKKyVCYXpdSIUphdbobB2HIXCWplQmJGFhZUn07kyNaFgbUsx1/1tb1Jh+i1hDmu0Y+uE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gsDE6sMcxNsEv4Ra+Jm5rOKsQwYgMJ7OzTmWxb2r7jK3izdc2OmGxTX56871WMsciTg8YGGHG/ZUKcS2BI7y9/5j7SsnrXJLjW0otqIbBQisvG5NEiLRxYSl6w4KzE1m3FLonPCG5ugnCLBoN6qUmXQ0Ta/5MWAx+wuVjv1L+K/xHgNmspxSqbAuMcL0DAaMxRopCn2UWPJj+3/NJutXiYGAWaxUI/0qkbndKQhYXJTK50j9wYDF7Me+LQKBVWc2of5gwNis1kzdAYGt3nIJdQcDFpM9DTF1BgQ2u1fja2dAYMHbLqHOgMDCsW352w8iCKweWDHffhBBYOyba2Nabz+IKDB3eFk+36+IILDQXPlQRnpdKLC0d+W9sjMoMN8kJY04woEC+6kbJY05dIMC86OPSaHA0ugREQWWR7tQYP/atZcUBmEoCsNHA4FEBxHvyKJQ7P7X2EGdlHbiNYNjON8OfvIkZP2Zi9tqV7CE2V77TyxL2PdkXJ52GUuYvZbKL1IsYcfr9GPbq2WxhJ2gMIUpTGEcFKYwEgpTGAmFKYyEwhRGQmEKI+EJy3YDCeeNdgOesMH4ZTgk4zfAoxi9GR6dsctwCfRD1sNnNm7HCmtuY8wRH42dZSXCL/CW5QQcmtoax4iLIuOglQkVpIHrPlzGPqCSNE8diT4FiIiIiIjIP2/v9e/hKQXqEwAAAABJRU5ErkJggg==", we = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "webp", "bmp", "svg", "avif", "ico"]), pe = /* @__PURE__ */ new Set(["mp4", "webm", "ogg", "ogv", "mov", "m4v"]), he = /* @__PURE__ */ new Set(["mp3", "wav", "ogg", "oga", "m4a", "aac", "flac"]), ge = /* @__PURE__ */ new Set(["html", "htm", "txt", "json", "xml", "csv", "md", "log"]), ye = /* @__PURE__ */ new Set([
60
+ }), me = ve;
61
+ const fe = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANgAAADYCAMAAAC+/t3fAAAAaVBMVEUAAABWapNVapKeqsLJztx3hKnGzN2yu8////9XapW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CsNHA4FEBxHvyKJQ7P7X2EGdlHbiNYNjON8OfvIkZP2Zi9tqV7CE2V77TyxL2PdkXJ52GUuYvZbKL1IsYcfr9GPbq2WxhJ2gMIUpTGEcFKYwEgpTGAmFKYyEwhRGQmEKI+EJy3YDCeeNdgOesMH4ZTgk4zfAoxi9GR6dsctwCfRD1sNnNm7HCmtuY8wRH42dZSXCL/CW5QQcmtoax4iLIuOglQkVpIHrPlzGPqCSNE8diT4FiIiIiIjIP2/v9e/hKQXqEwAAAABJRU5ErkJggg==", pe = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "webp", "bmp", "svg", "avif", "ico"]), he = /* @__PURE__ */ new Set(["mp4", "webm", "ogg", "ogv", "mov", "m4v"]), ge = /* @__PURE__ */ new Set(["mp3", "wav", "ogg", "oga", "m4a", "aac", "flac"]), ye = /* @__PURE__ */ new Set(["html", "htm", "txt", "json", "xml", "csv", "md", "log"]), Ae = /* @__PURE__ */ new Set([
62
62
  "doc",
63
63
  "docx",
64
64
  "xls",
@@ -70,22 +70,22 @@ const me = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANgAAADYCAMAAAC+/t3fAA
70
70
  "7z"
71
71
  ]);
72
72
  let A = null, U = null, N = null;
73
- async function Ae() {
73
+ async function _e() {
74
74
  return U || (U = Promise.all([
75
75
  import("../pdf-BmBuG7of.js"),
76
76
  import("../pdf.worker.min-4PI-nNLo.js")
77
- ]).then(([e, a]) => (e.GlobalWorkerOptions.workerSrc = a.default, e))), U;
77
+ ]).then(([e, n]) => (e.GlobalWorkerOptions.workerSrc = n.default, e))), U;
78
78
  }
79
- function _e(e) {
79
+ function be(e) {
80
80
  return typeof e == "string" ? { url: e } : e;
81
81
  }
82
- function X(e) {
83
- const [a] = e.split(/[?#]/);
84
- return a ?? "";
82
+ function Z(e) {
83
+ const [n] = e.split(/[?#]/);
84
+ return n ?? "";
85
85
  }
86
- function Q(e, a) {
87
- if (a?.trim()) return a.trim();
88
- const t = X(e).split("/").filter(Boolean).pop();
86
+ function Q(e, n) {
87
+ if (n?.trim()) return n.trim();
88
+ const t = Z(e).split("/").filter(Boolean).pop();
89
89
  if (!t) return "附件预览";
90
90
  try {
91
91
  return decodeURIComponent(t);
@@ -94,32 +94,32 @@ function Q(e, a) {
94
94
  }
95
95
  }
96
96
  function R(e) {
97
- return X(e).match(/\.([a-z0-9]+)$/i)?.[1]?.toLowerCase() ?? "";
97
+ return Z(e).match(/\.([a-z0-9]+)$/i)?.[1]?.toLowerCase() ?? "";
98
98
  }
99
- function be(e) {
99
+ function je(e) {
100
100
  return e?.trim().replace(/^\./, "").toLowerCase() ?? "";
101
101
  }
102
- function je(e) {
103
- const a = be(e);
104
- return we.has(a) ? "image" : a === "pdf" ? "pdf" : pe.has(a) ? "video" : he.has(a) ? "audio" : ge.has(a) ? "iframe" : ye.has(a) ? "unsupported" : "unknown";
102
+ function Ee(e) {
103
+ const n = je(e);
104
+ return pe.has(n) ? "image" : n === "pdf" ? "pdf" : he.has(n) ? "video" : ge.has(n) ? "audio" : ye.has(n) ? "iframe" : Ae.has(n) ? "unsupported" : "unknown";
105
105
  }
106
106
  function q(e) {
107
- const a = e.toLowerCase().split(";")[0]?.trim() ?? "";
108
- return a.startsWith("image/") ? "image" : a === "application/pdf" ? "pdf" : a.startsWith("video/") ? "video" : a.startsWith("audio/") ? "audio" : a.startsWith("text/") ? "iframe" : "unknown";
107
+ const n = e.toLowerCase().split(";")[0]?.trim() ?? "";
108
+ return n.startsWith("image/") ? "image" : n === "application/pdf" ? "pdf" : n.startsWith("video/") ? "video" : n.startsWith("audio/") ? "audio" : n.startsWith("text/") ? "iframe" : "unknown";
109
109
  }
110
- function Z(e) {
110
+ function $(e) {
111
111
  if (!e.url.trim()) return "empty";
112
112
  if (e.mode && e.mode !== "auto") return e.mode;
113
113
  if (e.mimeType) {
114
114
  const t = q(e.mimeType);
115
115
  if (t !== "unknown") return t;
116
116
  }
117
- const a = je(
117
+ const n = Ee(
118
118
  e.extension || R(e.name || "") || R(e.url)
119
119
  );
120
- return a !== "unknown" ? a : "unknown";
120
+ return n !== "unknown" ? n : "unknown";
121
121
  }
122
- async function Ee(e) {
122
+ async function xe(e) {
123
123
  try {
124
124
  const t = (await fetch(e, { method: "HEAD" })).headers.get("content-type") ?? "";
125
125
  return q(t);
@@ -127,58 +127,58 @@ async function Ee(e) {
127
127
  return "unknown";
128
128
  }
129
129
  }
130
- async function $(e) {
131
- const a = await fetch(e);
132
- if (!a.ok) throw new Error(`fetch failed: ${a.status}`);
133
- return a.blob();
130
+ async function ee(e) {
131
+ const n = await fetch(e);
132
+ if (!n.ok) throw new Error(`fetch failed: ${n.status}`);
133
+ return n.blob();
134
134
  }
135
- function xe(e, a) {
136
- const t = R(a);
135
+ function De(e, n) {
136
+ const t = R(n);
137
137
  return t === "doc" || t === "docx" ? "W" : t === "xls" || t === "xlsx" ? "X" : t === "ppt" || t === "pptx" ? "P" : t === "zip" || t === "rar" || t === "7z" ? "ZIP" : e === "pdf" ? "PDF" : "FILE";
138
138
  }
139
- function ee(e, a, t) {
140
- return n(
139
+ function te(e, n, t) {
140
+ return a(
141
141
  "button",
142
142
  {
143
143
  class: t,
144
144
  type: "button",
145
145
  onClick: () => {
146
- ne(e, a);
146
+ ae(e, n);
147
147
  }
148
148
  },
149
149
  [
150
- n(P, { class: "jt-attachment-preview-service__download-icon" }, () => n(oe)),
151
- n("span", { class: "jt-attachment-preview-service__download-text" }, "下载")
150
+ a(P, { class: "jt-attachment-preview-service__download-icon" }, () => a(ce)),
151
+ a("span", { class: "jt-attachment-preview-service__download-text" }, "下载")
152
152
  ]
153
153
  );
154
154
  }
155
155
  function H(e) {
156
156
  return e === "image" || e === "pdf";
157
157
  }
158
- function te(e) {
159
- return n("div", { class: "jt-attachment-preview-service__preview-fallback" }, [
160
- n("img", {
158
+ function ne(e) {
159
+ return a("div", { class: "jt-attachment-preview-service__preview-fallback" }, [
160
+ a("img", {
161
161
  class: "jt-attachment-preview-service__preview-fallback-icon",
162
162
  src: e.icon,
163
163
  alt: ""
164
164
  }),
165
- n("div", { class: "jt-attachment-preview-service__unsupported-text" }, "暂不支持预览此类型的文件"),
166
- n("div", { class: "jt-attachment-preview-service__file-name", title: e.name }, e.name)
165
+ a("div", { class: "jt-attachment-preview-service__unsupported-text" }, "暂不支持预览此类型的文件"),
166
+ a("div", { class: "jt-attachment-preview-service__file-name", title: e.name }, e.name)
167
167
  ]);
168
168
  }
169
- function z(e, a) {
169
+ function z(e, n) {
170
170
  const t = document.createElement("a");
171
- t.href = e, t.download = a, t.style.display = "none", document.body.appendChild(t), t.click(), t.remove();
171
+ t.href = e, t.download = n, t.style.display = "none", document.body.appendChild(t), t.click(), t.remove();
172
172
  }
173
- async function ne(e, a) {
173
+ async function ae(e, n) {
174
174
  try {
175
- const t = await $(e), c = URL.createObjectURL(t);
176
- z(c, a), URL.revokeObjectURL(c);
175
+ const t = await ee(e), c = URL.createObjectURL(t);
176
+ z(c, n), URL.revokeObjectURL(c);
177
177
  } catch {
178
- z(e, a);
178
+ z(e, n);
179
179
  }
180
180
  }
181
- const De = D({
181
+ const ke = D({
182
182
  name: "JtAttachmentPreviewPdfCanvas",
183
183
  props: {
184
184
  url: {
@@ -202,8 +202,8 @@ const De = D({
202
202
  previewLoad: (e) => e instanceof Event,
203
203
  previewError: (e) => e instanceof Event
204
204
  },
205
- setup(e, { emit: a }) {
206
- const t = x("loading"), c = x([]), i = x([]), o = /* @__PURE__ */ new Map(), u = x("");
205
+ setup(e, { emit: n }) {
206
+ const t = x("loading"), c = x([]), o = x([]), i = /* @__PURE__ */ new Map(), u = x("");
207
207
  let d = null, w = [], m = 0;
208
208
  async function v(r, l) {
209
209
  if (!l) return null;
@@ -229,23 +229,23 @@ const De = D({
229
229
  m += 1;
230
230
  for (const r of w)
231
231
  r.cancel();
232
- w = [], d?.destroy(), d = null, o.clear();
232
+ w = [], d?.destroy(), d = null, i.clear();
233
233
  }
234
- async function M() {
234
+ async function C() {
235
235
  h();
236
236
  const r = m;
237
- t.value = "loading", u.value = "", c.value = [], i.value = [];
237
+ t.value = "loading", u.value = "", c.value = [], o.value = [];
238
238
  try {
239
- const l = await Ae();
239
+ const l = await _e();
240
240
  if (r !== m) return;
241
241
  d = l.getDocument({ url: e.url });
242
242
  const f = await d.promise;
243
243
  if (r !== m) return;
244
- c.value = Array.from({ length: f.numPages }, (k, g) => g + 1), i.value = await _(f, await f.getOutline()), await re();
245
- const b = o.values().next().value, j = Math.max((b?.parentElement?.clientWidth ?? 800) - 32, 320);
244
+ c.value = Array.from({ length: f.numPages }, (k, g) => g + 1), o.value = await _(f, await f.getOutline()), await oe();
245
+ const b = i.values().next().value, j = Math.max((b?.parentElement?.clientWidth ?? 800) - 32, 320);
246
246
  for (const k of c.value) {
247
247
  if (r !== m) return;
248
- const g = await f.getPage(k), y = o.get(k), L = y?.getContext("2d");
248
+ const g = await f.getPage(k), y = i.get(k), L = y?.getContext("2d");
249
249
  if (!y || !L) continue;
250
250
  const G = g.getViewport({ scale: 1 }), S = Math.min(j / G.width, 2), s = g.getViewport({ scale: S }), B = window.devicePixelRatio || 1;
251
251
  y.width = Math.floor(s.width * B), y.height = Math.floor(s.height * B), y.style.width = `${Math.floor(s.width)}px`, y.style.height = `${Math.floor(s.height)}px`, L.setTransform(B, 0, 0, B, 0, 0);
@@ -257,28 +257,28 @@ const De = D({
257
257
  w.push(V), await V.promise;
258
258
  }
259
259
  if (r !== m) return;
260
- t.value = "ready", a("previewLoad", new Event("load"));
260
+ t.value = "ready", n("previewLoad", new Event("load"));
261
261
  } catch (l) {
262
262
  if (r !== m) return;
263
- t.value = "error", u.value = l instanceof Error ? l.message : "PDF 加载失败", a("previewError", new Event("error"));
263
+ t.value = "error", u.value = l instanceof Error ? l.message : "PDF 加载失败", n("previewError", new Event("error"));
264
264
  }
265
265
  }
266
- F(() => e.url, M, { immediate: !0 }), T(h);
266
+ F(() => e.url, C, { immediate: !0 }), T(h);
267
267
  function p(r) {
268
268
  if (!r) return;
269
- o.get(r)?.scrollIntoView({ behavior: "smooth", block: "start" });
269
+ i.get(r)?.scrollIntoView({ behavior: "smooth", block: "start" });
270
270
  }
271
- return () => n("div", { class: "jt-attachment-preview-service__pdf-viewer" }, [
272
- t.value === "loading" ? n("div", { class: "jt-attachment-preview-service__pdf-state" }, "PDF 加载中...") : null,
273
- t.value === "error" ? n("div", { class: "jt-attachment-preview-service__pdf-state" }, [
274
- te({
275
- icon: fe,
271
+ return () => a("div", { class: "jt-attachment-preview-service__pdf-viewer" }, [
272
+ t.value === "loading" ? a("div", { class: "jt-attachment-preview-service__pdf-state" }, "PDF 加载中...") : null,
273
+ t.value === "error" ? a("div", { class: "jt-attachment-preview-service__pdf-state" }, [
274
+ ne({
275
+ icon: we,
276
276
  name: e.name
277
277
  })
278
278
  ]) : null,
279
279
  null,
280
280
  null,
281
- n(
281
+ a(
282
282
  "div",
283
283
  {
284
284
  class: [
@@ -287,13 +287,13 @@ const De = D({
287
287
  ]
288
288
  },
289
289
  [
290
- i.value.length ? n("aside", { class: "jt-attachment-preview-service__pdf-outline" }, [
291
- n("div", { class: "jt-attachment-preview-service__pdf-outline-title" }, "目录"),
292
- n(
290
+ o.value.length ? a("aside", { class: "jt-attachment-preview-service__pdf-outline" }, [
291
+ a("div", { class: "jt-attachment-preview-service__pdf-outline-title" }, "目录"),
292
+ a(
293
293
  "div",
294
294
  { class: "jt-attachment-preview-service__pdf-outline-list" },
295
- i.value.map(
296
- (r, l) => n(
295
+ o.value.map(
296
+ (r, l) => a(
297
297
  "button",
298
298
  {
299
299
  key: `${r.title}-${l}`,
@@ -309,14 +309,14 @@ const De = D({
309
309
  )
310
310
  )
311
311
  ]) : null,
312
- n(
312
+ a(
313
313
  "div",
314
314
  { class: "jt-attachment-preview-service__pdf-pages" },
315
315
  c.value.map(
316
- (r) => n("canvas", {
316
+ (r) => a("canvas", {
317
317
  key: r,
318
318
  ref: (l) => {
319
- l instanceof HTMLCanvasElement && o.set(r, l);
319
+ l instanceof HTMLCanvasElement && i.set(r, l);
320
320
  },
321
321
  class: "jt-attachment-preview-service__pdf-page"
322
322
  })
@@ -326,7 +326,7 @@ const De = D({
326
326
  )
327
327
  ]);
328
328
  }
329
- }), ke = D({
329
+ }), Le = D({
330
330
  name: "JtAttachmentPreviewImageTransform",
331
331
  props: {
332
332
  url: {
@@ -354,15 +354,15 @@ const De = D({
354
354
  previewLoad: (e) => e instanceof Event,
355
355
  previewError: (e) => e instanceof Event
356
356
  },
357
- setup(e, { emit: a }) {
358
- const t = x(null), c = x("ready"), i = x(1), o = x(!1);
357
+ setup(e, { emit: n }) {
358
+ const t = x(null), c = x("ready"), o = x(1), i = x(!1);
359
359
  let u = 0, d = 0, w = 0, m = 0, v = 0, _ = 0, h = 0;
360
- const M = E(() => ({
360
+ const C = E(() => ({
361
361
  "--jt-attachment-preview-service-image-fit": e.fit,
362
- transform: `translate(${u}px, ${d}px) scale(${i.value})`
362
+ transform: `translate(${u}px, ${d}px) scale(${o.value})`
363
363
  }));
364
364
  function p() {
365
- t.value && (t.value.style.transform = `translate(${u}px, ${d}px) scale(${i.value})`);
365
+ t.value && (t.value.style.transform = `translate(${u}px, ${d}px) scale(${o.value})`);
366
366
  }
367
367
  function r() {
368
368
  h || (h = window.requestAnimationFrame(() => {
@@ -370,55 +370,55 @@ const De = D({
370
370
  }));
371
371
  }
372
372
  function l(s) {
373
- i.value = Math.min(Math.max(Number(s.toFixed(2)), 0.2), 5), i.value <= 1 && (u = 0, d = 0), p();
373
+ o.value = Math.min(Math.max(Number(s.toFixed(2)), 0.2), 5), o.value <= 1 && (u = 0, d = 0), p();
374
374
  }
375
375
  function f() {
376
- l(i.value + 0.2);
376
+ l(o.value + 0.2);
377
377
  }
378
378
  function b() {
379
- const s = Math.max(Number((i.value - 0.2).toFixed(2)), 0.2);
380
- i.value = s, s <= 1 && (u = 0, d = 0), p();
379
+ const s = Math.max(Number((o.value - 0.2).toFixed(2)), 0.2);
380
+ o.value = s, s <= 1 && (u = 0, d = 0), p();
381
381
  }
382
382
  function j() {
383
383
  u = 0, d = 0, l(1);
384
384
  }
385
385
  function k(s) {
386
- c.value = "ready", a("previewLoad", s);
386
+ c.value = "ready", n("previewLoad", s);
387
387
  }
388
388
  function g(s) {
389
- c.value = "error", a("previewError", s);
389
+ c.value = "error", n("previewError", s);
390
390
  }
391
391
  function y(s) {
392
- i.value <= 1 || (s.preventDefault(), o.value = !0, w = s.clientX, m = s.clientY, v = u, _ = d, window.addEventListener("pointermove", L), window.addEventListener("pointerup", G, { once: !0 }));
392
+ o.value <= 1 || (s.preventDefault(), i.value = !0, w = s.clientX, m = s.clientY, v = u, _ = d, window.addEventListener("pointermove", L), window.addEventListener("pointerup", G, { once: !0 }));
393
393
  }
394
394
  function L(s) {
395
- o.value && (u = v + s.clientX - w, d = _ + s.clientY - m, r());
395
+ i.value && (u = v + s.clientX - w, d = _ + s.clientY - m, r());
396
396
  }
397
397
  function G() {
398
- o.value = !1, window.removeEventListener("pointermove", L);
398
+ i.value = !1, window.removeEventListener("pointermove", L);
399
399
  }
400
400
  function S(s) {
401
- s.preventDefault(), l(i.value + (s.deltaY < 0 ? 0.1 : -0.1));
401
+ s.preventDefault(), l(o.value + (s.deltaY < 0 ? 0.1 : -0.1));
402
402
  }
403
403
  return K(p), F(() => e.url, () => {
404
404
  c.value = "ready", j();
405
405
  }), T(() => {
406
406
  window.removeEventListener("pointermove", L), h && window.cancelAnimationFrame(h);
407
- }), () => n("div", { class: "jt-attachment-preview-service__image-viewer" }, c.value === "error" ? te({
408
- icon: me,
407
+ }), () => a("div", { class: "jt-attachment-preview-service__image-viewer" }, c.value === "error" ? ne({
408
+ icon: fe,
409
409
  name: e.name
410
410
  }) : [
411
- n("img", {
411
+ a("img", {
412
412
  ref: t,
413
413
  class: [
414
414
  "jt-attachment-preview-service__media",
415
415
  "jt-attachment-preview-service__image",
416
- i.value > 1 ? "jt-attachment-preview-service__image--draggable" : "",
417
- o.value ? "jt-attachment-preview-service__image--dragging" : ""
416
+ o.value > 1 ? "jt-attachment-preview-service__image--draggable" : "",
417
+ i.value ? "jt-attachment-preview-service__image--dragging" : ""
418
418
  ],
419
419
  src: e.url,
420
420
  alt: e.name,
421
- style: M.value,
421
+ style: C.value,
422
422
  onLoad: k,
423
423
  onError: g,
424
424
  onPointerdown: y,
@@ -426,8 +426,8 @@ const De = D({
426
426
  onDragstart: (s) => s.preventDefault(),
427
427
  draggable: !1
428
428
  }),
429
- n("div", { class: "jt-attachment-preview-service__image-toolbar" }, [
430
- n(
429
+ a("div", { class: "jt-attachment-preview-service__image-toolbar" }, [
430
+ a(
431
431
  "button",
432
432
  {
433
433
  class: "jt-attachment-preview-service__image-tool",
@@ -435,10 +435,10 @@ const De = D({
435
435
  title: "缩小",
436
436
  onClick: b
437
437
  },
438
- [n(P, () => n(ve))]
438
+ [a(P, () => a(me))]
439
439
  ),
440
- n("span", { class: "jt-attachment-preview-service__image-scale" }, `${Math.round(i.value * 100)}%`),
441
- n(
440
+ a("span", { class: "jt-attachment-preview-service__image-scale" }, `${Math.round(o.value * 100)}%`),
441
+ a(
442
442
  "button",
443
443
  {
444
444
  class: "jt-attachment-preview-service__image-tool",
@@ -446,9 +446,9 @@ const De = D({
446
446
  title: "放大",
447
447
  onClick: f
448
448
  },
449
- [n(P, () => n(ue))]
449
+ [a(P, () => a(de))]
450
450
  ),
451
- n(
451
+ a(
452
452
  "button",
453
453
  {
454
454
  class: "jt-attachment-preview-service__image-tool",
@@ -456,12 +456,12 @@ const De = D({
456
456
  title: "复位",
457
457
  onClick: j
458
458
  },
459
- [n(P, () => n(se))]
459
+ [a(P, () => a(le))]
460
460
  )
461
461
  ])
462
462
  ]);
463
463
  }
464
- }), Le = D({
464
+ }), Ce = D({
465
465
  name: "JtAttachmentPreviewService",
466
466
  props: {
467
467
  options: {
@@ -474,7 +474,7 @@ const De = D({
474
474
  }
475
475
  },
476
476
  setup(e) {
477
- const a = E(() => Q(e.options.url, e.options.name)), t = E(() => e.options.downloadName || a.value), c = E(() => Z(e.options)), i = E(() => xe(c.value, e.options.url)), o = E(() => ({
477
+ const n = E(() => Q(e.options.url, e.options.name)), t = E(() => e.options.downloadName || n.value), c = E(() => $(e.options)), o = E(() => De(c.value, e.options.url)), i = E(() => ({
478
478
  zIndex: e.options.zIndex ?? 3e3,
479
479
  "--jt-attachment-preview-service-image-fit": e.options.fit ?? "contain"
480
480
  }));
@@ -495,14 +495,14 @@ const De = D({
495
495
  }), T(() => {
496
496
  document.removeEventListener("keydown", d), document.body.classList.remove("jt-attachment-preview-service-lock");
497
497
  }), () => {
498
- const v = e.options.downloadable === !1 ? [] : [ee(e.options.url, t.value, "jt-attachment-preview-service__top-download")];
499
- return n("div", { class: "jt-attachment-preview-service", style: o.value }, [
500
- n("div", { class: "jt-attachment-preview-service__modal" }, [
501
- n("div", { class: "jt-attachment-preview-service__header" }, [
502
- n("div", { class: "jt-attachment-preview-service__filename", title: a.value }, a.value),
503
- n("div", { class: "jt-attachment-preview-service__header-actions" }, [
498
+ const v = e.options.downloadable === !1 ? [] : [te(e.options.url, t.value, "jt-attachment-preview-service__top-download")];
499
+ return a("div", { class: "jt-attachment-preview-service", style: i.value }, [
500
+ a("div", { class: "jt-attachment-preview-service__modal" }, [
501
+ a("div", { class: "jt-attachment-preview-service__header" }, [
502
+ a("div", { class: "jt-attachment-preview-service__filename", title: n.value }, n.value),
503
+ a("div", { class: "jt-attachment-preview-service__header-actions" }, [
504
504
  ...v,
505
- n(
505
+ a(
506
506
  "button",
507
507
  {
508
508
  class: "jt-attachment-preview-service__close",
@@ -514,14 +514,14 @@ const De = D({
514
514
  )
515
515
  ])
516
516
  ]),
517
- n("div", { class: "jt-attachment-preview-service__body" }, [
518
- Ce({
517
+ a("div", { class: "jt-attachment-preview-service__body" }, [
518
+ Me({
519
519
  type: c.value,
520
520
  url: e.options.url,
521
- name: a.value,
521
+ name: n.value,
522
522
  downloadName: t.value,
523
523
  sandbox: e.options.sandbox,
524
- iconText: i.value,
524
+ iconText: o.value,
525
525
  downloadable: e.options.downloadable !== !1,
526
526
  onLoad: w,
527
527
  onError: m
@@ -556,25 +556,25 @@ const De = D({
556
556
  }
557
557
  },
558
558
  setup(e) {
559
- const a = E(() => Q(e.options.url, e.options.name)), t = E(() => ({
559
+ const n = E(() => Q(e.options.url, e.options.name)), t = E(() => ({
560
560
  zIndex: e.options.zIndex ?? 3e3
561
561
  }));
562
562
  function c() {
563
563
  e.options.onClose?.(), e.onDestroy();
564
564
  }
565
- function i(o) {
566
- o.key === "Escape" && e.options.closeOnPressEscape !== !1 && c();
565
+ function o(i) {
566
+ i.key === "Escape" && e.options.closeOnPressEscape !== !1 && c();
567
567
  }
568
568
  return K(() => {
569
- document.addEventListener("keydown", i), document.body.classList.add("jt-attachment-preview-service-lock");
569
+ document.addEventListener("keydown", o), document.body.classList.add("jt-attachment-preview-service-lock");
570
570
  }), T(() => {
571
- document.removeEventListener("keydown", i), document.body.classList.remove("jt-attachment-preview-service-lock");
572
- }), () => n("div", { class: "jt-attachment-preview-service", style: t.value }, [
573
- n("div", { class: "jt-attachment-preview-service__modal" }, [
574
- n("div", { class: "jt-attachment-preview-service__header" }, [
575
- n("div", { class: "jt-attachment-preview-service__filename", title: a.value }, a.value),
576
- n("div", { class: "jt-attachment-preview-service__header-actions" }, [
577
- n(
571
+ document.removeEventListener("keydown", o), document.body.classList.remove("jt-attachment-preview-service-lock");
572
+ }), () => a("div", { class: "jt-attachment-preview-service", style: t.value }, [
573
+ a("div", { class: "jt-attachment-preview-service__modal" }, [
574
+ a("div", { class: "jt-attachment-preview-service__header" }, [
575
+ a("div", { class: "jt-attachment-preview-service__filename", title: n.value }, n.value),
576
+ a("div", { class: "jt-attachment-preview-service__header-actions" }, [
577
+ a(
578
578
  "button",
579
579
  {
580
580
  class: "jt-attachment-preview-service__close",
@@ -586,96 +586,108 @@ const De = D({
586
586
  )
587
587
  ])
588
588
  ]),
589
- n("div", { class: "jt-attachment-preview-service__body" }, [
590
- n("div", { class: "jt-attachment-preview-service__detecting" }, [
591
- e.spinning ? n("span", { class: "jt-attachment-preview-service__detecting-spinner" }) : null,
592
- n("span", { class: "jt-attachment-preview-service__detecting-title" }, e.title),
593
- n("span", { class: "jt-attachment-preview-service__detecting-desc" }, e.desc)
589
+ a("div", { class: "jt-attachment-preview-service__body" }, [
590
+ a("div", { class: "jt-attachment-preview-service__detecting" }, [
591
+ e.spinning ? a("span", { class: "jt-attachment-preview-service__detecting-spinner" }) : null,
592
+ a("span", { class: "jt-attachment-preview-service__detecting-title" }, e.title),
593
+ a("span", { class: "jt-attachment-preview-service__detecting-desc" }, e.desc)
594
594
  ])
595
595
  ])
596
596
  ])
597
597
  ]);
598
598
  }
599
599
  });
600
- function Ce(e) {
601
- return e.type === "empty" ? n("div", { class: "jt-attachment-preview-service__empty" }, "暂无附件") : e.type === "image" ? n(ke, {
600
+ function Me(e) {
601
+ return e.type === "empty" ? a("div", { class: "jt-attachment-preview-service__empty" }, "暂无附件") : e.type === "image" ? a(Le, {
602
602
  url: e.url,
603
603
  name: e.name,
604
604
  downloadName: e.downloadName,
605
605
  downloadable: e.downloadable,
606
606
  onPreviewLoad: e.onLoad,
607
607
  onPreviewError: e.onError
608
- }) : e.type === "video" ? n("video", {
608
+ }) : e.type === "video" ? a("video", {
609
609
  class: "jt-attachment-preview-service__media",
610
610
  src: e.url,
611
611
  controls: !0,
612
612
  onLoadeddata: e.onLoad,
613
613
  onError: e.onError
614
- }) : e.type === "audio" ? n("audio", {
614
+ }) : e.type === "audio" ? a("audio", {
615
615
  class: "jt-attachment-preview-service__audio",
616
616
  src: e.url,
617
617
  controls: !0,
618
618
  onLoadeddata: e.onLoad,
619
619
  onError: e.onError
620
- }) : e.type === "pdf" ? n(De, {
620
+ }) : e.type === "pdf" ? a(ke, {
621
621
  url: e.url,
622
622
  name: e.name,
623
623
  downloadName: e.downloadName,
624
624
  downloadable: e.downloadable,
625
625
  onPreviewLoad: e.onLoad,
626
626
  onPreviewError: e.onError
627
- }) : e.type === "iframe" ? n("iframe", {
627
+ }) : e.type === "iframe" ? a("iframe", {
628
628
  class: "jt-attachment-preview-service__iframe",
629
629
  src: e.url,
630
630
  title: e.name,
631
631
  sandbox: e.sandbox || void 0,
632
632
  onLoad: e.onLoad
633
- }) : n("div", { class: "jt-attachment-preview-service__unsupported" }, [
634
- n("div", { class: "jt-attachment-preview-service__file-card" }, [
635
- n("div", { class: "jt-attachment-preview-service__file-icon" }, e.iconText),
636
- n("div", { class: "jt-attachment-preview-service__unsupported-text" }, "暂不支持预览此类型的文件")
633
+ }) : a("div", { class: "jt-attachment-preview-service__unsupported" }, [
634
+ a("div", { class: "jt-attachment-preview-service__file-card" }, [
635
+ a("div", { class: "jt-attachment-preview-service__file-icon" }, e.iconText),
636
+ a("div", { class: "jt-attachment-preview-service__unsupported-text" }, "暂不支持预览此类型的文件")
637
637
  ]),
638
- n("div", { class: "jt-attachment-preview-service__file-name", title: e.name }, e.name),
639
- e.downloadable ? ee(e.url, e.downloadName, "jt-attachment-preview-service__primary-download") : null
638
+ a("div", { class: "jt-attachment-preview-service__file-name", title: e.name }, e.name),
639
+ e.downloadable ? te(e.url, e.downloadName, "jt-attachment-preview-service__primary-download") : null
640
640
  ]);
641
641
  }
642
+ function M(e, n) {
643
+ try {
644
+ X(e, n);
645
+ } catch (t) {
646
+ console.error("[JtAttachmentPreview] render failed", t);
647
+ }
648
+ }
642
649
  function W(e) {
643
- C(null, e), queueMicrotask(() => {
650
+ window.setTimeout(() => {
651
+ try {
652
+ X(null, e);
653
+ } catch (n) {
654
+ console.error("[JtAttachmentPreview] unmount failed", n);
655
+ }
644
656
  e.remove();
645
- });
657
+ }, 0);
646
658
  }
647
- function ae(e, a) {
648
- const t = _e(e), c = t.downloadName || Q(t.url, t.name);
649
- let i = !1, o = a?.container ?? null, u = null;
659
+ function re(e, n) {
660
+ const t = be(e), c = t.downloadName || Q(t.url, t.name);
661
+ let o = !1, i = n?.container ?? null, u = null;
650
662
  const d = () => {
651
- i || (i = !0, o && (W(o), o = null), u && (URL.revokeObjectURL(u), u = null), a?.onClose?.(), A?.close === d && (A = null));
663
+ o || (o = !0, i && (W(i), i = null), u && (URL.revokeObjectURL(u), u = null), n?.onClose?.(), A?.close === d && (A = null));
652
664
  };
653
665
  function w() {
654
- i || (o || (o = document.createElement("div"), document.body.appendChild(o)), C(n(Le, { options: t, onDestroy: d }), o));
666
+ o || (i || (i = document.createElement("div"), document.body.appendChild(i)), M(a(Ce, { options: t, onDestroy: d }), i));
655
667
  }
656
668
  function m() {
657
- i || (o || (o = document.createElement("div"), document.body.appendChild(o)), C(n(Y, { options: t, onDestroy: d }), o));
669
+ o || (i || (i = document.createElement("div"), document.body.appendChild(i)), M(a(Y, { options: t, onDestroy: d }), i));
658
670
  }
659
671
  function v() {
660
- o && (W(o), o = null, a?.onClose?.());
672
+ i && (W(i), i = null, n?.onClose?.());
661
673
  }
662
674
  function _() {
663
- i || ne(t.url, c);
675
+ o || ae(t.url, c);
664
676
  }
665
677
  function h(p) {
666
- if (i) return;
678
+ if (o) return;
667
679
  const r = URL.createObjectURL(p);
668
680
  z(r, c), URL.revokeObjectURL(r);
669
681
  }
670
- const M = Z(t);
671
- return H(M) ? w() : M === "unknown" ? (m(), Ee(t.url).then(async (p) => {
672
- if (!i) {
682
+ const C = $(t);
683
+ return H(C) ? w() : C === "unknown" ? (m(), xe(t.url).then(async (p) => {
684
+ if (!o) {
673
685
  if (H(p)) {
674
686
  t.mode = p, w();
675
687
  return;
676
688
  }
677
689
  try {
678
- const r = await $(t.url), l = q(r.type);
690
+ const r = await ee(t.url), l = q(r.type);
679
691
  if (H(l)) {
680
692
  u = URL.createObjectURL(r), t.url = u, t.mode = l, w();
681
693
  return;
@@ -687,25 +699,25 @@ function ae(e, a) {
687
699
  }
688
700
  })) : (v(), _()), A = { close: d }, A;
689
701
  }
690
- function Me(e) {
702
+ function Ye(e) {
691
703
  return typeof document > "u" ? { close: () => {
692
- } } : (A?.close(), ae(e));
704
+ } } : (A?.close(), re(e));
693
705
  }
694
- function Ye(e) {
706
+ function Be(e) {
695
707
  N = e;
696
708
  }
697
- function Be(e) {
709
+ function Pe(e) {
698
710
  if (typeof document > "u")
699
711
  return { close: () => {
700
712
  } };
701
713
  A?.close();
702
- let a = !1, t = document.createElement("div");
714
+ let n = !1, t = document.createElement("div");
703
715
  document.body.appendChild(t);
704
716
  const c = () => {
705
- a || (a = !0, t && (W(t), t = null), A?.close === c && (A = null));
706
- }, i = { close: c };
707
- return A = i, N ? (C(
708
- n(Y, {
717
+ n || (n = !0, t && (W(t), t = null), A?.close === c && (A = null));
718
+ }, o = { close: c };
719
+ return A = o, N ? (M(
720
+ a(Y, {
709
721
  options: { url: "", name: "附件预览" },
710
722
  title: "正在获取文件信息",
711
723
  desc: "请稍候,获取完成后将自动预览或下载",
@@ -713,12 +725,12 @@ function Be(e) {
713
725
  onDestroy: c
714
726
  }),
715
727
  t
716
- ), N.request(e).then((o) => {
717
- if (a) return;
718
- const u = N?.mapResponse(o, e);
728
+ ), N.request(e).then((i) => {
729
+ if (n) return;
730
+ const u = N?.mapResponse(i, e);
719
731
  if (!u?.url) {
720
- C(
721
- n(Y, {
732
+ M(
733
+ a(Y, {
722
734
  options: { url: "", name: "附件预览" },
723
735
  title: "文件信息缺少 URL",
724
736
  desc: "请检查 mapResponse 是否返回了 url 字段",
@@ -729,18 +741,18 @@ function Be(e) {
729
741
  );
730
742
  return;
731
743
  }
732
- const d = ae(u, {
744
+ const d = re(u, {
733
745
  container: t,
734
746
  onClose: () => {
735
- a = !0, t = null;
747
+ n = !0, t = null;
736
748
  }
737
749
  });
738
- i.close = d.close;
739
- }).catch((o) => {
740
- if (a) return;
741
- const u = o instanceof Error ? o.message : "接口请求失败";
742
- C(
743
- n(Y, {
750
+ o.close = d.close;
751
+ }).catch((i) => {
752
+ if (n) return;
753
+ const u = i instanceof Error ? i.message : "接口请求失败";
754
+ M(
755
+ a(Y, {
744
756
  options: { url: "", name: "附件预览" },
745
757
  title: "文件信息获取失败",
746
758
  desc: u,
@@ -749,8 +761,8 @@ function Be(e) {
749
761
  }),
750
762
  t
751
763
  );
752
- }), i) : (C(
753
- n(Y, {
764
+ }), o) : (M(
765
+ a(Y, {
754
766
  options: { url: "", name: "附件预览" },
755
767
  title: "附件预览未初始化",
756
768
  desc: "请先调用 setupJtAttachmentPreview 注册请求配置",
@@ -758,14 +770,14 @@ function Be(e) {
758
770
  onDestroy: c
759
771
  }),
760
772
  t
761
- ), i);
773
+ ), o);
762
774
  }
763
- const Oe = Object.assign(Me, {
764
- openByParams: Be,
765
- setup: Ye
775
+ const Oe = Object.assign(Ye, {
776
+ openByParams: Pe,
777
+ setup: Be
766
778
  });
767
779
  export {
768
780
  Oe as JtAttachmentPreview,
769
- Be as JtAttachmentPreviewByParams,
770
- Ye as setupJtAttachmentPreview
781
+ Pe as JtAttachmentPreviewByParams,
782
+ Be as setupJtAttachmentPreview
771
783
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jt-home/mfe-components",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",