import{aJ as w,aK as E,b as x,a$ as U,aR as V,e as A,k as m,o as s,h as D,A as N,a as i,f as p,c as n,j as M,r as _,t as f,F as g,l as h,E as T,aL as y,_ as L}from"./index.4d3e3847.js";import{u as O}from"./hooks.428ba1c3.js";import{u as $}from"./useAsync.24db85a6.js";const{VITE_PROXY_DOMAIN_REAL:j}=E();async function q(a){return w.request("post",`${j}admin/upload`,{data:a})}const z={class:"flex justify-between"},H=["src"],P={key:1},X={class:"ml-2 text-[#8c939d]"},Y={key:0},J=x({__name:"image",props:{descs:null,types:null,size:{default:1},url:null,disabled:{type:Boolean}},emits:["change","update:url"],setup(a,{emit:v}){const l=a,{VITE_PROXY_DOMAIN_REAL:k}=E(),c=U(l,"url"),B=`${k}storage/`,F=V(),I=A(()=>{const{types:o}=l;return o.map(e=>"image/"+e)}),b=$(),C=({type:o,size:e})=>{if(!I.value.includes(o))return y.warning(`\u8BF7\u4E0A\u4F20${l.types.join(".")}\u7C7B\u578B\u7684\u56FE\u7247`),!1;if(e/1024/1024>l.size)return y.warning("\u56FE\u7247\u5927\u5C0F\u8D85\u8FC7"+l.size+"M"),!1},R=async({file:o})=>{const e=new FormData;e.append("image",o),e.append("token",F);const{message:r,code:d,data:u}=await q(e),t=B+u[0].url;b({message:r,code:d,handler:()=>{c.value=t,v("change",t)}})};return(o,e)=>{const r=m("ElButton"),d=m("ElUpload");return s(),D(d,{class:"avatar-uploader","http-request":R,"before-upload":C,"show-file-list":!1,disabled:a.disabled},{default:N(()=>[i("div",z,[p(c)?(s(),n("img",{key:0,class:"avatar",src:p(c)},null,8,H)):(s(),n("div",P,[M(r,{class:"avatar-uploader-icon",icon:p(O)("plus")},null,8,["icon"])])),i("div",X,[(s(!0),n(g,null,_(a.descs,(u,t)=>(s(),n("p",{key:t},f(u),1))),128)),i("p",null,[h(" \u683C\u5F0F : "),(s(!0),n(g,null,_(a.types,(u,t)=>(s(),n("span",{key:t},[h(f(u)+" ",1),t!==a.types.length-1?(s(),n("i",Y,",")):T("",!0)]))),128))])])])]),_:1},8,["disabled"])}}});const Q=L(J,[["__scopeId","data-v-527467f2"]]);export{Q as I,q as h};
