@gx-design-vue/image 0.1.0 → 0.1.1
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.
- package/dist/image.es.js +801 -0
- package/dist/image.umd.js +1 -1
- package/package.json +8 -8
- package/dist/image.mjs +0 -591
package/dist/image.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(v,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@ant-design/icons-vue"),require("@gx-design-vue/pro-utils"),require("@gx-design-vue/pro-hooks"),require("vue-types"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","@ant-design/icons-vue","@gx-design-vue/pro-utils","@gx-design-vue/pro-hooks","vue-types","@vueuse/core"],e):(v=typeof globalThis<"u"?globalThis:v||self,e(v.GImage={},v.vue,v.iconsVue,v.proUtils,v.proHooks,v.vueTypes,v.core))})(this,function(v,e,O,w,J,oe,W){"use strict";const de="",ue="";var Q=oe.createTypes({func:void 0,bool:void 0,string:void 0,number:void 0,array:void 0,object:void 0,integer:void 0});Q.extend([{name:"looseBool",getter:!0,type:Boolean,default:void 0},{name:"style",getter:!0,type:[String,Object],default:void 0},{name:"VueNode",getter:!0,type:null}]);const H=Q,j={appendToBody:{type:Boolean,default:!1},hideOnClickModal:{type:Boolean,default:!0},src:{type:String,default:""},fit:{type:String,default:""},lazy:H.bool,scrollContainer:{type:[String,Object]},placeholder:{type:[Function,Object],default:()=>{}},fallback:{type:[Function,Object],default:()=>{}},onError:{type:Function},onClick:{type:Function},disablePreview:H.bool,previewSrcList:{type:Array,default:()=>[]},width:H.number,height:H.number,zIndex:{type:Number,default:2e3}},re={urlList:{type:Array,default:()=>[]},zIndex:j.zIndex,initialIndex:{type:Number,default:0},infinite:{type:Boolean,default:!0},onHideOnClickModal:j.hideOnClickModal},T={tab:"Tab",enter:"Enter",space:"Space",left:"ArrowLeft",up:"ArrowUp",right:"ArrowRight",down:"ArrowDown",esc:"Escape",delete:"Delete",backspace:"Backspace"},R=function(t,l,u,N=!1){t&&l&&u&&t.addEventListener(l,u,N)},q=function(t,l,u,N=!1){t&&l&&u&&t.removeEventListener(l,u,N)},A={CONTAIN:{name:"contain",icon:e.createVNode(O.ExpandOutlined,null,null)},ORIGINAL:{name:"original",icon:e.createVNode(O.OneToOneOutlined,null,null)}},U=function(){return!w.isServer&&!!window.navigator.userAgent.match(/firefox/i)}()?"DOMMouseScroll":"mousewheel";function B(t){let l=!1;return function(...u){l||(l=!0,window.requestAnimationFrame(()=>{t.apply(this,u),l=!1}))}}const X=e.defineComponent({props:re,emits:["close","switch"],setup:function(t,{emit:l}){let u=null,N=null,b=null;const o=w.getPrefixCls({suffixCls:"image-viewer"}),f=e.ref(!0),h=e.ref(t.initialIndex),I=e.ref(null),x=e.ref(null),p=e.ref(A.CONTAIN),r=e.ref({scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1}),c=e.computed(()=>{const{urlList:a}=t;return a.length<=1}),d=e.computed(()=>h.value===0),m=e.computed(()=>h.value===t.urlList.length-1),k=e.computed(()=>t.urlList[h.value]),S=e.ref("viewer-fade-enter-active"),E=e.computed(()=>{const{scale:a,deg:y,offsetX:n,offsetY:i,enableTransition:s}=r.value,g={transform:`scale(${a}) rotate(${y}deg)`,transition:s?"transform .3s":"",marginLeft:`${n}px`,marginTop:`${i}px`};return p.value.name===A.CONTAIN.name&&(g.maxWidth=g.maxHeight="100%"),g}),z=()=>{Z(),setTimeout(()=>{l("close")},200)},L=()=>{S.value="viewer-fade-enter-active",u=B(a=>{switch(a.code){case T.esc:z();break;case T.space:D();break;case T.left:G();break;case T.up:C("zoomIn");break;case T.right:Y();break;case T.down:C("zoomOut");break}}),N=B(a=>{(a.wheelDelta?a.wheelDelta:-a.detail)>0?C("zoomIn",{zoomRate:.015,enableTransition:!1}):C("zoomOut",{zoomRate:.015,enableTransition:!1})}),R(document,"keydown",u),R(document,U,N)},Z=()=>{S.value="viewer-fade-leave-active",q(document,"keydown",u),q(document,U,N),u=null,N=null},F=()=>{f.value=!1},_=a=>{f.value=!1,a.target.alt="加载失败"},P=a=>{if(f.value||a.button!==0)return;const{offsetX:y,offsetY:n}=r.value,i=a.pageX,s=a.pageY;b=B(g=>{r.value={...r.value,offsetX:y+g.pageX-i,offsetY:n+g.pageY-s}}),R(document,"mousemove",b),R(document,"mouseup",()=>{q(document,"mousemove",b)}),a.preventDefault()},M=()=>{r.value={scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1}},D=()=>{if(f.value)return;const a=Object.keys(A),y=Object.values(A),n=p.value.name,s=(y.findIndex(g=>g.name===n)+1)%a.length;p.value=A[a[s]],M()},G=()=>{if(d.value&&!t.infinite)return;const a=t.urlList.length;h.value=(h.value-1+a)%a},Y=()=>{if(m.value&&!t.infinite)return;const a=t.urlList.length;h.value=(h.value+1)%a},C=(a,y={})=>{if(f.value)return;const{zoomRate:n,rotateDeg:i,enableTransition:s}={zoomRate:.2,rotateDeg:90,enableTransition:!0,...y};switch(a){case"zoomOut":r.value.scale>.2&&(r.value.scale=parseFloat((r.value.scale-n).toFixed(3)));break;case"zoomIn":r.value.scale=parseFloat((r.value.scale+n).toFixed(3));break;case"clocelise":r.value.deg+=i;break;case"anticlocelise":r.value.deg-=i;break}r.value.enableTransition=s};return e.watch(k,()=>{e.nextTick(()=>{x.value.complete||(f.value=!0)})}),e.watch(h,a=>{M(),l("switch",a)}),J.onMountedOrActivated(()=>{var a,y;L(),(y=(a=I.value)==null?void 0:a.focus)==null||y.call(a)}),()=>e.createVNode("div",{ref:a=>I.value=a,tabindex:1,class:[`${o}-wrapper`,`${S.value}`],style:{zIndex:t.zIndex}},[e.createVNode("div",{class:`${o}-mask`,onClick:()=>t.onHideOnClickModal&&z()},null),e.createVNode("span",{class:[`${o}-btn`,`${o}-close`],onClick:()=>z()},[e.createVNode(O.CloseOutlined,null,null)]),!c.value&&e.createVNode(e.Fragment,null,[e.createVNode("span",{class:{[`${o}-btn`]:!0,[`${o}-prev`]:!0,["is-disabled"]:!t.infinite&&d.value},onClick:()=>G()},[e.createVNode(O.LeftOutlined,null,null)]),e.createVNode("span",{class:{[`${o}-btn`]:!0,[`${o}-next`]:!0,["is-disabled"]:!t.infinite&&d.value},onClick:()=>Y()},[e.createVNode(O.RightOutlined,null,null)])]),e.createVNode("div",{class:[`${o}-btn`,`${o}-actions`]},[e.createVNode("div",{class:`${o}-actions-inner`},[e.createVNode(O.ZoomOutOutlined,{onClick:()=>C("zoomOut")},null),e.createVNode(O.ZoomInOutlined,{onClick:()=>C("zoomIn")},null),e.createVNode("i",{class:`${o}-actions-divider`},null),e.createVNode("i",{onClick:()=>D()},[p.value.icon]),e.createVNode("i",{class:`${o}-actions-divider`},null),e.createVNode(O.RotateLeftOutlined,{onClick:()=>C("anticlocelise")},null),e.createVNode(O.RotateRightOutlined,{onClick:()=>C("clocelise")},null)])]),f.value&&e.createVNode("div",{class:`${o}-canvas`},[e.createVNode(e.resolveComponent("a-spin"),{indicator:e.createVNode(O.LoadingOutlined,{style:{color:"#fff",fontSize:"40px"}},null)},null)]),e.createVNode("div",{class:`${o}-canvas`},[t.urlList.map((a,y)=>e.createVNode("img",{ref:n=>x.value=n,class:`${o}-img`,key:a,style:{...E.value,display:y===h.value?"block":"none"},src:a,onLoad:()=>F(),onError:n=>_(n),onMousedown:n=>P(n)},null))])])}});function ie(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!e.isVNode(t)}let ee="";const ce=e.defineComponent({props:{hideOnClickModal:j.hideOnClickModal},setup(t,{slots:l}){const u=w.getPrefixCls({suffixCls:"image-viewer-group"}),N=e.ref(!1),b=e.ref(""),o=e.computed(()=>{var c,d,m,k,S;return((c=l.default)==null?void 0:c.call(l).length)===1&&(String((d=l.default)==null?void 0:d.call(l)[0].type)===String(Symbol("Fragment"))||String((m=l.default)==null?void 0:m.call(l)[0].type)===String(Symbol()))?((k=l.default)==null?void 0:k.call(l)[0].children)||[]:((S=l.default)==null?void 0:S.call(l))||[]}),f=e.computed(()=>o.value.filter(m=>I(m)).map(m=>m.props.src).filter(m=>m)||[]),h=e.computed(()=>Array.isArray(f.value)&&f.value.length>0),I=c=>c&&c.type&&(c.type.isGImage||c.type.name==="GImage"),x=()=>{let c=0;const d=f.value.findIndex(m=>m===b.value);return d>=0&&(c=d),c},p=c=>{!h.value||!c||(b.value=c,ee=document.body.style.overflow,document.body.style.overflow="hidden",N.value=!0)},r=()=>{document.body.style.overflow=ee,N.value=!1};return()=>{let c;return e.createVNode("div",{class:`${u}`},[e.createVNode(e.resolveComponent("a-space"),{size:15},ie(c=o.value.map((d,m)=>I(d)?e.createVNode("div",{key:m,class:`${u}-item`,onClick:()=>{var k;return p(((k=d.props)==null?void 0:k.src)||"")}},[e.cloneVNode(d,{disablePreview:!0})]):null))?c:{default:()=>[c]}),e.createVNode(e.Teleport,{to:"body"},{default:()=>[h.value&&N.value&&e.createVNode(X,{initialIndex:x(),urlList:f.value,onHideOnClickModal:t.hideOnClickModal,onClose:()=>r()},null)]})])}}}),se=t=>t&&t.nodeType===Node.ELEMENT_NODE,te=()=>document.documentElement.style.objectFit!==void 0;let ne="";const V={NONE:"none",CONTAIN:"contain",COVER:"cover",FILL:"fill",SCALE_DOWN:"scale-down"},$=e.defineComponent({props:j,name:"GImage",inheritAttrs:!1,emits:["error","click"],setup(t,{slots:l,emit:u,attrs:N}){const b=w.getPrefixCls({suffixCls:"image"}),o=e.ref(!1),f=e.ref(!0),h=e.ref(0),I=e.ref(0),x=e.ref(!1),p=e.ref(null),r=e.ref();let c,d;const m=e.computed(()=>({width:t.width?`${t.width}px`:void 0,height:t.height?`${t.height}px`:void 0})),k=e.computed(()=>{const{fit:n}=t;return!w.isServer&&n?te()?{"object-fit":n,...m.value}:{...Z(n),...m.value}:m.value}),S=e.computed(()=>{const{fit:n}=t;return!w.isServer&&!te()&&n!==V.FILL}),E=e.computed(()=>{const{previewSrcList:n}=t;return Array.isArray(n)&&n.length>0}),z=e.computed(()=>{const{src:n,previewSrcList:i}=t;let s=0;const g=i.indexOf(n);return g>=0&&(s=g),s}),L=e.computed(()=>N),Z=n=>{const i=t.width||h.value,s=t.height||I.value;if(!p.value)return{};const{clientWidth:g,clientHeight:K}=p.value;if(!i||!s||!g||!K)return{};const ae=i/s,le=g/K;switch(n===V.SCALE_DOWN&&(n=i<g&&s<K?V.NONE:V.CONTAIN),n){case V.NONE:return{width:"auto",height:"auto"};case V.CONTAIN:return ae<le?{width:"auto"}:{height:"auto"};case V.COVER:return ae<le?{height:"auto"}:{width:"auto"};default:return{}}},F=()=>{if(w.isServer)return;const n=L.value;f.value=!0,o.value=!1;const i=new Image;i.onload=s=>G(s,i),i.onerror=Y,Object.keys(n).forEach(s=>{if(s.toLowerCase()==="onload")return;const g=n[s];i.setAttribute(s,g)}),i.src=t.src};function _(){w.isInContainer(p.value,r.value)&&(F(),D())}const P=W.useThrottleFn(_,200),M=async()=>{if(w.isServer)return;await e.nextTick();const{scrollContainer:n}=t;se(n)?r.value=n:w.isString(n)&&n!==""?r.value=document.querySelector(n)??void 0:p.value&&(r.value=w.getScrollContainer(p.value)),r.value&&(c=W.useEventListener(r,"scroll",P),setTimeout(()=>_(),200))},D=()=>{w.isServer||!r.value||!P||(c(),r.value=void 0)},G=(n,i)=>{h.value=i.width,I.value=i.height,f.value=!1,o.value=!1},Y=n=>{f.value=!1,o.value=!0,u("error",n)},C=n=>{if(n.ctrlKey){if(n.deltaY<0)return n.preventDefault(),!1;if(n.deltaY>0)return n.preventDefault(),!1}},a=()=>{!E.value||t.disablePreview||(d=W.useEventListener("wheel",C,{passive:!1}),ne=document.body.style.overflow,document.body.style.overflow="hidden",x.value=!0)},y=()=>{d==null||d(),document.body.style.overflow=ne,x.value=!1};return e.watch(()=>t.src,()=>{t.lazy?(f.value=!0,o.value=!1,D(),M()):F()}),J.onMountedOrActivated(()=>{t.lazy?M():F()}),()=>{const n=w.getSlotVNode(l,t,"fallback"),i=w.getSlotVNode(l,t,"placeholder");return e.createVNode(e.Fragment,null,[e.createVNode("div",{class:{[`${b}`]:!0,[`${L.value.class}`]:L.value.class},ref:s=>p.value=s,style:{...L.value.style||{},display:t.lazy?"block":void 0},onClick:()=>{u("click")}},[f.value?i||e.createVNode("div",{class:`${b}-placeholder`},null):o.value?n||e.createVNode("div",{class:`${b}-error`},[e.createTextVNode("加载失败")]):e.createVNode("img",e.mergeProps({class:{[`${b}-inner`]:!0,[`${b}-inner-center`]:S.value,[`${b}-preview`]:E.value}},L.value,{src:t.src,style:k.value,onClick:()=>a()}),null),e.createVNode(e.Teleport,{to:"body",disabled:!t.appendToBody},{default:()=>[E.value&&x.value&&e.createVNode(X,{zIndex:t.zIndex,initialIndex:z.value,urlList:t.previewSrcList,onHideOnClickModal:t.hideOnClickModal,onClose:()=>y()},null)]})])])}}});$.isWImage=!0,$.install=t=>(t.component($.name,$),t),v.GImage=$,v.ImageViewer=X,v.ImageViewerGroup=ce,v.default=$,Object.defineProperties(v,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(v,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue"),require("@ant-design/icons-vue"),require("@gx-design-vue/pro-utils"),require("@gx-design-vue/pro-hooks"),require("vue-types"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","@ant-design/icons-vue","@gx-design-vue/pro-utils","@gx-design-vue/pro-hooks","vue-types","@vueuse/core"],e):(v=typeof globalThis!="undefined"?globalThis:v||self,e(v.GImage={},v.vue,v.iconsVue,v.proUtils,v.proHooks,v.vueTypes,v.core))})(this,function(v,e,O,w,J,oe,W){"use strict";var de="",ue="",Q=oe.createTypes({func:void 0,bool:void 0,string:void 0,number:void 0,array:void 0,object:void 0,integer:void 0});Q.extend([{name:"looseBool",getter:!0,type:Boolean,default:void 0},{name:"style",getter:!0,type:[String,Object],default:void 0},{name:"VueNode",getter:!0,type:null}]);var H=Q;const j={appendToBody:{type:Boolean,default:!1},hideOnClickModal:{type:Boolean,default:!0},src:{type:String,default:""},fit:{type:String,default:""},lazy:H.bool,scrollContainer:{type:[String,Object]},placeholder:{type:[Function,Object],default:()=>{}},fallback:{type:[Function,Object],default:()=>{}},onError:{type:Function},onClick:{type:Function},disablePreview:H.bool,previewSrcList:{type:Array,default:()=>[]},width:H.number,height:H.number,zIndex:{type:Number,default:2e3}},re={urlList:{type:Array,default:()=>[]},zIndex:j.zIndex,initialIndex:{type:Number,default:0},infinite:{type:Boolean,default:!0},onHideOnClickModal:j.hideOnClickModal},T={tab:"Tab",enter:"Enter",space:"Space",left:"ArrowLeft",up:"ArrowUp",right:"ArrowRight",down:"ArrowDown",esc:"Escape",delete:"Delete",backspace:"Backspace"},R=function(t,l,u,N=!1){t&&l&&u&&t.addEventListener(l,u,N)},q=function(t,l,u,N=!1){t&&l&&u&&t.removeEventListener(l,u,N)},A={CONTAIN:{name:"contain",icon:e.createVNode(O.ExpandOutlined,null,null)},ORIGINAL:{name:"original",icon:e.createVNode(O.OneToOneOutlined,null,null)}},U=function(){return!w.isServer&&!!window.navigator.userAgent.match(/firefox/i)}()?"DOMMouseScroll":"mousewheel";function B(t){let l=!1;return function(...u){l||(l=!0,window.requestAnimationFrame(()=>{t.apply(this,u),l=!1}))}}const X=e.defineComponent({props:re,emits:["close","switch"],setup:function(t,{emit:l}){let u=null,N=null,b=null;const r=w.getPrefixCls({suffixCls:"image-viewer"}),f=e.ref(!0),h=e.ref(t.initialIndex),I=e.ref(null),x=e.ref(null),p=e.ref(A.CONTAIN),i=e.ref({scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1}),c=e.computed(()=>{const{urlList:a}=t;return a.length<=1}),d=e.computed(()=>h.value===0),m=e.computed(()=>h.value===t.urlList.length-1),k=e.computed(()=>t.urlList[h.value]),S=e.ref("viewer-fade-enter-active"),E=e.computed(()=>{const{scale:a,deg:y,offsetX:n,offsetY:o,enableTransition:s}=i.value,g={transform:`scale(${a}) rotate(${y}deg)`,transition:s?"transform .3s":"",marginLeft:`${n}px`,marginTop:`${o}px`};return p.value.name===A.CONTAIN.name&&(g.maxWidth=g.maxHeight="100%"),g}),z=()=>{Z(),setTimeout(()=>{l("close")},200)},L=()=>{S.value="viewer-fade-enter-active",u=B(a=>{switch(a.code){case T.esc:z();break;case T.space:D();break;case T.left:G();break;case T.up:C("zoomIn");break;case T.right:Y();break;case T.down:C("zoomOut");break}}),N=B(a=>{(a.wheelDelta?a.wheelDelta:-a.detail)>0?C("zoomIn",{zoomRate:.015,enableTransition:!1}):C("zoomOut",{zoomRate:.015,enableTransition:!1})}),R(document,"keydown",u),R(document,U,N)},Z=()=>{S.value="viewer-fade-leave-active",q(document,"keydown",u),q(document,U,N),u=null,N=null},F=()=>{f.value=!1},_=a=>{f.value=!1,a.target.alt="\u52A0\u8F7D\u5931\u8D25"},P=a=>{if(f.value||a.button!==0)return;const{offsetX:y,offsetY:n}=i.value,o=a.pageX,s=a.pageY;b=B(g=>{i.value={...i.value,offsetX:y+g.pageX-o,offsetY:n+g.pageY-s}}),R(document,"mousemove",b),R(document,"mouseup",()=>{q(document,"mousemove",b)}),a.preventDefault()},M=()=>{i.value={scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1}},D=()=>{if(f.value)return;const a=Object.keys(A),y=Object.values(A),n=p.value.name,s=(y.findIndex(g=>g.name===n)+1)%a.length;p.value=A[a[s]],M()},G=()=>{if(d.value&&!t.infinite)return;const a=t.urlList.length;h.value=(h.value-1+a)%a},Y=()=>{if(m.value&&!t.infinite)return;const a=t.urlList.length;h.value=(h.value+1)%a},C=(a,y={})=>{if(f.value)return;const{zoomRate:n,rotateDeg:o,enableTransition:s}={zoomRate:.2,rotateDeg:90,enableTransition:!0,...y};switch(a){case"zoomOut":i.value.scale>.2&&(i.value.scale=parseFloat((i.value.scale-n).toFixed(3)));break;case"zoomIn":i.value.scale=parseFloat((i.value.scale+n).toFixed(3));break;case"clocelise":i.value.deg+=o;break;case"anticlocelise":i.value.deg-=o;break}i.value.enableTransition=s};return e.watch(k,()=>{e.nextTick(()=>{x.value.complete||(f.value=!0)})}),e.watch(h,a=>{M(),l("switch",a)}),J.onMountedOrActivated(()=>{var a,y;L(),(y=(a=I.value)==null?void 0:a.focus)==null||y.call(a)}),()=>e.createVNode("div",{ref:a=>I.value=a,tabindex:1,class:[`${r}-wrapper`,`${S.value}`],style:{zIndex:t.zIndex}},[e.createVNode("div",{class:`${r}-mask`,onClick:()=>t.onHideOnClickModal&&z()},null),e.createVNode("span",{class:[`${r}-btn`,`${r}-close`],onClick:()=>z()},[e.createVNode(O.CloseOutlined,null,null)]),!c.value&&e.createVNode(e.Fragment,null,[e.createVNode("span",{class:{[`${r}-btn`]:!0,[`${r}-prev`]:!0,["is-disabled"]:!t.infinite&&d.value},onClick:()=>G()},[e.createVNode(O.LeftOutlined,null,null)]),e.createVNode("span",{class:{[`${r}-btn`]:!0,[`${r}-next`]:!0,["is-disabled"]:!t.infinite&&d.value},onClick:()=>Y()},[e.createVNode(O.RightOutlined,null,null)])]),e.createVNode("div",{class:[`${r}-btn`,`${r}-actions`]},[e.createVNode("div",{class:`${r}-actions-inner`},[e.createVNode(O.ZoomOutOutlined,{onClick:()=>C("zoomOut")},null),e.createVNode(O.ZoomInOutlined,{onClick:()=>C("zoomIn")},null),e.createVNode("i",{class:`${r}-actions-divider`},null),e.createVNode("i",{onClick:()=>D()},[p.value.icon]),e.createVNode("i",{class:`${r}-actions-divider`},null),e.createVNode(O.RotateLeftOutlined,{onClick:()=>C("anticlocelise")},null),e.createVNode(O.RotateRightOutlined,{onClick:()=>C("clocelise")},null)])]),f.value&&e.createVNode("div",{class:`${r}-canvas`},[e.createVNode(e.resolveComponent("a-spin"),{indicator:e.createVNode(O.LoadingOutlined,{style:{color:"#fff",fontSize:"40px"}},null)},null)]),e.createVNode("div",{class:`${r}-canvas`},[t.urlList.map((a,y)=>e.createVNode("img",{ref:n=>x.value=n,class:`${r}-img`,key:a,style:{...E.value,display:y===h.value?"block":"none"},src:a,onLoad:()=>F(),onError:n=>_(n),onMousedown:n=>P(n)},null))])])}});function ie(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!e.isVNode(t)}let ee="";const ce=e.defineComponent({props:{hideOnClickModal:j.hideOnClickModal},setup(t,{slots:l}){const u=w.getPrefixCls({suffixCls:"image-viewer-group"}),N=e.ref(!1),b=e.ref(""),r=e.computed(()=>{var c,d,m,k,S;return((c=l.default)==null?void 0:c.call(l).length)===1&&(String((d=l.default)==null?void 0:d.call(l)[0].type)===String(Symbol("Fragment"))||String((m=l.default)==null?void 0:m.call(l)[0].type)===String(Symbol()))?((k=l.default)==null?void 0:k.call(l)[0].children)||[]:((S=l.default)==null?void 0:S.call(l))||[]}),f=e.computed(()=>r.value.filter(m=>I(m)).map(m=>m.props.src).filter(m=>m)||[]),h=e.computed(()=>Array.isArray(f.value)&&f.value.length>0),I=c=>c&&c.type&&(c.type.isGImage||c.type.name==="GImage"),x=()=>{let c=0;const d=f.value.findIndex(m=>m===b.value);return d>=0&&(c=d),c},p=c=>{!h.value||!c||(b.value=c,ee=document.body.style.overflow,document.body.style.overflow="hidden",N.value=!0)},i=()=>{document.body.style.overflow=ee,N.value=!1};return()=>{let c;return e.createVNode("div",{class:`${u}`},[e.createVNode(e.resolveComponent("a-space"),{size:15},ie(c=r.value.map((d,m)=>I(d)?e.createVNode("div",{key:m,class:`${u}-item`,onClick:()=>{var k;return p(((k=d.props)==null?void 0:k.src)||"")}},[e.cloneVNode(d,{disablePreview:!0})]):null))?c:{default:()=>[c]}),e.createVNode(e.Teleport,{to:"body"},{default:()=>[h.value&&N.value&&e.createVNode(X,{initialIndex:x(),urlList:f.value,onHideOnClickModal:t.hideOnClickModal,onClose:()=>i()},null)]})])}}}),se=t=>t&&t.nodeType===Node.ELEMENT_NODE,te=()=>document.documentElement.style.objectFit!==void 0;let ne="";const V={NONE:"none",CONTAIN:"contain",COVER:"cover",FILL:"fill",SCALE_DOWN:"scale-down"},$=e.defineComponent({props:j,name:"GImage",inheritAttrs:!1,emits:["error","click"],setup(t,{slots:l,emit:u,attrs:N}){const b=w.getPrefixCls({suffixCls:"image"}),r=e.ref(!1),f=e.ref(!0),h=e.ref(0),I=e.ref(0),x=e.ref(!1),p=e.ref(null),i=e.ref();let c,d;const m=e.computed(()=>({width:t.width?`${t.width}px`:void 0,height:t.height?`${t.height}px`:void 0})),k=e.computed(()=>{const{fit:n}=t;return!w.isServer&&n?te()?{"object-fit":n,...m.value}:{...Z(n),...m.value}:m.value}),S=e.computed(()=>{const{fit:n}=t;return!w.isServer&&!te()&&n!==V.FILL}),E=e.computed(()=>{const{previewSrcList:n}=t;return Array.isArray(n)&&n.length>0}),z=e.computed(()=>{const{src:n,previewSrcList:o}=t;let s=0;const g=o.indexOf(n);return g>=0&&(s=g),s}),L=e.computed(()=>N),Z=n=>{const o=t.width||h.value,s=t.height||I.value;if(!p.value)return{};const{clientWidth:g,clientHeight:K}=p.value;if(!o||!s||!g||!K)return{};const ae=o/s,le=g/K;switch(n===V.SCALE_DOWN&&(n=o<g&&s<K?V.NONE:V.CONTAIN),n){case V.NONE:return{width:"auto",height:"auto"};case V.CONTAIN:return ae<le?{width:"auto"}:{height:"auto"};case V.COVER:return ae<le?{height:"auto"}:{width:"auto"};default:return{}}},F=()=>{if(w.isServer)return;const n=L.value;f.value=!0,r.value=!1;const o=new Image;o.onload=s=>G(s,o),o.onerror=Y,Object.keys(n).forEach(s=>{if(s.toLowerCase()==="onload")return;const g=n[s];o.setAttribute(s,g)}),o.src=t.src};function _(){w.isInContainer(p.value,i.value)&&(F(),D())}const P=W.useThrottleFn(_,200),M=async()=>{var o;if(w.isServer)return;await e.nextTick();const{scrollContainer:n}=t;se(n)?i.value=n:w.isString(n)&&n!==""?i.value=(o=document.querySelector(n))!=null?o:void 0:p.value&&(i.value=w.getScrollContainer(p.value)),i.value&&(c=W.useEventListener(i,"scroll",P),setTimeout(()=>_(),200))},D=()=>{w.isServer||!i.value||!P||(c(),i.value=void 0)},G=(n,o)=>{h.value=o.width,I.value=o.height,f.value=!1,r.value=!1},Y=n=>{f.value=!1,r.value=!0,u("error",n)},C=n=>{if(!!n.ctrlKey){if(n.deltaY<0)return n.preventDefault(),!1;if(n.deltaY>0)return n.preventDefault(),!1}},a=()=>{!E.value||t.disablePreview||(d=W.useEventListener("wheel",C,{passive:!1}),ne=document.body.style.overflow,document.body.style.overflow="hidden",x.value=!0)},y=()=>{d==null||d(),document.body.style.overflow=ne,x.value=!1};return e.watch(()=>t.src,()=>{t.lazy?(f.value=!0,r.value=!1,D(),M()):F()}),J.onMountedOrActivated(()=>{t.lazy?M():F()}),()=>{const n=w.getSlotVNode(l,t,"fallback"),o=w.getSlotVNode(l,t,"placeholder");return e.createVNode(e.Fragment,null,[e.createVNode("div",{class:{[`${b}`]:!0,[`${L.value.class}`]:L.value.class},ref:s=>p.value=s,style:{...L.value.style||{},display:t.lazy?"block":void 0},onClick:()=>{u("click")}},[f.value?o||e.createVNode("div",{class:`${b}-placeholder`},null):r.value?n||e.createVNode("div",{class:`${b}-error`},[e.createTextVNode("\u52A0\u8F7D\u5931\u8D25")]):e.createVNode("img",e.mergeProps({class:{[`${b}-inner`]:!0,[`${b}-inner-center`]:S.value,[`${b}-preview`]:E.value}},L.value,{src:t.src,style:k.value,onClick:()=>a()}),null),e.createVNode(e.Teleport,{to:"body",disabled:!t.appendToBody},{default:()=>[E.value&&x.value&&e.createVNode(X,{zIndex:t.zIndex,initialIndex:z.value,urlList:t.previewSrcList,onHideOnClickModal:t.hideOnClickModal,onClose:()=>y()},null)]})])])}}});$.isWImage=!0,$.install=t=>(t.component($.name,$),t),v.GImage=$,v.ImageViewer=X,v.ImageViewerGroup=ce,v.default=$,Object.defineProperties(v,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gx-design-vue/image",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vite",
|
|
6
6
|
"build": "vite build",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@vueuse/core": "^9.10.0",
|
|
29
|
-
"@gx-design-vue/pro-utils": "^0.1.
|
|
30
|
-
"@gx-design-vue/pro-hooks": "^0.1.
|
|
31
|
-
"ant-design-vue": "^3.2.
|
|
29
|
+
"@gx-design-vue/pro-utils": "^0.1.3",
|
|
30
|
+
"@gx-design-vue/pro-hooks": "^0.1.4",
|
|
31
|
+
"ant-design-vue": "^3.2.17",
|
|
32
32
|
"vue": "^3.2.45",
|
|
33
33
|
"vue-types": "^4.1.1"
|
|
34
34
|
},
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@types/lodash-es": "^4.17.6",
|
|
40
40
|
"@types/jsdom": "^16.2.14",
|
|
41
41
|
"@types/node": "^16.11.26",
|
|
42
|
-
"@vitejs/plugin-vue": "^
|
|
43
|
-
"@vitejs/plugin-vue-jsx": "^3.
|
|
42
|
+
"@vitejs/plugin-vue": "^2.3.1",
|
|
43
|
+
"@vitejs/plugin-vue-jsx": "^1.3.10",
|
|
44
44
|
"@vue/eslint-config-prettier": "^7.0.0",
|
|
45
45
|
"@vue/eslint-config-typescript": "^10.0.0",
|
|
46
46
|
"@vue/tsconfig": "^0.1.3",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"stylelint-config-standard": "^25.0.0",
|
|
62
62
|
"stylelint-order": "^5.0.0",
|
|
63
63
|
"typescript": "^4.6.4",
|
|
64
|
-
"vite": "^
|
|
64
|
+
"vite": "^2.9.14",
|
|
65
65
|
"vue-eslint-parser": "^9.0.3",
|
|
66
|
-
"vue-tsc": "0.
|
|
66
|
+
"vue-tsc": "^1.0.24"
|
|
67
67
|
},
|
|
68
68
|
"description": "Gx Design"
|
|
69
69
|
}
|
package/dist/image.mjs
DELETED
|
@@ -1,591 +0,0 @@
|
|
|
1
|
-
import { createVNode as l, defineComponent as Z, ref as g, computed as b, watch as U, nextTick as oe, Fragment as re, resolveComponent as ue, cloneVNode as ve, Teleport as ce, isVNode as me, createTextVNode as ge, mergeProps as he } from "vue";
|
|
2
|
-
import { ExpandOutlined as ye, OneToOneOutlined as we, CloseOutlined as be, LeftOutlined as pe, RightOutlined as Oe, ZoomOutOutlined as Ce, ZoomInOutlined as Ie, RotateLeftOutlined as ke, RotateRightOutlined as xe, LoadingOutlined as Le } from "@ant-design/icons-vue";
|
|
3
|
-
import { isServer as T, getPrefixCls as K, getSlotVNode as ee, isInContainer as Se, isString as Ne, getScrollContainer as $e } from "@gx-design-vue/pro-utils";
|
|
4
|
-
import { onMountedOrActivated as se } from "@gx-design-vue/pro-hooks";
|
|
5
|
-
import { createTypes as Te } from "vue-types";
|
|
6
|
-
import { useThrottleFn as Ae, useEventListener as te } from "@vueuse/core";
|
|
7
|
-
var de = Te({
|
|
8
|
-
func: void 0,
|
|
9
|
-
bool: void 0,
|
|
10
|
-
string: void 0,
|
|
11
|
-
number: void 0,
|
|
12
|
-
array: void 0,
|
|
13
|
-
object: void 0,
|
|
14
|
-
integer: void 0
|
|
15
|
-
});
|
|
16
|
-
de.extend([{
|
|
17
|
-
name: "looseBool",
|
|
18
|
-
getter: !0,
|
|
19
|
-
type: Boolean,
|
|
20
|
-
default: void 0
|
|
21
|
-
}, {
|
|
22
|
-
name: "style",
|
|
23
|
-
getter: !0,
|
|
24
|
-
type: [String, Object],
|
|
25
|
-
default: void 0
|
|
26
|
-
}, {
|
|
27
|
-
name: "VueNode",
|
|
28
|
-
getter: !0,
|
|
29
|
-
type: null
|
|
30
|
-
}]);
|
|
31
|
-
const _ = de, P = {
|
|
32
|
-
appendToBody: {
|
|
33
|
-
type: Boolean,
|
|
34
|
-
default: !1
|
|
35
|
-
},
|
|
36
|
-
hideOnClickModal: {
|
|
37
|
-
type: Boolean,
|
|
38
|
-
default: !0
|
|
39
|
-
},
|
|
40
|
-
src: {
|
|
41
|
-
type: String,
|
|
42
|
-
default: ""
|
|
43
|
-
},
|
|
44
|
-
fit: {
|
|
45
|
-
type: String,
|
|
46
|
-
default: ""
|
|
47
|
-
},
|
|
48
|
-
lazy: _.bool,
|
|
49
|
-
scrollContainer: {
|
|
50
|
-
type: [String, Object]
|
|
51
|
-
},
|
|
52
|
-
placeholder: {
|
|
53
|
-
type: [Function, Object],
|
|
54
|
-
default: () => {
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
fallback: {
|
|
58
|
-
type: [Function, Object],
|
|
59
|
-
default: () => {
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
onError: {
|
|
63
|
-
type: Function
|
|
64
|
-
},
|
|
65
|
-
onClick: {
|
|
66
|
-
type: Function
|
|
67
|
-
},
|
|
68
|
-
disablePreview: _.bool,
|
|
69
|
-
previewSrcList: {
|
|
70
|
-
type: Array,
|
|
71
|
-
default: () => []
|
|
72
|
-
},
|
|
73
|
-
width: _.number,
|
|
74
|
-
height: _.number,
|
|
75
|
-
zIndex: {
|
|
76
|
-
type: Number,
|
|
77
|
-
default: 2e3
|
|
78
|
-
}
|
|
79
|
-
}, ze = {
|
|
80
|
-
urlList: {
|
|
81
|
-
type: Array,
|
|
82
|
-
default: () => []
|
|
83
|
-
},
|
|
84
|
-
zIndex: P.zIndex,
|
|
85
|
-
initialIndex: {
|
|
86
|
-
type: Number,
|
|
87
|
-
default: 0
|
|
88
|
-
},
|
|
89
|
-
infinite: {
|
|
90
|
-
type: Boolean,
|
|
91
|
-
default: !0
|
|
92
|
-
},
|
|
93
|
-
onHideOnClickModal: P.hideOnClickModal
|
|
94
|
-
}, $ = {
|
|
95
|
-
tab: "Tab",
|
|
96
|
-
enter: "Enter",
|
|
97
|
-
space: "Space",
|
|
98
|
-
left: "ArrowLeft",
|
|
99
|
-
up: "ArrowUp",
|
|
100
|
-
right: "ArrowRight",
|
|
101
|
-
down: "ArrowDown",
|
|
102
|
-
esc: "Escape",
|
|
103
|
-
delete: "Delete",
|
|
104
|
-
backspace: "Backspace"
|
|
105
|
-
}, Y = function(e, a, d, w = !1) {
|
|
106
|
-
e && a && d && e.addEventListener(a, d, w);
|
|
107
|
-
}, X = function(e, a, d, w = !1) {
|
|
108
|
-
e && a && d && e.removeEventListener(a, d, w);
|
|
109
|
-
}, V = {
|
|
110
|
-
CONTAIN: {
|
|
111
|
-
name: "contain",
|
|
112
|
-
icon: l(ye, null, null)
|
|
113
|
-
},
|
|
114
|
-
ORIGINAL: {
|
|
115
|
-
name: "original",
|
|
116
|
-
icon: l(we, null, null)
|
|
117
|
-
}
|
|
118
|
-
}, Ee = function() {
|
|
119
|
-
return !T && !!window.navigator.userAgent.match(/firefox/i);
|
|
120
|
-
}, ne = Ee() ? "DOMMouseScroll" : "mousewheel";
|
|
121
|
-
function q(e) {
|
|
122
|
-
let a = !1;
|
|
123
|
-
return function(...d) {
|
|
124
|
-
a || (a = !0, window.requestAnimationFrame(() => {
|
|
125
|
-
e.apply(this, d), a = !1;
|
|
126
|
-
}));
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
const fe = /* @__PURE__ */ Z({
|
|
130
|
-
props: ze,
|
|
131
|
-
emits: ["close", "switch"],
|
|
132
|
-
setup: function(e, {
|
|
133
|
-
emit: a
|
|
134
|
-
}) {
|
|
135
|
-
let d = null, w = null, p = null;
|
|
136
|
-
const i = K({
|
|
137
|
-
suffixCls: "image-viewer"
|
|
138
|
-
}), f = g(!0), h = g(e.initialIndex), k = g(null), x = g(null), O = g(V.CONTAIN), o = g({
|
|
139
|
-
scale: 1,
|
|
140
|
-
deg: 0,
|
|
141
|
-
offsetX: 0,
|
|
142
|
-
offsetY: 0,
|
|
143
|
-
enableTransition: !1
|
|
144
|
-
}), u = b(() => {
|
|
145
|
-
const {
|
|
146
|
-
urlList: n
|
|
147
|
-
} = e;
|
|
148
|
-
return n.length <= 1;
|
|
149
|
-
}), s = b(() => h.value === 0), v = b(() => h.value === e.urlList.length - 1), I = b(() => e.urlList[h.value]), L = g("viewer-fade-enter-active"), A = b(() => {
|
|
150
|
-
const {
|
|
151
|
-
scale: n,
|
|
152
|
-
deg: y,
|
|
153
|
-
offsetX: t,
|
|
154
|
-
offsetY: r,
|
|
155
|
-
enableTransition: c
|
|
156
|
-
} = o.value, m = {
|
|
157
|
-
transform: `scale(${n}) rotate(${y}deg)`,
|
|
158
|
-
transition: c ? "transform .3s" : "",
|
|
159
|
-
marginLeft: `${t}px`,
|
|
160
|
-
marginTop: `${r}px`
|
|
161
|
-
};
|
|
162
|
-
return O.value.name === V.CONTAIN.name && (m.maxWidth = m.maxHeight = "100%"), m;
|
|
163
|
-
}), z = () => {
|
|
164
|
-
W(), setTimeout(() => {
|
|
165
|
-
a("close");
|
|
166
|
-
}, 200);
|
|
167
|
-
}, S = () => {
|
|
168
|
-
L.value = "viewer-fade-enter-active", d = q((n) => {
|
|
169
|
-
switch (n.code) {
|
|
170
|
-
case $.esc:
|
|
171
|
-
z();
|
|
172
|
-
break;
|
|
173
|
-
case $.space:
|
|
174
|
-
M();
|
|
175
|
-
break;
|
|
176
|
-
case $.left:
|
|
177
|
-
R();
|
|
178
|
-
break;
|
|
179
|
-
case $.up:
|
|
180
|
-
C("zoomIn");
|
|
181
|
-
break;
|
|
182
|
-
case $.right:
|
|
183
|
-
j();
|
|
184
|
-
break;
|
|
185
|
-
case $.down:
|
|
186
|
-
C("zoomOut");
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
}), w = q((n) => {
|
|
190
|
-
(n.wheelDelta ? n.wheelDelta : -n.detail) > 0 ? C("zoomIn", {
|
|
191
|
-
zoomRate: 0.015,
|
|
192
|
-
enableTransition: !1
|
|
193
|
-
}) : C("zoomOut", {
|
|
194
|
-
zoomRate: 0.015,
|
|
195
|
-
enableTransition: !1
|
|
196
|
-
});
|
|
197
|
-
}), Y(document, "keydown", d), Y(document, ne, w);
|
|
198
|
-
}, W = () => {
|
|
199
|
-
L.value = "viewer-fade-leave-active", X(document, "keydown", d), X(document, ne, w), d = null, w = null;
|
|
200
|
-
}, E = () => {
|
|
201
|
-
f.value = !1;
|
|
202
|
-
}, D = (n) => {
|
|
203
|
-
f.value = !1, n.target.alt = "加载失败";
|
|
204
|
-
}, H = (n) => {
|
|
205
|
-
if (f.value || n.button !== 0)
|
|
206
|
-
return;
|
|
207
|
-
const {
|
|
208
|
-
offsetX: y,
|
|
209
|
-
offsetY: t
|
|
210
|
-
} = o.value, r = n.pageX, c = n.pageY;
|
|
211
|
-
p = q((m) => {
|
|
212
|
-
o.value = {
|
|
213
|
-
...o.value,
|
|
214
|
-
offsetX: y + m.pageX - r,
|
|
215
|
-
offsetY: t + m.pageY - c
|
|
216
|
-
};
|
|
217
|
-
}), Y(document, "mousemove", p), Y(document, "mouseup", () => {
|
|
218
|
-
X(document, "mousemove", p);
|
|
219
|
-
}), n.preventDefault();
|
|
220
|
-
}, F = () => {
|
|
221
|
-
o.value = {
|
|
222
|
-
scale: 1,
|
|
223
|
-
deg: 0,
|
|
224
|
-
offsetX: 0,
|
|
225
|
-
offsetY: 0,
|
|
226
|
-
enableTransition: !1
|
|
227
|
-
};
|
|
228
|
-
}, M = () => {
|
|
229
|
-
if (f.value)
|
|
230
|
-
return;
|
|
231
|
-
const n = Object.keys(V), y = Object.values(V), t = O.value.name, c = (y.findIndex((m) => m.name === t) + 1) % n.length;
|
|
232
|
-
O.value = V[n[c]], F();
|
|
233
|
-
}, R = () => {
|
|
234
|
-
if (s.value && !e.infinite)
|
|
235
|
-
return;
|
|
236
|
-
const n = e.urlList.length;
|
|
237
|
-
h.value = (h.value - 1 + n) % n;
|
|
238
|
-
}, j = () => {
|
|
239
|
-
if (v.value && !e.infinite)
|
|
240
|
-
return;
|
|
241
|
-
const n = e.urlList.length;
|
|
242
|
-
h.value = (h.value + 1) % n;
|
|
243
|
-
}, C = (n, y = {}) => {
|
|
244
|
-
if (f.value)
|
|
245
|
-
return;
|
|
246
|
-
const {
|
|
247
|
-
zoomRate: t,
|
|
248
|
-
rotateDeg: r,
|
|
249
|
-
enableTransition: c
|
|
250
|
-
} = {
|
|
251
|
-
zoomRate: 0.2,
|
|
252
|
-
rotateDeg: 90,
|
|
253
|
-
enableTransition: !0,
|
|
254
|
-
...y
|
|
255
|
-
};
|
|
256
|
-
switch (n) {
|
|
257
|
-
case "zoomOut":
|
|
258
|
-
o.value.scale > 0.2 && (o.value.scale = parseFloat((o.value.scale - t).toFixed(3)));
|
|
259
|
-
break;
|
|
260
|
-
case "zoomIn":
|
|
261
|
-
o.value.scale = parseFloat((o.value.scale + t).toFixed(3));
|
|
262
|
-
break;
|
|
263
|
-
case "clocelise":
|
|
264
|
-
o.value.deg += r;
|
|
265
|
-
break;
|
|
266
|
-
case "anticlocelise":
|
|
267
|
-
o.value.deg -= r;
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
270
|
-
o.value.enableTransition = c;
|
|
271
|
-
};
|
|
272
|
-
return U(I, () => {
|
|
273
|
-
oe(() => {
|
|
274
|
-
x.value.complete || (f.value = !0);
|
|
275
|
-
});
|
|
276
|
-
}), U(h, (n) => {
|
|
277
|
-
F(), a("switch", n);
|
|
278
|
-
}), se(() => {
|
|
279
|
-
var n, y;
|
|
280
|
-
S(), (y = (n = k.value) == null ? void 0 : n.focus) == null || y.call(n);
|
|
281
|
-
}), () => l("div", {
|
|
282
|
-
ref: (n) => k.value = n,
|
|
283
|
-
tabindex: 1,
|
|
284
|
-
class: [`${i}-wrapper`, `${L.value}`],
|
|
285
|
-
style: {
|
|
286
|
-
zIndex: e.zIndex
|
|
287
|
-
}
|
|
288
|
-
}, [l("div", {
|
|
289
|
-
class: `${i}-mask`,
|
|
290
|
-
onClick: () => e.onHideOnClickModal && z()
|
|
291
|
-
}, null), l("span", {
|
|
292
|
-
class: [`${i}-btn`, `${i}-close`],
|
|
293
|
-
onClick: () => z()
|
|
294
|
-
}, [l(be, null, null)]), !u.value && l(re, null, [l("span", {
|
|
295
|
-
class: {
|
|
296
|
-
[`${i}-btn`]: !0,
|
|
297
|
-
[`${i}-prev`]: !0,
|
|
298
|
-
["is-disabled"]: !e.infinite && s.value
|
|
299
|
-
},
|
|
300
|
-
onClick: () => R()
|
|
301
|
-
}, [l(pe, null, null)]), l("span", {
|
|
302
|
-
class: {
|
|
303
|
-
[`${i}-btn`]: !0,
|
|
304
|
-
[`${i}-next`]: !0,
|
|
305
|
-
["is-disabled"]: !e.infinite && s.value
|
|
306
|
-
},
|
|
307
|
-
onClick: () => j()
|
|
308
|
-
}, [l(Oe, null, null)])]), l("div", {
|
|
309
|
-
class: [`${i}-btn`, `${i}-actions`]
|
|
310
|
-
}, [l("div", {
|
|
311
|
-
class: `${i}-actions-inner`
|
|
312
|
-
}, [l(Ce, {
|
|
313
|
-
onClick: () => C("zoomOut")
|
|
314
|
-
}, null), l(Ie, {
|
|
315
|
-
onClick: () => C("zoomIn")
|
|
316
|
-
}, null), l("i", {
|
|
317
|
-
class: `${i}-actions-divider`
|
|
318
|
-
}, null), l("i", {
|
|
319
|
-
onClick: () => M()
|
|
320
|
-
}, [O.value.icon]), l("i", {
|
|
321
|
-
class: `${i}-actions-divider`
|
|
322
|
-
}, null), l(ke, {
|
|
323
|
-
onClick: () => C("anticlocelise")
|
|
324
|
-
}, null), l(xe, {
|
|
325
|
-
onClick: () => C("clocelise")
|
|
326
|
-
}, null)])]), f.value && l("div", {
|
|
327
|
-
class: `${i}-canvas`
|
|
328
|
-
}, [l(ue("a-spin"), {
|
|
329
|
-
indicator: l(Le, {
|
|
330
|
-
style: {
|
|
331
|
-
color: "#fff",
|
|
332
|
-
fontSize: "40px"
|
|
333
|
-
}
|
|
334
|
-
}, null)
|
|
335
|
-
}, null)]), l("div", {
|
|
336
|
-
class: `${i}-canvas`
|
|
337
|
-
}, [e.urlList.map((n, y) => l("img", {
|
|
338
|
-
ref: (t) => x.value = t,
|
|
339
|
-
class: `${i}-img`,
|
|
340
|
-
key: n,
|
|
341
|
-
style: {
|
|
342
|
-
...A.value,
|
|
343
|
-
display: y === h.value ? "block" : "none"
|
|
344
|
-
},
|
|
345
|
-
src: n,
|
|
346
|
-
onLoad: () => E(),
|
|
347
|
-
onError: (t) => D(t),
|
|
348
|
-
onMousedown: (t) => H(t)
|
|
349
|
-
}, null))])]);
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
function Fe(e) {
|
|
353
|
-
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !me(e);
|
|
354
|
-
}
|
|
355
|
-
let le = "";
|
|
356
|
-
const Ge = /* @__PURE__ */ Z({
|
|
357
|
-
props: {
|
|
358
|
-
hideOnClickModal: P.hideOnClickModal
|
|
359
|
-
},
|
|
360
|
-
setup(e, {
|
|
361
|
-
slots: a
|
|
362
|
-
}) {
|
|
363
|
-
const d = K({
|
|
364
|
-
suffixCls: "image-viewer-group"
|
|
365
|
-
}), w = g(!1), p = g(""), i = b(() => {
|
|
366
|
-
var u, s, v, I, L;
|
|
367
|
-
return ((u = a.default) == null ? void 0 : u.call(a).length) === 1 && (String((s = a.default) == null ? void 0 : s.call(a)[0].type) === String(Symbol("Fragment")) || String((v = a.default) == null ? void 0 : v.call(a)[0].type) === String(Symbol())) ? ((I = a.default) == null ? void 0 : I.call(a)[0].children) || [] : ((L = a.default) == null ? void 0 : L.call(a)) || [];
|
|
368
|
-
}), f = b(() => i.value.filter((v) => k(v)).map((v) => v.props.src).filter((v) => v) || []), h = b(() => Array.isArray(f.value) && f.value.length > 0), k = (u) => u && u.type && (u.type.isGImage || u.type.name === "GImage"), x = () => {
|
|
369
|
-
let u = 0;
|
|
370
|
-
const s = f.value.findIndex((v) => v === p.value);
|
|
371
|
-
return s >= 0 && (u = s), u;
|
|
372
|
-
}, O = (u) => {
|
|
373
|
-
!h.value || !u || (p.value = u, le = document.body.style.overflow, document.body.style.overflow = "hidden", w.value = !0);
|
|
374
|
-
}, o = () => {
|
|
375
|
-
document.body.style.overflow = le, w.value = !1;
|
|
376
|
-
};
|
|
377
|
-
return () => {
|
|
378
|
-
let u;
|
|
379
|
-
return l("div", {
|
|
380
|
-
class: `${d}`
|
|
381
|
-
}, [l(ue("a-space"), {
|
|
382
|
-
size: 15
|
|
383
|
-
}, Fe(u = i.value.map((s, v) => k(s) ? l("div", {
|
|
384
|
-
key: v,
|
|
385
|
-
class: `${d}-item`,
|
|
386
|
-
onClick: () => {
|
|
387
|
-
var I;
|
|
388
|
-
return O(((I = s.props) == null ? void 0 : I.src) || "");
|
|
389
|
-
}
|
|
390
|
-
}, [ve(s, {
|
|
391
|
-
disablePreview: !0
|
|
392
|
-
})]) : null)) ? u : {
|
|
393
|
-
default: () => [u]
|
|
394
|
-
}), l(ce, {
|
|
395
|
-
to: "body"
|
|
396
|
-
}, {
|
|
397
|
-
default: () => [h.value && w.value && l(fe, {
|
|
398
|
-
initialIndex: x(),
|
|
399
|
-
urlList: f.value,
|
|
400
|
-
onHideOnClickModal: e.hideOnClickModal,
|
|
401
|
-
onClose: () => o()
|
|
402
|
-
}, null)]
|
|
403
|
-
})]);
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
}), Me = (e) => e && e.nodeType === Node.ELEMENT_NODE, ae = () => document.documentElement.style.objectFit !== void 0;
|
|
407
|
-
let ie = "";
|
|
408
|
-
const N = {
|
|
409
|
-
NONE: "none",
|
|
410
|
-
CONTAIN: "contain",
|
|
411
|
-
COVER: "cover",
|
|
412
|
-
FILL: "fill",
|
|
413
|
-
SCALE_DOWN: "scale-down"
|
|
414
|
-
}, G = /* @__PURE__ */ Z({
|
|
415
|
-
props: P,
|
|
416
|
-
name: "GImage",
|
|
417
|
-
inheritAttrs: !1,
|
|
418
|
-
emits: ["error", "click"],
|
|
419
|
-
setup(e, {
|
|
420
|
-
slots: a,
|
|
421
|
-
emit: d,
|
|
422
|
-
attrs: w
|
|
423
|
-
}) {
|
|
424
|
-
const p = K({
|
|
425
|
-
suffixCls: "image"
|
|
426
|
-
}), i = g(!1), f = g(!0), h = g(0), k = g(0), x = g(!1), O = g(null), o = g();
|
|
427
|
-
let u, s;
|
|
428
|
-
const v = b(() => ({
|
|
429
|
-
width: e.width ? `${e.width}px` : void 0,
|
|
430
|
-
height: e.height ? `${e.height}px` : void 0
|
|
431
|
-
})), I = b(() => {
|
|
432
|
-
const {
|
|
433
|
-
fit: t
|
|
434
|
-
} = e;
|
|
435
|
-
return !T && t ? ae() ? {
|
|
436
|
-
"object-fit": t,
|
|
437
|
-
...v.value
|
|
438
|
-
} : {
|
|
439
|
-
...W(t),
|
|
440
|
-
...v.value
|
|
441
|
-
} : v.value;
|
|
442
|
-
}), L = b(() => {
|
|
443
|
-
const {
|
|
444
|
-
fit: t
|
|
445
|
-
} = e;
|
|
446
|
-
return !T && !ae() && t !== N.FILL;
|
|
447
|
-
}), A = b(() => {
|
|
448
|
-
const {
|
|
449
|
-
previewSrcList: t
|
|
450
|
-
} = e;
|
|
451
|
-
return Array.isArray(t) && t.length > 0;
|
|
452
|
-
}), z = b(() => {
|
|
453
|
-
const {
|
|
454
|
-
src: t,
|
|
455
|
-
previewSrcList: r
|
|
456
|
-
} = e;
|
|
457
|
-
let c = 0;
|
|
458
|
-
const m = r.indexOf(t);
|
|
459
|
-
return m >= 0 && (c = m), c;
|
|
460
|
-
}), S = b(() => w), W = (t) => {
|
|
461
|
-
const r = e.width || h.value, c = e.height || k.value;
|
|
462
|
-
if (!O.value)
|
|
463
|
-
return {};
|
|
464
|
-
const {
|
|
465
|
-
clientWidth: m,
|
|
466
|
-
clientHeight: B
|
|
467
|
-
} = O.value;
|
|
468
|
-
if (!r || !c || !m || !B)
|
|
469
|
-
return {};
|
|
470
|
-
const J = r / c, Q = m / B;
|
|
471
|
-
switch (t === N.SCALE_DOWN && (t = r < m && c < B ? N.NONE : N.CONTAIN), t) {
|
|
472
|
-
case N.NONE:
|
|
473
|
-
return {
|
|
474
|
-
width: "auto",
|
|
475
|
-
height: "auto"
|
|
476
|
-
};
|
|
477
|
-
case N.CONTAIN:
|
|
478
|
-
return J < Q ? {
|
|
479
|
-
width: "auto"
|
|
480
|
-
} : {
|
|
481
|
-
height: "auto"
|
|
482
|
-
};
|
|
483
|
-
case N.COVER:
|
|
484
|
-
return J < Q ? {
|
|
485
|
-
height: "auto"
|
|
486
|
-
} : {
|
|
487
|
-
width: "auto"
|
|
488
|
-
};
|
|
489
|
-
default:
|
|
490
|
-
return {};
|
|
491
|
-
}
|
|
492
|
-
}, E = () => {
|
|
493
|
-
if (T)
|
|
494
|
-
return;
|
|
495
|
-
const t = S.value;
|
|
496
|
-
f.value = !0, i.value = !1;
|
|
497
|
-
const r = new Image();
|
|
498
|
-
r.onload = (c) => R(c, r), r.onerror = j, Object.keys(t).forEach((c) => {
|
|
499
|
-
if (c.toLowerCase() === "onload")
|
|
500
|
-
return;
|
|
501
|
-
const m = t[c];
|
|
502
|
-
r.setAttribute(c, m);
|
|
503
|
-
}), r.src = e.src;
|
|
504
|
-
};
|
|
505
|
-
function D() {
|
|
506
|
-
Se(O.value, o.value) && (E(), M());
|
|
507
|
-
}
|
|
508
|
-
const H = Ae(D, 200), F = async () => {
|
|
509
|
-
if (T)
|
|
510
|
-
return;
|
|
511
|
-
await oe();
|
|
512
|
-
const {
|
|
513
|
-
scrollContainer: t
|
|
514
|
-
} = e;
|
|
515
|
-
Me(t) ? o.value = t : Ne(t) && t !== "" ? o.value = document.querySelector(t) ?? void 0 : O.value && (o.value = $e(O.value)), o.value && (u = te(o, "scroll", H), setTimeout(() => D(), 200));
|
|
516
|
-
}, M = () => {
|
|
517
|
-
T || !o.value || !H || (u(), o.value = void 0);
|
|
518
|
-
}, R = (t, r) => {
|
|
519
|
-
h.value = r.width, k.value = r.height, f.value = !1, i.value = !1;
|
|
520
|
-
}, j = (t) => {
|
|
521
|
-
f.value = !1, i.value = !0, d("error", t);
|
|
522
|
-
}, C = (t) => {
|
|
523
|
-
if (t.ctrlKey) {
|
|
524
|
-
if (t.deltaY < 0)
|
|
525
|
-
return t.preventDefault(), !1;
|
|
526
|
-
if (t.deltaY > 0)
|
|
527
|
-
return t.preventDefault(), !1;
|
|
528
|
-
}
|
|
529
|
-
}, n = () => {
|
|
530
|
-
!A.value || e.disablePreview || (s = te("wheel", C, {
|
|
531
|
-
passive: !1
|
|
532
|
-
}), ie = document.body.style.overflow, document.body.style.overflow = "hidden", x.value = !0);
|
|
533
|
-
}, y = () => {
|
|
534
|
-
s == null || s(), document.body.style.overflow = ie, x.value = !1;
|
|
535
|
-
};
|
|
536
|
-
return U(() => e.src, () => {
|
|
537
|
-
e.lazy ? (f.value = !0, i.value = !1, M(), F()) : E();
|
|
538
|
-
}), se(() => {
|
|
539
|
-
e.lazy ? F() : E();
|
|
540
|
-
}), () => {
|
|
541
|
-
const t = ee(a, e, "fallback"), r = ee(a, e, "placeholder");
|
|
542
|
-
return l(re, null, [l("div", {
|
|
543
|
-
class: {
|
|
544
|
-
[`${p}`]: !0,
|
|
545
|
-
[`${S.value.class}`]: S.value.class
|
|
546
|
-
},
|
|
547
|
-
ref: (c) => O.value = c,
|
|
548
|
-
style: {
|
|
549
|
-
...S.value.style || {},
|
|
550
|
-
display: e.lazy ? "block" : void 0
|
|
551
|
-
},
|
|
552
|
-
onClick: () => {
|
|
553
|
-
d("click");
|
|
554
|
-
}
|
|
555
|
-
}, [f.value ? r || l("div", {
|
|
556
|
-
class: `${p}-placeholder`
|
|
557
|
-
}, null) : i.value ? t || l("div", {
|
|
558
|
-
class: `${p}-error`
|
|
559
|
-
}, [ge("加载失败")]) : l("img", he({
|
|
560
|
-
class: {
|
|
561
|
-
[`${p}-inner`]: !0,
|
|
562
|
-
[`${p}-inner-center`]: L.value,
|
|
563
|
-
[`${p}-preview`]: A.value
|
|
564
|
-
}
|
|
565
|
-
}, S.value, {
|
|
566
|
-
src: e.src,
|
|
567
|
-
style: I.value,
|
|
568
|
-
onClick: () => n()
|
|
569
|
-
}), null), l(ce, {
|
|
570
|
-
to: "body",
|
|
571
|
-
disabled: !e.appendToBody
|
|
572
|
-
}, {
|
|
573
|
-
default: () => [A.value && x.value && l(fe, {
|
|
574
|
-
zIndex: e.zIndex,
|
|
575
|
-
initialIndex: z.value,
|
|
576
|
-
urlList: e.previewSrcList,
|
|
577
|
-
onHideOnClickModal: e.hideOnClickModal,
|
|
578
|
-
onClose: () => y()
|
|
579
|
-
}, null)]
|
|
580
|
-
})])]);
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
});
|
|
584
|
-
G.isWImage = !0;
|
|
585
|
-
G.install = (e) => (e.component(G.name, G), e);
|
|
586
|
-
export {
|
|
587
|
-
G as GImage,
|
|
588
|
-
fe as ImageViewer,
|
|
589
|
-
Ge as ImageViewerGroup,
|
|
590
|
-
G as default
|
|
591
|
-
};
|