import{O as a,P as e,Q as t,R as o,k as s,S as l,U as n,V as r,W as c,X as i,I as d,Y as u,a as m}from"./index-z4UiUMlV.js";let f;let p=a({},{title:"",width:"",theme:null,message:"",overlay:!0,callback:null,teleport:"body",className:"",allowHtml:!1,lockScroll:!0,transition:void 0,beforeClose:null,overlayClass:"",overlayStyle:void 0,messageAlign:"",cancelButtonText:"",cancelButtonColor:null,cancelButtonDisabled:!1,confirmButtonText:"",confirmButtonColor:null,confirmButtonDisabled:!1,showConfirmButton:!0,showCancelButton:!1,closeOnPopstate:!0,closeOnClickOverlay:!1});function h(r){return e?new Promise(((e,c)=>{f||function(){const a={setup(){const{state:a,toggle:e}=o();return()=>s(n,l(a,{"onUpdate:show":e}),null)}};({instance:f}=t(a))}(),f.open(a({},p,r,{callback:a=>{("confirm"===a?e:c)(a)}}))})):Promise.resolve(void 0)}const g=e=>h(a({showCancelButton:!0},e)),b="/api",v="",B="/mes",w="/mes";function C(a,e,t={},o={}){return new Promise(((s,l)=>{const n=r("token"),f={"Content-Type":"application/json;charset=UTF-8",Authorization:"Bearer "+n},p=Object.assign({},f,o);let g="";g=a.includes("/v1")?v:"/fabric/info/all"===a||"/color/list"===a||a.includes("/fabric/info/craftPrice")?B:a.includes("fabric/craft")?w:b,"/upload"===a?c({url:g+a,file:t,header:{Authorization:"Bearer "+n},success:a=>{let e=JSON.parse(a.data);s(e)}}):i({url:g+a,method:e,data:t,header:p,success:a=>{var e;a.data&&200===a.data.code?s(a.data):a.data&&401===a.data.code?(d({icon:"error",title:"登录过期！"}),u(),m({url:"/pages/login/login"}),l(new Error("请求失败: "+(a.data&&(null==(e=a.data)?void 0:e.message)||"未知错误")))):a.data&&401===a.data.code?d({icon:"error",title:"暂无权限！"}):7778===a.data.code||7777===a.data.code?s(a.data):h({title:a.data.msg}).then((()=>{}))},fail:a=>{l(a)}})}))}const P=(a,e={},t={})=>C(a,"POST",e,t),T=(a,e={},t={})=>C(a,"GET",e,t),y=(a,e={},t={})=>C(a,"PUT",e,t),O=(a,e={},t={})=>C(a,"DELETE",e,t),k=(a,e={})=>C(a,"",e);export{y as a,h as b,O as d,T as g,P as p,g as s,k as u};
