|
|
-import{z as o,d as a,x as r,y as e,b as l,W as s,aC as i,w as n,ao as t,aq as d,o as c,M as u,c as v,I as g,E as f,a2 as h,S as m,b8 as p,R as b,a0 as w,G as y}from"./index-0af571ca.js";const[z,S]=o("image"),x=y(a({name:z,props:{src:String,alt:String,fit:String,position:String,round:Boolean,block:Boolean,width:g,height:g,radius:g,lazyLoad:Boolean,iconSize:g,showError:f,errorIcon:h("photo-fail"),iconPrefix:String,showLoading:f,loadingIcon:h("photo")},emits:["load","error"],setup(o,{emit:a,slots:g}){const f=r(!1),h=r(!0),y=r(),{$Lazyload:z}=e().proxy,x=l((()=>{const a={width:s(o.width),height:s(o.height)};return i(o.radius)&&(a.overflow="hidden",a.borderRadius=s(o.radius)),a}));n((()=>o.src),(()=>{f.value=!1,h.value=!0}));const L=o=>{h.value&&(h.value=!1,a("load",o))},I=()=>{const o=new Event("load");Object.defineProperty(o,"target",{value:y.value,enumerable:!0}),L(o)},E=o=>{f.value=!0,h.value=!1,a("error",o)},P=(a,r,e)=>e?e():v(w,{name:a,size:o.iconSize,"class":r,classPrefix:o.iconPrefix},null),$=()=>{if(f.value||!o.src)return;const a={alt:o.alt,"class":S("img"),style:{objectFit:o.fit,objectPosition:o.position}};return o.lazyLoad?m(v("img",b({ref:y},a),null),[[p("lazy"),o.src]]):v("img",b({ref:y,src:o.src,onLoad:L,onError:E},a),null)},j=({el:o})=>{const a=()=>{o===y.value&&h.value&&I()};y.value?a():u(a)},k=({el:o})=>{o!==y.value||f.value||E()};return z&&t&&(z.$on("loaded",j),z.$on("error",k),d((()=>{z.$off("loaded",j),z.$off("error",k)}))),c((()=>{u((()=>{var a;(null==(a=y.value)?void 0:a.complete)&&!o.lazyLoad&&I()}))})),()=>{var a;return v("div",{"class":S({round:o.round,block:o.block}),style:x.value},[$(),h.value&&o.showLoading?v("div",{"class":S("loading")},[P(o.loadingIcon,S("loading-icon"),g.loading)]):f.value&&o.showError?v("div",{"class":S("error")},[P(o.errorIcon,S("error-icon"),g.error)]):void 0,null==(a=g["default"])?void 0:a.call(g)])}}}));export{x as I};
|
|
|
+import{z as o,d as a,x as r,y as e,b as l,W as s,aC as i,w as n,ao as t,aq as d,o as c,M as u,c as v,I as g,E as f,a2 as h,S as m,b8 as p,R as b,a0 as w,G as y}from"./index-7bdeb505.js";const[z,S]=o("image"),x=y(a({name:z,props:{src:String,alt:String,fit:String,position:String,round:Boolean,block:Boolean,width:g,height:g,radius:g,lazyLoad:Boolean,iconSize:g,showError:f,errorIcon:h("photo-fail"),iconPrefix:String,showLoading:f,loadingIcon:h("photo")},emits:["load","error"],setup(o,{emit:a,slots:g}){const f=r(!1),h=r(!0),y=r(),{$Lazyload:z}=e().proxy,x=l((()=>{const a={width:s(o.width),height:s(o.height)};return i(o.radius)&&(a.overflow="hidden",a.borderRadius=s(o.radius)),a}));n((()=>o.src),(()=>{f.value=!1,h.value=!0}));const L=o=>{h.value&&(h.value=!1,a("load",o))},I=()=>{const o=new Event("load");Object.defineProperty(o,"target",{value:y.value,enumerable:!0}),L(o)},E=o=>{f.value=!0,h.value=!1,a("error",o)},P=(a,r,e)=>e?e():v(w,{name:a,size:o.iconSize,"class":r,classPrefix:o.iconPrefix},null),$=()=>{if(f.value||!o.src)return;const a={alt:o.alt,"class":S("img"),style:{objectFit:o.fit,objectPosition:o.position}};return o.lazyLoad?m(v("img",b({ref:y},a),null),[[p("lazy"),o.src]]):v("img",b({ref:y,src:o.src,onLoad:L,onError:E},a),null)},j=({el:o})=>{const a=()=>{o===y.value&&h.value&&I()};y.value?a():u(a)},k=({el:o})=>{o!==y.value||f.value||E()};return z&&t&&(z.$on("loaded",j),z.$on("error",k),d((()=>{z.$off("loaded",j),z.$off("error",k)}))),c((()=>{u((()=>{var a;(null==(a=y.value)?void 0:a.complete)&&!o.lazyLoad&&I()}))})),()=>{var a;return v("div",{"class":S({round:o.round,block:o.block}),style:x.value},[$(),h.value&&o.showLoading?v("div",{"class":S("loading")},[P(o.loadingIcon,S("loading-icon"),g.loading)]):f.value&&o.showError?v("div",{"class":S("error")},[P(o.errorIcon,S("error-icon"),g.error)]):void 0,null==(a=g["default"])?void 0:a.call(g)])}}}));export{x as I};
|