1 |
- import{t as x,z as d,v as L,u as z,d as E,R as u,a9 as B,y as $,U as f,a1 as D,Z as R,aa as U,ab as _,c as r,ac as j,ad as C,E as P,_ as N,a5 as F,D as T}from"./index.332c7f08.js";const[V,o]=x("image"),Z={src:String,alt:String,fit:String,position:String,round:Boolean,block:Boolean,width:d,height:d,radius:d,lazyLoad:Boolean,iconSize:d,showError:L,errorIcon:z("photo-fail"),iconPrefix:String,showLoading:L,loadingIcon:z("photo")};var q=E({name:V,props:Z,emits:["load","error"],setup(e,{emit:g,slots:l}){const n=u(!1),t=u(!0),s=u(),{$Lazyload:i}=B().proxy,b=$(()=>{const a={width:f(e.width),height:f(e.height)};return D(e.radius)&&(a.overflow="hidden",a.borderRadius=f(e.radius)),a});R(()=>e.src,()=>{n.value=!1,t.value=!0});const v=a=>{t.value=!1,g("load",a)},h=a=>{n.value=!0,t.value=!1,g("error",a)},m=(a,c,I)=>I?I():r(F,{name:a,size:e.iconSize,class:c,classPrefix:e.iconPrefix},null),S=()=>{if(t.value&&e.showLoading)return r("div",{class:o("loading")},[m(e.loadingIcon,o("loading-icon"),l.loading)]);if(n.value&&e.showError)return r("div",{class:o("error")},[m(e.errorIcon,o("error-icon"),l.error)])},k=()=>{if(n.value||!e.src)return;const a={alt:e.alt,class:o("img"),style:{objectFit:e.fit,objectPosition:e.position}};return e.lazyLoad?j(r("img",P({ref:s},a),null),[[C("lazy"),e.src]]):r("img",P({src:e.src,onLoad:v,onError:h},a),null)},w=({el:a})=>{const c=()=>{a===s.value&&t.value&&v()};s.value?c():N(c)},y=({el:a})=>{a===s.value&&!n.value&&h()};return i&&U&&(i.$on("loaded",w),i.$on("error",y),_(()=>{i.$off("loaded",w),i.$off("error",y)})),()=>{var a;return r("div",{class:o({round:e.round,block:e.block}),style:b.value},[k(),S(),(a=l.default)==null?void 0:a.call(l)])}}});const G=T(q);export{G as I};
|