驭风行PC站
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1 lines
10 KiB

import{m as he,b as M}from"./CeUmO8rY.js";import{f as ne,ah as pe,k,ai as Le,D as Se,h as p,l as ue,aj as be,E as ke,o as b,z as de,w as C,b as v,T as xe,a as h,n as m,u as t,i as ge,C as Oe,g as L,c as x,F as ae,ak as Ne,y as Te,x as Re,O as Ae,r as te,al as $e,t as Me,am as we,L as Be}from"./Ca9y1zsW.js";import{E as Ve}from"./BAT_Brgp.js";import{q as $,r as De,b as _e,h as H,i as fe,t as Pe,x as Ye,a as Ce,u as Ie,E as T,y as Fe,n as Xe,f as He,z as je,A as Ke,B as We,C as Ze,_ as ze,w as Ee,D as qe,F as Ge,G as Ue}from"./BPRC2v3K.js";import{u as Je,k as Qe}from"./B3sO6I2n.js";import{E as A}from"./BUADUvnR.js";import{d as et}from"./BBIc9hyf.js";import{u as tt}from"./aPBqHQcn.js";import{g as at}from"./DYOBeiWW.js";const nt=(s,i)=>{if(!$||!s||!i)return!1;const n=s.getBoundingClientRect();let f;return i instanceof Element?f=i.getBoundingClientRect():f={top:0,right:window.innerWidth,bottom:window.innerHeight,left:0},n.top<f.bottom&&n.bottom>f.top&&n.right>f.left&&n.left<f.right},ye=s=>{let i=0,n=s;for(;n;)i+=n.offsetTop,n=n.offsetParent;return i},zt=(s,i)=>Math.abs(ye(s)-ye(i));var st="Expected a function";function ce(s,i,n){var f=!0,l=!0;if(typeof s!="function")throw new TypeError(st);return De(n)&&(f="leading"in n?!!n.leading:f,l="trailing"in n?!!n.trailing:l),et(s,i,{leading:f,maxWait:i,trailing:l})}const ot=_e({urlList:{type:H(Array),default:()=>he([])},zIndex:{type:Number},initialIndex:{type:Number,default:0},infinite:{type:Boolean,default:!0},hideOnClickModal:Boolean,teleported:Boolean,closeOnPressEscape:{type:Boolean,default:!0},zoomRate:{type:Number,default:1.2},minScale:{type:Number,default:.2},maxScale:{type:Number,default:7},crossorigin:{type:H(String)}}),lt={close:()=>!0,switch:s=>fe(s),rotate:s=>fe(s)},rt=ne({name:"ElImageViewer"}),it=ne({...rt,props:ot,emits:lt,setup(s,{expose:i,emit:n}){var f;const l=s,g={CONTAIN:{name:"contain",icon:pe(Pe)},ORIGINAL:{name:"original",icon:pe(Ye)}},{t:se}=Ce(),r=Ie("image-viewer"),{nextZIndex:oe}=Je(),R=k(),O=k([]),S=Le(),I=k(!0),w=k(l.initialIndex),y=Se(g.CONTAIN),c=k({scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1}),B=k((f=l.zIndex)!=null?f:oe()),V=p(()=>{const{urlList:a}=l;return a.length<=1}),j=p(()=>w.value===0),K=p(()=>w.value===l.urlList.length-1),D=p(()=>l.urlList[w.value]),le=p(()=>[r.e("btn"),r.e("prev"),r.is("disabled",!l.infinite&&j.value)]),W=p(()=>[r.e("btn"),r.e("next"),r.is("disabled",!l.infinite&&K.value)]),P=p(()=>{const{scale:a,deg:d,offsetX:o,offsetY:_,enableTransition:z}=c.value;let E=o/a,N=_/a;const X=d*Math.PI/180,ve=Math.cos(X),me=Math.sin(X);E=E*ve+N*me,N=N*ve-o/a*me;const ie={transform:`scale(${a}) rotate(${d}deg) translate(${E}px, ${N}px)`,transition:z?"transform .3s":""};return y.value.name===g.CONTAIN.name&&(ie.maxWidth=ie.maxHeight="100%"),ie});function Y(){Z(),n("close")}function re(){const a=ce(o=>{switch(o.code){case A.esc:l.closeOnPressEscape&&Y();break;case A.space:Q();break;case A.left:ee();break;case A.up:u("zoomIn");break;case A.right:e();break;case A.down:u("zoomOut");break}}),d=ce(o=>{const _=o.deltaY||o.deltaX;u(_<0?"zoomIn":"zoomOut",{zoomRate:l.zoomRate,enableTransition:!1})});S.run(()=>{M(document,"keydown",a),M(document,"wheel",d)})}function Z(){S.stop()}function q(){I.value=!1}function G(a){I.value=!1,a.target.alt=se("el.image.error")}function U(a){if(I.value||a.button!==0||!R.value)return;c.value.enableTransition=!1;const{offsetX:d,offsetY:o}=c.value,_=a.pageX,z=a.pageY,E=ce(X=>{c.value={...c.value,offsetX:d+X.pageX-_,offsetY:o+X.pageY-z}}),N=M(document,"mousemove",E);M(document,"mouseup",()=>{N()}),a.preventDefault()}function J(){c.value={scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1}}function Q(){if(I.value)return;const a=Qe(g),d=Object.values(g),o=y.value.name,z=(d.findIndex(E=>E.name===o)+1)%a.length;y.value=g[a[z]],J()}function F(a){const d=l.urlList.length;w.value=(a+d)%d}function ee(){j.value&&!l.infinite||F(w.value-1)}function e(){K.value&&!l.infinite||F(w.value+1)}function u(a,d={}){if(I.value)return;const{minScale:o,maxScale:_}=l,{zoomRate:z,rotateDeg:E,enableTransition:N}={zoomRate:l.zoomRate,rotateDeg:90,enableTransition:!0,...d};switch(a){case"zoomOut":c.value.scale>o&&(c.value.scale=Number.parseFloat((c.value.scale/z).toFixed(3)));break;case"zoomIn":c.value.scale<_&&(c.value.scale=Number.parseFloat((c.value.scale*z).toFixed(3)));break;case"clockwise":c.value.deg+=E,n("rotate",c.value.deg);break;case"anticlockwise":c.value.deg-=E,n("rotate",c.value.deg);break}c.value.enableTransition=N}return ue(D,()=>{be(()=>{const a=O.value[0];a!=null&&a.complete||(I.value=!0)})}),ue(w,a=>{J(),n("switch",a)}),ke(()=>{var a,d;re(),(d=(a=R.value)==null?void 0:a.focus)==null||d.call(a)}),i({setActiveItem:F}),(a,d)=>(b(),de(t(Ve),{to:"body",disabled:!a.teleported},{default:C(()=>[v(xe,{name:"viewer-fade",appear:""},{default:C(()=>[h("div",{ref_key:"wrapper",ref:R,tabindex:-1,class:m(t(r).e("wrapper")),style:ge({zIndex:B.value})},[h("div",{class:m(t(r).e("mask")),onClick:Oe(o=>a.hideOnClickModal&&Y(),["self"])},null,10,["onClick"]),L(" CLOSE "),h("span",{class:m([t(r).e("btn"),t(r).e("close")]),onClick:Y},[v(t(T),null,{default:C(()=>[v(t(Fe))]),_:1})],2),L(" ARROW "),t(V)?L("v-if",!0):(b(),x(ae,{key:0},[h("span",{class:m(t(le)),onClick:ee},[v(t(T),null,{default:C(()=>[v(t(Xe))]),_:1})],2),h("span",{class:m(t(W)),onClick:e},[v(t(T),null,{default:C(()=>[v(t(He))]),_:1})],2)],64)),L(" ACTIONS "),h("div",{class:m([t(r).e("btn"),t(r).e("actions")])},[h("div",{class:m(t(r).e("actions__inner"))},[v(t(T),{onClick:o=>u("zoomOut")},{default:C(()=>[v(t(je))]),_:1},8,["onClick"]),v(t(T),{onClick:o=>u("zoomIn")},{default:C(()=>[v(t(Ke))]),_:1},8,["onClick"]),h("i",{class:m(t(r).e("actions__divider"))},null,2),v(t(T),{onClick:Q},{default:C(()=>[(b(),de(Ne(t(y).icon)))]),_:1}),h("i",{class:m(t(r).e("actions__divider"))},null,2),v(t(T),{onClick:o=>u("anticlockwise")},{default:C(()=>[v(t(We))]),_:1},8,["onClick"]),v(t(T),{onClick:o=>u("clockwise")},{default:C(()=>[v(t(Ze))]),_:1},8,["onClick"])],2)],2),L(" CANVAS "),h("div",{class:m(t(r).e("canvas"))},[(b(!0),x(ae,null,Te(a.urlList,(o,_)=>Re((b(),x("img",{ref_for:!0,ref:z=>O.value[_]=z,key:o,src:o,style:ge(t(P)),class:m(t(r).e("img")),crossorigin:a.crossorigin,onLoad:q,onError:G,onMousedown:U},null,46,["src","crossorigin"])),[[Ae,_===w.value]])),128))],2),te(a.$slots,"default")],6)]),_:3})]),_:3},8,["disabled"]))}});var ct=ze(it,[["__file","image-viewer.vue"]]);const ut=Ee(ct),dt=_e({hideOnClickModal:Boolean,src:{type:String,default:""},fit:{type:String,values:["","contain","cover","fill","none","scale-down"],default:""},loading:{type:String,values:["eager","lazy"]},lazy:Boolean,scrollContainer:{type:H([String,Object])},previewSrcList:{type:H(Array),default:()=>he([])},previewTeleported:Boolean,zIndex:{type:Number},initialIndex:{type:Number,default:0},infinite:{type:Boolean,default:!0},closeOnPressEscape:{type:Boolean,default:!0},zoomRate:{type:Number,default:1.2},minScale:{type:Number,default:.2},maxScale:{type:Number,default:7},crossorigin:{type:H(String)}}),ft={load:s=>s instanceof Event,error:s=>s instanceof Event,switch:s=>fe(s),close:()=>!0,show:()=>!0},vt=ne({name:"ElImage",inheritAttrs:!1}),mt=ne({...vt,props:dt,emits:ft,setup(s,{emit:i}){const n=s;let f="";const{t:l}=Ce(),g=Ie("image"),se=$e(),r=p(()=>qe(Object.entries(se).filter(([e])=>/^(data-|on[A-Z])/i.test(e)||["id","style"].includes(e)))),oe=tt({excludeListeners:!0,excludeKeys:p(()=>Object.keys(r.value))}),R=k(),O=k(!1),S=k(!0),I=k(!1),w=k(),y=k(),c=$&&"loading"in HTMLImageElement.prototype;let B,V;const j=p(()=>[g.e("inner"),D.value&&g.e("preview"),S.value&&g.is("loading")]),K=p(()=>{const{fit:e}=n;return $&&e?{objectFit:e}:{}}),D=p(()=>{const{previewSrcList:e}=n;return Array.isArray(e)&&e.length>0}),le=p(()=>{const{previewSrcList:e,initialIndex:u}=n;let a=u;return u>e.length-1&&(a=0),a}),W=p(()=>n.loading==="eager"?!1:!c&&n.loading==="lazy"||n.lazy),P=()=>{$&&(S.value=!0,O.value=!1,R.value=n.src)};function Y(e){S.value=!1,O.value=!1,i("load",e)}function re(e){S.value=!1,O.value=!0,i("error",e)}function Z(){nt(w.value,y.value)&&(P(),U())}const q=Ge(Z,200,!0);async function G(){var e;if(!$)return;await be();const{scrollContainer:u}=n;Ue(u)?y.value=u:Be(u)&&u!==""?y.value=(e=document.querySelector(u))!=null?e:void 0:w.value&&(y.value=at(w.value)),y.value&&(B=M(y,"scroll",q),setTimeout(()=>Z(),100))}function U(){!$||!y.value||!q||(B==null||B(),y.value=void 0)}function J(e){if(e.ctrlKey){if(e.deltaY<0)return e.preventDefault(),!1;if(e.deltaY>0)return e.preventDefault(),!1}}function Q(){D.value&&(V=M("wheel",J,{passive:!1}),f=document.body.style.overflow,document.body.style.overflow="hidden",I.value=!0,i("show"))}function F(){V==null||V(),document.body.style.overflow=f,I.value=!1,i("close")}function ee(e){i("switch",e)}return ue(()=>n.src,()=>{W.value?(S.value=!0,O.value=!1,U(),G()):P()}),ke(()=>{W.value?G():P()}),(e,u)=>(b(),x("div",we({ref_key:"container",ref:w},t(r),{class:[t(g).b(),e.$attrs.class]}),[O.value?te(e.$slots,"error",{key:0},()=>[h("div",{class:m(t(g).e("error"))},Me(t(l)("el.image.error")),3)]):(b(),x(ae,{key:1},[R.value!==void 0?(b(),x("img",we({key:0},t(oe),{src:R.value,loading:e.loading,style:t(K),class:t(j),crossorigin:e.crossorigin,onClick:Q,onLoad:Y,onError:re}),null,16,["src","loading","crossorigin"])):L("v-if",!0),S.value?(b(),x("div",{key:1,class:m(t(g).e("wrapper"))},[te(e.$slots,"placeholder",{},()=>[h("div",{class:m(t(g).e("placeholder"))},null,2)])],2)):L("v-if",!0)],64)),t(D)?(b(),x(ae,{key:2},[I.value?(b(),de(t(ut),{key:0,"z-index":e.zIndex,"initial-index":t(le),infinite:e.infinite,"zoom-rate":e.zoomRate,"min-scale":e.minScale,"max-scale":e.maxScale,"url-list":e.previewSrcList,crossorigin:e.crossorigin,"hide-on-click-modal":e.hideOnClickModal,teleported:e.previewTeleported,"close-on-press-escape":e.closeOnPressEscape,onClose:F,onSwitch:ee},{default:C(()=>[e.$slots.viewer?(b(),x("div",{key:0},[te(e.$slots,"viewer")])):L("v-if",!0)]),_:3},8,["z-index","initial-index","infinite","zoom-rate","min-scale","max-scale","url-list","crossorigin","hide-on-click-modal","teleported","close-on-press-escape"])):L("v-if",!0)],64)):L("v-if",!0)],16))}});var pt=ze(mt,[["__file","image.vue"]]);const Et=Ee(pt);export{Et as E,zt as g,ce as t};