var e=Object.defineProperty,t=(t,s,r)=>(((t,s,r)=>{s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r})(t,"symbol"!=typeof s?s+"":s,r),r);import{aG as s,aH as r,aI as i,M as o,aJ as a,aK as h,q as n,aC as u}from"./index-2b50ecca.js";/* empty css             *//* empty css                  *//* empty css                 *//* empty css                   */const c=new class{constructor(){t(this,"config",{}),t(this,"baseURL",""),t(this,"timeout",0),t(this,"headers",{}),t(this,"request"),this.request=s.create(this.getConfig())}get(e,t={}){return this.request.get(this.baseURL+e,{params:t})}post(e,t={}){return this.request.post(this.baseURL+e,t)}put(e,t={}){return this.request.put(this.baseURL+e,t)}delete(e){return this.request.delete(this.baseURL+e)}setTimeout(e){return this.timeout=e,this}setBaseUrl(e){return this.baseURL=e,this}setHeader(e,t){return this.headers.key=t,this}getConfig(){return this.config.baseURL=this.baseURL?this.baseURL:r("VITE_BASE_URL"),this.config.timeout=this.timeout?this.timeout:6e4,this.headers["X-Requested-With"]="XMLHttpRequest",this.headers["Request-from"]="Dashboard",this.config.headers=this.headers,this.config}interceptorsOfRequest(){this.request.interceptors.request.use((function(e){const t=i();return t&&(e.headers||(e.headers={}),e.headers.authorization="Bearer "+t),e}))}interceptorsOfResponse(){this.request.interceptors.response.use((e=>{const t=e.data,s=t.code,r=t.message;return 1e4===s?t:(10004===s?o.error(r||"Error"):s===a.LOST_LOGIN||s===a.LOGIN_EXPIRED?o.confirm(r+"，需要重新登陆",(function(){h(),n.push("/login")})):s===a.LOGIN_BLACKLIST||s===a.USER_FORBIDDEN?(o.error(r||"Error"),h(),n.push("/login")):-2333===s?u.alert(`上传失败，《${r}》文件名已存在，请修改后重新上传`):o.error(r||"Error"),Promise.reject(new Error(r||"Error")))}),(e=>(o.error(e.message),Promise.reject(e))))}};c.interceptorsOfRequest(),c.interceptorsOfResponse();export{c as h};
