import{cd as s,E as o,ce as u,cf as d,aq as p,a3 as g,cg as l}from"./index.0308b213.js";s.configure({easing:"ease",speed:1e3,showSpinner:!0,trickleSpeed:100});const t={success:({code:e,show:r,msg:c,data:i})=>(e!==1&&o({type:"error",message:c}),i),error:({show:e,msg:r})=>(e*1&&o({type:"error",message:r}),Promise.reject(r)),redirect:u(()=>{const{clearLoginInfo:e}=g();return e(),l.push("/pawn/login"),Promise.reject()}),page:({data:e})=>(window.location.href=e.url,e)};var a="";a=window.location.protocol+"//"+window.location.host+"/";const n=d.create({baseURL:a,timeout:600*1e3,headers:{"Content-Type":"application/json",version:p}});n.interceptors.request.use(e=>{s.start();const r=sessionStorage.getItem("shangpu_tuniao_store_token")||"";return e.headers&&(e.headers.token=r),e},e=>Promise.reject(e));n.interceptors.response.use(e=>{switch(s.done(),e.data.code){case 1:return t.success(e.data);case 0:return t.error(e.data);case-1:return t.redirect();case 2:return t.page(e.data)}},e=>(console.log(e),s.done(),o({type:"error",message:e}),Promise.reject(e)));export{n as r};
