UNPKG

@pit-front-end/utils

Version:

湖南创智艾泰克科技有限公司

2 lines (1 loc) 1.35 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("qs"),q=require("axios"),i=require("./define.js"),u=require("vue");let l={baseURL:i.DEFINE_BASE_URL,timeout:i.DEFINE_TIME,withCredentials:!1,headers:{Accept:"application/json, text/plain, */*","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},paramsSerializer:e=>p.stringify(e,{indices:!1,arrayFormat:"repeat"})};const w=()=>{l={baseURL:i.DEFINE_BASE_URL,timeout:i.DEFINE_TIME,withCredentials:!1,headers:{Accept:"application/json, text/plain, */*","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},paramsSerializer:e=>p.stringify(e,{indices:!1,arrayFormat:"repeat"})}};class r{constructor(){this.axiosInstance=q.create(l),this.httpInterceptorsRequest()}httpInterceptorsRequest(){var n;(n=this.axiosInstance)==null||n.interceptors.request.use(t=>(window.setConfigCallback&&(t=window.setConfigCallback(t)),t))}request(n){return new Promise((t,d)=>{var c;(c=this.axiosInstance)==null||c.request(n).then(a=>{const o=window.requestThen(a);t(o)}).catch(a=>{const o=window.requestCatch(a);d(o)})})}}let s=null;exports.http=u.reactive(null);const f=()=>s?{}:(w(),s=new r,exports.http=new r,s),h=u.computed(()=>s),E=h.value,R=new r,C=f;exports.Service=r;exports.http2=h;exports.http3=E;exports.http4=R;exports.initRequest=C;