版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

useAxios.iife.min.js 3.4 KiB

пре 1 година
1
  1. var VueDemi=function(e,n,h){if(e.install)return e;if(!n)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),e;if(n.version.slice(0,4)==="2.7."){let s=function(c,u){var f,O={},w={config:n.config,use:n.use.bind(n),mixin:n.mixin.bind(n),component:n.component.bind(n),provide:function(a,d){return O[a]=d,this},directive:function(a,d){return d?(n.directive(a,d),w):n.directive(a)},mount:function(a,d){return f||(f=new n(Object.assign({propsData:u},c,{provide:Object.assign(O,c.provide)})),f.$mount(a,d),f)},unmount:function(){f&&(f.$destroy(),f=void 0)}};return w};var q=s;for(var l in n)e[l]=n[l];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=n,e.Vue2=n,e.version=n.version,e.warn=n.util.warn,e.createApp=s}else if(n.version.slice(0,2)==="2.")if(h){for(var l in h)e[l]=h[l];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=n,e.Vue2=n,e.version=n.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(n.version.slice(0,2)==="3."){for(var l in n)e[l]=n[l];e.isVue2=!1,e.isVue3=!0,e.install=function(){},e.Vue=n,e.Vue2=void 0,e.version=n.version,e.set=function(s,c,u){return Array.isArray(s)?(s.length=Math.max(s.length,c),s.splice(c,1,u),u):(s[c]=u,u)},e.del=function(s,c){if(Array.isArray(s)){s.splice(c,1);return}delete s[c]}}else console.error("[vue-demi] Vue version "+n.version+" is unsupported.");return e}(this.VueDemi=this.VueDemi||(typeof VueDemi!="undefined"?VueDemi:{}),this.Vue||(typeof Vue!="undefined"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI!="undefined"?VueCompositionAPI:void 0));(function(e,n,h,l){"use strict";var q=Object.defineProperty,s=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,w=(r,t,o)=>t in r?q(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o,a=(r,t)=>{for(var o in t||(t={}))f.call(t,o)&&w(r,o,t[o]);if(u)for(var o of u(t))O.call(t,o)&&w(r,o,t[o]);return r},d=(r,t)=>s(r,c(t));function B(...r){const t=typeof r[0]=="string"?r[0]:void 0,o=h.isString(t)?1:0;let C={},I=l,v={immediate:!!o,shallow:!0};const E=i=>!!(i==null?void 0:i.request);r.length>0+o&&(E(r[0+o])?I=r[0+o]:C=r[0+o]),r.length>1+o&&E(r[1+o])&&(I=r[1+o]),(r.length===2+o&&!E(r[1+o])||r.length===3+o)&&(v=r[r.length-1]);const T=n.shallowRef(),g=v.shallow?n.shallowRef():n.ref(),p=n.ref(!1),b=n.ref(!1),y=n.ref(!1),j=n.shallowRef(),L=l.CancelToken.source;let R=L();const S=i=>{p.value||!b.value||(R.cancel(i),R=L(),y.value=!0,b.value=!1,p.value=!1)},F=i=>{b.value=i,p.value=!i},M=()=>new Promise((i,_)=>{h.until(p).toBe(!0).then(()=>i(U)).catch(_)}),x=(i,_)=>M().then(i,_),N=(i=t,_={})=>{j.value=void 0;const $=typeof i=="string"?i:t??_.url;return $===void 0?(j.value=new l.AxiosError(l.AxiosError.ERR_INVALID_URL),p.value=!0,{then:x}):(S(),F(!0),I($,d(a(a({},C),typeof i=="object"?i:_),{cancelToken:R.token})).then(P=>{var A;T.value=P;const k=P.data;g.value=k,(A=v.onSuccess)==null||A.call(v,k)}).catch(P=>{var A;j.value=P,(A=v.onError)==null||A.call(v,P)}).finally(()=>F(!1)),{then:x})};v.immediate&&t&&N();const U={response:T,data:g,error:j,finished:p,loading:b,isFinished:p,isLoading:b,cancel:S,isAborted:y,canceled:y,aborted:y,isCanceled:y,abort:S,execute:N};return d(a({},U),{then:x})}e.useAxios=B})(this.VueUse=this.VueUse||{},VueDemi,VueUse,axios);