@vueuse/integrations 7.5.4 → 7.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +25 -13
- package/index.d.ts +16 -4
- package/index.iife.js +25 -13
- package/index.iife.min.js +1 -1
- package/index.mjs +25 -13
- package/package.json +50 -19
- package/useAxios.cjs +25 -13
- package/useAxios.d.ts +16 -4
- package/useAxios.iife.js +25 -13
- package/useAxios.iife.min.js +1 -1
- package/useAxios.mjs +25 -13
package/index.cjs
CHANGED
|
@@ -43,22 +43,25 @@ var __spreadValues$3 = (a, b) => {
|
|
|
43
43
|
};
|
|
44
44
|
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
45
45
|
function useAxios(url, ...args) {
|
|
46
|
-
let
|
|
46
|
+
let defaultConfig = {};
|
|
47
47
|
let instance = axios__default["default"];
|
|
48
|
+
let options = { immediate: true };
|
|
48
49
|
if (args.length > 0) {
|
|
49
50
|
if ("request" in args[0])
|
|
50
51
|
instance = args[0];
|
|
51
52
|
else
|
|
52
|
-
|
|
53
|
+
defaultConfig = args[0];
|
|
53
54
|
}
|
|
54
55
|
if (args.length > 1) {
|
|
55
56
|
if ("request" in args[1])
|
|
56
57
|
instance = args[1];
|
|
57
58
|
}
|
|
59
|
+
if (args.length >= 2)
|
|
60
|
+
options = args[args.length - 1];
|
|
58
61
|
const response = vueDemi.shallowRef();
|
|
59
62
|
const data = vueDemi.shallowRef();
|
|
60
63
|
const isFinished = vueDemi.ref(false);
|
|
61
|
-
const isLoading = vueDemi.ref(
|
|
64
|
+
const isLoading = vueDemi.ref(false);
|
|
62
65
|
const aborted = vueDemi.ref(false);
|
|
63
66
|
const error = vueDemi.shallowRef();
|
|
64
67
|
const cancelToken = axios__default["default"].CancelToken.source();
|
|
@@ -70,15 +73,23 @@ function useAxios(url, ...args) {
|
|
|
70
73
|
isLoading.value = false;
|
|
71
74
|
isFinished.value = false;
|
|
72
75
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
const loading = (loading2) => {
|
|
77
|
+
isLoading.value = loading2;
|
|
78
|
+
isFinished.value = !loading2;
|
|
79
|
+
};
|
|
80
|
+
const execute = (config = {}) => {
|
|
81
|
+
loading(true);
|
|
82
|
+
instance(url, __spreadProps$1(__spreadValues$3(__spreadValues$3({}, defaultConfig), config), { cancelToken: cancelToken.token })).then((r) => {
|
|
83
|
+
response.value = r;
|
|
84
|
+
data.value = r.data;
|
|
85
|
+
}).catch((e) => {
|
|
86
|
+
error.value = e;
|
|
87
|
+
}).finally(() => {
|
|
88
|
+
loading(false);
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
if (options.immediate)
|
|
92
|
+
execute();
|
|
82
93
|
return {
|
|
83
94
|
response,
|
|
84
95
|
data,
|
|
@@ -90,7 +101,8 @@ function useAxios(url, ...args) {
|
|
|
90
101
|
cancel: abort,
|
|
91
102
|
canceled: aborted,
|
|
92
103
|
aborted,
|
|
93
|
-
abort
|
|
104
|
+
abort,
|
|
105
|
+
execute
|
|
94
106
|
};
|
|
95
107
|
}
|
|
96
108
|
|
package/index.d.ts
CHANGED
|
@@ -42,10 +42,22 @@ interface UseAxiosReturn<T> {
|
|
|
42
42
|
* Aborts the current request
|
|
43
43
|
*/
|
|
44
44
|
abort: (message?: string | undefined) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Manually call the axios request
|
|
47
|
+
*/
|
|
48
|
+
execute: (config?: AxiosRequestConfig) => void;
|
|
49
|
+
}
|
|
50
|
+
interface UseAxiosOptions {
|
|
51
|
+
/**
|
|
52
|
+
* Will automatically run axios request when `useAxios` is used
|
|
53
|
+
*
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
56
|
+
immediate?: boolean;
|
|
45
57
|
}
|
|
46
|
-
declare function useAxios<T = any>(url: string, config?: AxiosRequestConfig): UseAxiosReturn<T>;
|
|
47
|
-
declare function useAxios<T = any>(url: string, instance?: AxiosInstance): UseAxiosReturn<T>;
|
|
48
|
-
declare function useAxios<T = any>(url: string, config: AxiosRequestConfig, instance: AxiosInstance): UseAxiosReturn<T>;
|
|
58
|
+
declare function useAxios<T = any>(url: string, config?: AxiosRequestConfig, options?: UseAxiosOptions): UseAxiosReturn<T>;
|
|
59
|
+
declare function useAxios<T = any>(url: string, instance?: AxiosInstance, options?: UseAxiosOptions): UseAxiosReturn<T>;
|
|
60
|
+
declare function useAxios<T = any>(url: string, config: AxiosRequestConfig, instance: AxiosInstance, options?: UseAxiosOptions): UseAxiosReturn<T>;
|
|
49
61
|
|
|
50
62
|
/**
|
|
51
63
|
* Creates a new {@link useCookies} function
|
|
@@ -234,4 +246,4 @@ declare function useNProgress(currentProgress?: MaybeRef<number | null | undefin
|
|
|
234
246
|
*/
|
|
235
247
|
declare function useQRCode(text: MaybeRef<string>, options?: QRCode.QRCodeToDataURLOptions): vue_demi.Ref<string>;
|
|
236
248
|
|
|
237
|
-
export { FuseOptions, JwtOptions, JwtResult, UseAxiosReturn, UseDrauuOptions, UseDrauuReturn, UseFocusTrapOptions, UseFocusTrapReturn, UseFuseOptions, UseFuseReturn, createCookies, useAxios, useCookies, useDrauu, useFocusTrap, useFuse, useJwt, useNProgress, useQRCode };
|
|
249
|
+
export { FuseOptions, JwtOptions, JwtResult, UseAxiosOptions, UseAxiosReturn, UseDrauuOptions, UseDrauuReturn, UseFocusTrapOptions, UseFocusTrapReturn, UseFuseOptions, UseFuseReturn, createCookies, useAxios, useCookies, useDrauu, useFocusTrap, useFuse, useJwt, useNProgress, useQRCode };
|
package/index.iife.js
CHANGED
|
@@ -91,22 +91,25 @@
|
|
|
91
91
|
};
|
|
92
92
|
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
93
93
|
function useAxios(url, ...args) {
|
|
94
|
-
let
|
|
94
|
+
let defaultConfig = {};
|
|
95
95
|
let instance = axios__default["default"];
|
|
96
|
+
let options = { immediate: true };
|
|
96
97
|
if (args.length > 0) {
|
|
97
98
|
if ("request" in args[0])
|
|
98
99
|
instance = args[0];
|
|
99
100
|
else
|
|
100
|
-
|
|
101
|
+
defaultConfig = args[0];
|
|
101
102
|
}
|
|
102
103
|
if (args.length > 1) {
|
|
103
104
|
if ("request" in args[1])
|
|
104
105
|
instance = args[1];
|
|
105
106
|
}
|
|
107
|
+
if (args.length >= 2)
|
|
108
|
+
options = args[args.length - 1];
|
|
106
109
|
const response = vueDemi.shallowRef();
|
|
107
110
|
const data = vueDemi.shallowRef();
|
|
108
111
|
const isFinished = vueDemi.ref(false);
|
|
109
|
-
const isLoading = vueDemi.ref(
|
|
112
|
+
const isLoading = vueDemi.ref(false);
|
|
110
113
|
const aborted = vueDemi.ref(false);
|
|
111
114
|
const error = vueDemi.shallowRef();
|
|
112
115
|
const cancelToken = axios__default["default"].CancelToken.source();
|
|
@@ -118,15 +121,23 @@
|
|
|
118
121
|
isLoading.value = false;
|
|
119
122
|
isFinished.value = false;
|
|
120
123
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
const loading = (loading2) => {
|
|
125
|
+
isLoading.value = loading2;
|
|
126
|
+
isFinished.value = !loading2;
|
|
127
|
+
};
|
|
128
|
+
const execute = (config = {}) => {
|
|
129
|
+
loading(true);
|
|
130
|
+
instance(url, __spreadProps$1(__spreadValues$3(__spreadValues$3({}, defaultConfig), config), { cancelToken: cancelToken.token })).then((r) => {
|
|
131
|
+
response.value = r;
|
|
132
|
+
data.value = r.data;
|
|
133
|
+
}).catch((e) => {
|
|
134
|
+
error.value = e;
|
|
135
|
+
}).finally(() => {
|
|
136
|
+
loading(false);
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
if (options.immediate)
|
|
140
|
+
execute();
|
|
130
141
|
return {
|
|
131
142
|
response,
|
|
132
143
|
data,
|
|
@@ -138,7 +149,8 @@
|
|
|
138
149
|
cancel: abort,
|
|
139
150
|
canceled: aborted,
|
|
140
151
|
aborted,
|
|
141
|
-
abort
|
|
152
|
+
abort,
|
|
153
|
+
execute
|
|
142
154
|
};
|
|
143
155
|
}
|
|
144
156
|
|
package/index.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(d){if(!d.VueDemi){var n={},
|
|
1
|
+
(function(d){if(!d.VueDemi){var n={},p=d.Vue;if(p)if(p.version.slice(0,2)==="2."){var g=d.VueCompositionAPI;if(g){for(var m in g)n[m]=g[m];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=p,n.Vue2=p,n.version=p.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.")}else if(p.version.slice(0,2)==="3."){for(var m in p)n[m]=p[m];n.isVue2=!1,n.isVue3=!0,n.install=function(){},n.Vue=p,n.Vue2=void 0,n.version=p.version,n.set=function(h,v,b){return Array.isArray(h)?(h.length=Math.max(h.length,v),h.splice(v,1,b),b):(h[v]=b,b)},n.del=function(h,v){if(Array.isArray(h)){h.splice(v,1);return}delete h[v]}}else console.error("[vue-demi] Vue version "+p.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");d.VueDemi=n}})(window),function(d,n,p,g,m,h,v,b,z,B,K,X){"use strict";function C(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var A=C(p),R=C(m),Y=C(z),Z=C(B),O=C(K),x=C(X),D=Object.defineProperty,ee=Object.defineProperties,re=Object.getOwnPropertyDescriptors,F=Object.getOwnPropertySymbols,te=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable,L=(t,r,e)=>r in t?D(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,H=(t,r)=>{for(var e in r||(r={}))te.call(r,e)&&L(t,e,r[e]);if(F)for(var e of F(r))ne.call(r,e)&&L(t,e,r[e]);return t},ae=(t,r)=>ee(t,re(r));function oe(t,...r){let e={},a=A.default,s={immediate:!0};r.length>0&&("request"in r[0]?a=r[0]:e=r[0]),r.length>1&&"request"in r[1]&&(a=r[1]),r.length>=2&&(s=r[r.length-1]);const f=n.shallowRef(),i=n.shallowRef(),l=n.ref(!1),o=n.ref(!1),c=n.ref(!1),_=n.shallowRef(),w=A.default.CancelToken.source(),P=y=>{l.value||!o.value||(w.cancel(y),c.value=!0,o.value=!1,l.value=!1)},V=y=>{o.value=y,l.value=!y},S=(y={})=>{V(!0),a(t,ae(H(H({},e),y),{cancelToken:w.token})).then(E=>{f.value=E,i.value=E.data}).catch(E=>{_.value=E}).finally(()=>{V(!1)})};return s.immediate&&S(),{response:f,data:i,error:_,finished:l,loading:o,isFinished:l,isLoading:o,cancel:P,canceled:c,aborted:c,abort:P,execute:S}}var le=Object.defineProperty,I=Object.getOwnPropertySymbols,ue=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,N=(t,r,e)=>r in t?le(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,T=(t,r)=>{for(var e in r||(r={}))ue.call(r,e)&&N(t,e,r[e]);if(I)for(var e of I(r))se.call(r,e)&&N(t,e,r[e]);return t};function fe(t){const r=new R.default(t?t.headers.cookie:null);return(e,{doNotParse:a=!1,autoUpdateDependencies:s=!1}={})=>U(e,{doNotParse:a,autoUpdateDependencies:s},r)}function U(t,{doNotParse:r=!1,autoUpdateDependencies:e=!1}={},a=new R.default){const s=e?[...t||[]]:t;let f=a.getAll({doNotParse:!0});const i=n.ref(0),l=()=>{const o=a.getAll({doNotParse:!0});ce(s||null,o,f)&&i.value++,f=o};return a.addChangeListener(l),g.tryOnScopeDispose(()=>{a.removeChangeListener(l)}),{get:(...o)=>(e&&s&&!s.includes(o[0])&&s.push(o[0]),i.value,a.get(o[0],T({doNotParse:r},o[1]))),getAll:(...o)=>(i.value,a.getAll(T({doNotParse:r},o[0]))),set:(...o)=>a.set(...o),remove:(...o)=>a.remove(...o),addChangeListener:(...o)=>a.addChangeListener(...o),removeChangeListener:(...o)=>a.removeChangeListener(...o)}}function ce(t,r,e){if(!t)return!0;for(const a of t)if(r[a]!==e[a])return!0;return!1}var ie=Object.defineProperty,k=Object.getOwnPropertySymbols,de=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable,G=(t,r,e)=>r in t?ie(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,pe=(t,r)=>{for(var e in r||(r={}))de.call(r,e)&&G(t,e,r[e]);if(k)for(var e of k(r))ve.call(r,e)&&G(t,e,r[e]);return t};function _e(t,r){const e=n.ref();let a=[];const s=v.createEventHook(),f=v.createEventHook(),i=v.createEventHook(),l=v.createEventHook(),o=v.createEventHook(),c=n.ref(!1),_=n.ref(!1),w=n.ref(!1),P=n.ref(!1),V=n.ref({color:"black",size:3,arrowEnd:!1,cornerRadius:0,dasharray:void 0,fill:"transparent",mode:"draw"});n.watch(V,()=>{const u=e.value;u&&(u.brush=V.value)},{deep:!0});const S=()=>{var u;return(u=e.value)==null?void 0:u.undo()},y=()=>{var u;return(u=e.value)==null?void 0:u.redo()},E=()=>{var u;return(u=e.value)==null?void 0:u.clear()},$e=()=>{var u;return(u=e.value)==null?void 0:u.cancel()},Se=u=>{var j;return(j=e.value)==null?void 0:j.load(u)},je=()=>{var u;return(u=e.value)==null?void 0:u.dump()},W=()=>{var u;a.forEach(j=>j()),(u=e.value)==null||u.unmount()},q=()=>{e.value&&(c.value=e.value.canUndo(),_.value=e.value.canRedo(),w.value=e.value.altPressed,P.value=e.value.shiftPressed)};return n.watch(()=>v.unrefElement(t),u=>{!u||typeof SVGSVGElement=="undefined"||!(u instanceof SVGSVGElement)||(e.value&&W(),e.value=h.createDrauu(pe({el:u},r)),q(),a=[e.value.on("canceled",()=>f.trigger()),e.value.on("committed",()=>i.trigger()),e.value.on("start",()=>l.trigger()),e.value.on("end",()=>o.trigger()),e.value.on("changed",()=>{q(),s.trigger()})])},{flush:"post"}),g.tryOnScopeDispose(()=>W()),{drauuInstance:e,load:Se,dump:je,clear:E,cancel:$e,undo:S,redo:y,canUndo:c,canRedo:_,brush:V,onChanged:s.on,onCommitted:i.on,onStart:l.on,onEnd:o.on,onCanceled:f.on}}var he=Object.defineProperty,Oe=Object.defineProperties,Pe=Object.getOwnPropertyDescriptors,$=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,M=(t,r,e)=>r in t?he(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,ge=(t,r)=>{for(var e in r||(r={}))Q.call(r,e)&&M(t,e,r[e]);if($)for(var e of $(r))J.call(r,e)&&M(t,e,r[e]);return t},we=(t,r)=>Oe(t,Pe(r)),ye=(t,r)=>{var e={};for(var a in t)Q.call(t,a)&&r.indexOf(a)<0&&(e[a]=t[a]);if(t!=null&&$)for(var a of $(t))r.indexOf(a)<0&&J.call(t,a)&&(e[a]=t[a]);return e};function me(t,r={}){let e;const a=r,{immediate:s}=a,f=ye(a,["immediate"]),i=n.ref(!1),l=n.ref(!1),o=P=>e&&e.activate(P),c=P=>e&&e.deactivate(P),_=()=>{e&&(e.pause(),l.value=!0)},w=()=>{e&&(e.unpause(),l.value=!1)};return n.watch(()=>v.unrefElement(t),P=>{!P||(e=b.createFocusTrap(P,we(ge({},f),{onActivate(){i.value=!0,r.onActivate&&r.onActivate()},onDeactivate(){i.value=!1,r.onDeactivate&&r.onDeactivate()}})),s&&o())},{flush:"post"}),v.tryOnScopeDispose(()=>c()),{hasFocus:i,isPaused:l,activate:o,deactivate:c,pause:_,unpause:w}}function be(t,r,e){var a;const s=(l,o)=>{var c;const _=o;return new Y.default((c=n.unref(l))!=null?c:[],_)},f=n.ref(s(r,(a=n.unref(e))==null?void 0:a.fuseOptions));return n.watch(()=>{var l;return(l=n.unref(e))==null?void 0:l.fuseOptions},l=>{f.value=s(r,l)},{deep:!0}),n.watch(()=>n.unref(r),l=>{f.value.setCollection(l)},{deep:!0}),{results:n.computed(()=>{var l,o;if(((l=n.unref(e))==null?void 0:l.matchAllWhenSearchEmpty)&&!n.unref(t))return n.unref(r).map((_,w)=>({item:_,refIndex:w}));const c=(o=n.unref(e))==null?void 0:o.resultLimit;return f.value.search(n.unref(t),c?{limit:c}:void 0)})}}function Ce(t,r={}){const e=n.ref(t),{onError:a,fallbackValue:s=null}=r,f=(o,c)=>{try{return Z.default(o,c)}catch(_){return a==null||a(_),s}},i=n.computed(()=>f(e.value,{header:!0})),l=n.computed(()=>f(e.value));return{header:i,payload:l}}function Ve(t=null,r){const e=n.isRef(t)?t:n.ref(t),a=n.computed({set:f=>f?O.default.start():O.default.done(),get:()=>g.isNumber(e.value)&&e.value<1});r&&O.default.configure(r);const s=O.default.set;return O.default.set=f=>(e.value=f,s.call(O.default,f)),n.watchEffect(()=>{g.isNumber(e.value)&&s.call(O.default,e.value)}),g.tryOnScopeDispose(O.default.remove),{isLoading:a,progress:e,start:O.default.start,done:O.default.done,remove:()=>{e.value=null,O.default.remove()}}}function Ee(t,r){const e=n.ref(t),a=n.ref("");return n.watch(e,async s=>{e.value&&g.isClient&&(a.value=await x.default.toDataURL(s,r))},{immediate:!0}),a}d.createCookies=fe,d.useAxios=oe,d.useCookies=U,d.useDrauu=_e,d.useFocusTrap=me,d.useFuse=be,d.useJwt=Ce,d.useNProgress=Ve,d.useQRCode=Ee,Object.defineProperty(d,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},VueDemi,axios,VueUse,UniversalCookie,Drauu,VueUse,focusTrap,Fuse,jwt_decode,nprogress,QRCode);
|
package/index.mjs
CHANGED
|
@@ -30,22 +30,25 @@ var __spreadValues$3 = (a, b) => {
|
|
|
30
30
|
};
|
|
31
31
|
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
32
32
|
function useAxios(url, ...args) {
|
|
33
|
-
let
|
|
33
|
+
let defaultConfig = {};
|
|
34
34
|
let instance = axios;
|
|
35
|
+
let options = { immediate: true };
|
|
35
36
|
if (args.length > 0) {
|
|
36
37
|
if ("request" in args[0])
|
|
37
38
|
instance = args[0];
|
|
38
39
|
else
|
|
39
|
-
|
|
40
|
+
defaultConfig = args[0];
|
|
40
41
|
}
|
|
41
42
|
if (args.length > 1) {
|
|
42
43
|
if ("request" in args[1])
|
|
43
44
|
instance = args[1];
|
|
44
45
|
}
|
|
46
|
+
if (args.length >= 2)
|
|
47
|
+
options = args[args.length - 1];
|
|
45
48
|
const response = shallowRef();
|
|
46
49
|
const data = shallowRef();
|
|
47
50
|
const isFinished = ref(false);
|
|
48
|
-
const isLoading = ref(
|
|
51
|
+
const isLoading = ref(false);
|
|
49
52
|
const aborted = ref(false);
|
|
50
53
|
const error = shallowRef();
|
|
51
54
|
const cancelToken = axios.CancelToken.source();
|
|
@@ -57,15 +60,23 @@ function useAxios(url, ...args) {
|
|
|
57
60
|
isLoading.value = false;
|
|
58
61
|
isFinished.value = false;
|
|
59
62
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
const loading = (loading2) => {
|
|
64
|
+
isLoading.value = loading2;
|
|
65
|
+
isFinished.value = !loading2;
|
|
66
|
+
};
|
|
67
|
+
const execute = (config = {}) => {
|
|
68
|
+
loading(true);
|
|
69
|
+
instance(url, __spreadProps$1(__spreadValues$3(__spreadValues$3({}, defaultConfig), config), { cancelToken: cancelToken.token })).then((r) => {
|
|
70
|
+
response.value = r;
|
|
71
|
+
data.value = r.data;
|
|
72
|
+
}).catch((e) => {
|
|
73
|
+
error.value = e;
|
|
74
|
+
}).finally(() => {
|
|
75
|
+
loading(false);
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
if (options.immediate)
|
|
79
|
+
execute();
|
|
69
80
|
return {
|
|
70
81
|
response,
|
|
71
82
|
data,
|
|
@@ -77,7 +88,8 @@ function useAxios(url, ...args) {
|
|
|
77
88
|
cancel: abort,
|
|
78
89
|
canceled: aborted,
|
|
79
90
|
aborted,
|
|
80
|
-
abort
|
|
91
|
+
abort,
|
|
92
|
+
execute
|
|
81
93
|
};
|
|
82
94
|
}
|
|
83
95
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/integrations",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.2",
|
|
4
4
|
"description": "Integration wrappers for utility libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue",
|
|
7
7
|
"vue-use",
|
|
8
8
|
"utils"
|
|
9
9
|
],
|
|
10
|
+
"homepage": "https://github.com/vueuse/vueuse/tree/main/packages/integrations#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/vueuse/vueuse/issues"
|
|
13
|
+
},
|
|
10
14
|
"license": "MIT",
|
|
11
15
|
"repository": {
|
|
12
16
|
"type": "git",
|
|
@@ -15,6 +19,7 @@
|
|
|
15
19
|
},
|
|
16
20
|
"funding": "https://github.com/sponsors/antfu",
|
|
17
21
|
"author": "Anthony Fu <https://github.com/antfu>",
|
|
22
|
+
"sideEffects": false,
|
|
18
23
|
"exports": {
|
|
19
24
|
".": {
|
|
20
25
|
"import": "./index.mjs",
|
|
@@ -69,33 +74,59 @@
|
|
|
69
74
|
}
|
|
70
75
|
},
|
|
71
76
|
"main": "./index.cjs",
|
|
72
|
-
"
|
|
77
|
+
"jsdelivr": "./index.iife.min.js",
|
|
73
78
|
"module": "./index.mjs",
|
|
74
79
|
"unpkg": "./index.iife.min.js",
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
"
|
|
80
|
+
"types": "./index.d.ts",
|
|
81
|
+
"peerDependencies": {
|
|
82
|
+
"axios": "*",
|
|
83
|
+
"drauu": "*",
|
|
84
|
+
"focus-trap": "*",
|
|
85
|
+
"fuse.js": "*",
|
|
86
|
+
"jwt-decode": "*",
|
|
87
|
+
"nprogress": "*",
|
|
88
|
+
"qrcode": "*",
|
|
89
|
+
"universal-cookie": "*"
|
|
90
|
+
},
|
|
91
|
+
"peerDependenciesMeta": {
|
|
92
|
+
"axios": {
|
|
93
|
+
"optional": true
|
|
94
|
+
},
|
|
95
|
+
"drauu": {
|
|
96
|
+
"optional": true
|
|
97
|
+
},
|
|
98
|
+
"focus-trap": {
|
|
99
|
+
"optional": true
|
|
100
|
+
},
|
|
101
|
+
"fuse.js": {
|
|
102
|
+
"optional": true
|
|
103
|
+
},
|
|
104
|
+
"jwt-decode": {
|
|
105
|
+
"optional": true
|
|
106
|
+
},
|
|
107
|
+
"nprogress": {
|
|
108
|
+
"optional": true
|
|
109
|
+
},
|
|
110
|
+
"qrcode": {
|
|
111
|
+
"optional": true
|
|
112
|
+
},
|
|
113
|
+
"universal-cookie": {
|
|
114
|
+
"optional": true
|
|
115
|
+
}
|
|
79
116
|
},
|
|
80
|
-
"homepage": "https://github.com/vueuse/vueuse/tree/main/packages/integrations#readme",
|
|
81
117
|
"dependencies": {
|
|
82
|
-
"@vueuse/core": "7.
|
|
83
|
-
"@vueuse/shared": "7.
|
|
118
|
+
"@vueuse/core": "7.6.2",
|
|
119
|
+
"@vueuse/shared": "7.6.2",
|
|
84
120
|
"vue-demi": "*"
|
|
85
121
|
},
|
|
86
|
-
"optionalDependencies": {
|
|
87
|
-
"axios": "^0.24.0",
|
|
88
|
-
"drauu": "^0.2.1",
|
|
89
|
-
"focus-trap": "^6.7.1",
|
|
90
|
-
"fuse.js": "^6.5.3",
|
|
91
|
-
"jwt-decode": "^3.1.2",
|
|
92
|
-
"nprogress": "^0.2.0",
|
|
93
|
-
"qrcode": "^1.5.0",
|
|
94
|
-
"universal-cookie": "^4.0.4"
|
|
95
|
-
},
|
|
96
122
|
"devDependencies": {
|
|
97
123
|
"@types/nprogress": "^0.2.0",
|
|
98
124
|
"@types/qrcode": "^1.4.2",
|
|
125
|
+
"axios": "^0.25.0",
|
|
126
|
+
"drauu": "^0.2.1",
|
|
127
|
+
"focus-trap": "^6.7.2",
|
|
128
|
+
"fuse.js": "^6.5.3",
|
|
129
|
+
"jwt-decode": "^3.1.2",
|
|
99
130
|
"nprogress": "^0.2.0",
|
|
100
131
|
"qrcode": "^1.5.0",
|
|
101
132
|
"universal-cookie": "^4.0.4"
|
package/useAxios.cjs
CHANGED
|
@@ -29,22 +29,25 @@ var __spreadValues = (a, b) => {
|
|
|
29
29
|
};
|
|
30
30
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
31
31
|
function useAxios(url, ...args) {
|
|
32
|
-
let
|
|
32
|
+
let defaultConfig = {};
|
|
33
33
|
let instance = axios__default["default"];
|
|
34
|
+
let options = { immediate: true };
|
|
34
35
|
if (args.length > 0) {
|
|
35
36
|
if ("request" in args[0])
|
|
36
37
|
instance = args[0];
|
|
37
38
|
else
|
|
38
|
-
|
|
39
|
+
defaultConfig = args[0];
|
|
39
40
|
}
|
|
40
41
|
if (args.length > 1) {
|
|
41
42
|
if ("request" in args[1])
|
|
42
43
|
instance = args[1];
|
|
43
44
|
}
|
|
45
|
+
if (args.length >= 2)
|
|
46
|
+
options = args[args.length - 1];
|
|
44
47
|
const response = vueDemi.shallowRef();
|
|
45
48
|
const data = vueDemi.shallowRef();
|
|
46
49
|
const isFinished = vueDemi.ref(false);
|
|
47
|
-
const isLoading = vueDemi.ref(
|
|
50
|
+
const isLoading = vueDemi.ref(false);
|
|
48
51
|
const aborted = vueDemi.ref(false);
|
|
49
52
|
const error = vueDemi.shallowRef();
|
|
50
53
|
const cancelToken = axios__default["default"].CancelToken.source();
|
|
@@ -56,15 +59,23 @@ function useAxios(url, ...args) {
|
|
|
56
59
|
isLoading.value = false;
|
|
57
60
|
isFinished.value = false;
|
|
58
61
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
const loading = (loading2) => {
|
|
63
|
+
isLoading.value = loading2;
|
|
64
|
+
isFinished.value = !loading2;
|
|
65
|
+
};
|
|
66
|
+
const execute = (config = {}) => {
|
|
67
|
+
loading(true);
|
|
68
|
+
instance(url, __spreadProps(__spreadValues(__spreadValues({}, defaultConfig), config), { cancelToken: cancelToken.token })).then((r) => {
|
|
69
|
+
response.value = r;
|
|
70
|
+
data.value = r.data;
|
|
71
|
+
}).catch((e) => {
|
|
72
|
+
error.value = e;
|
|
73
|
+
}).finally(() => {
|
|
74
|
+
loading(false);
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
if (options.immediate)
|
|
78
|
+
execute();
|
|
68
79
|
return {
|
|
69
80
|
response,
|
|
70
81
|
data,
|
|
@@ -76,7 +87,8 @@ function useAxios(url, ...args) {
|
|
|
76
87
|
cancel: abort,
|
|
77
88
|
canceled: aborted,
|
|
78
89
|
aborted,
|
|
79
|
-
abort
|
|
90
|
+
abort,
|
|
91
|
+
execute
|
|
80
92
|
};
|
|
81
93
|
}
|
|
82
94
|
|
package/useAxios.d.ts
CHANGED
|
@@ -30,9 +30,21 @@ interface UseAxiosReturn<T> {
|
|
|
30
30
|
* Aborts the current request
|
|
31
31
|
*/
|
|
32
32
|
abort: (message?: string | undefined) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Manually call the axios request
|
|
35
|
+
*/
|
|
36
|
+
execute: (config?: AxiosRequestConfig) => void;
|
|
37
|
+
}
|
|
38
|
+
interface UseAxiosOptions {
|
|
39
|
+
/**
|
|
40
|
+
* Will automatically run axios request when `useAxios` is used
|
|
41
|
+
*
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
44
|
+
immediate?: boolean;
|
|
33
45
|
}
|
|
34
|
-
declare function useAxios<T = any>(url: string, config?: AxiosRequestConfig): UseAxiosReturn<T>;
|
|
35
|
-
declare function useAxios<T = any>(url: string, instance?: AxiosInstance): UseAxiosReturn<T>;
|
|
36
|
-
declare function useAxios<T = any>(url: string, config: AxiosRequestConfig, instance: AxiosInstance): UseAxiosReturn<T>;
|
|
46
|
+
declare function useAxios<T = any>(url: string, config?: AxiosRequestConfig, options?: UseAxiosOptions): UseAxiosReturn<T>;
|
|
47
|
+
declare function useAxios<T = any>(url: string, instance?: AxiosInstance, options?: UseAxiosOptions): UseAxiosReturn<T>;
|
|
48
|
+
declare function useAxios<T = any>(url: string, config: AxiosRequestConfig, instance: AxiosInstance, options?: UseAxiosOptions): UseAxiosReturn<T>;
|
|
37
49
|
|
|
38
|
-
export { UseAxiosReturn, useAxios };
|
|
50
|
+
export { UseAxiosOptions, UseAxiosReturn, useAxios };
|
package/useAxios.iife.js
CHANGED
|
@@ -86,22 +86,25 @@
|
|
|
86
86
|
};
|
|
87
87
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
88
88
|
function useAxios(url, ...args) {
|
|
89
|
-
let
|
|
89
|
+
let defaultConfig = {};
|
|
90
90
|
let instance = axios__default["default"];
|
|
91
|
+
let options = { immediate: true };
|
|
91
92
|
if (args.length > 0) {
|
|
92
93
|
if ("request" in args[0])
|
|
93
94
|
instance = args[0];
|
|
94
95
|
else
|
|
95
|
-
|
|
96
|
+
defaultConfig = args[0];
|
|
96
97
|
}
|
|
97
98
|
if (args.length > 1) {
|
|
98
99
|
if ("request" in args[1])
|
|
99
100
|
instance = args[1];
|
|
100
101
|
}
|
|
102
|
+
if (args.length >= 2)
|
|
103
|
+
options = args[args.length - 1];
|
|
101
104
|
const response = vueDemi.shallowRef();
|
|
102
105
|
const data = vueDemi.shallowRef();
|
|
103
106
|
const isFinished = vueDemi.ref(false);
|
|
104
|
-
const isLoading = vueDemi.ref(
|
|
107
|
+
const isLoading = vueDemi.ref(false);
|
|
105
108
|
const aborted = vueDemi.ref(false);
|
|
106
109
|
const error = vueDemi.shallowRef();
|
|
107
110
|
const cancelToken = axios__default["default"].CancelToken.source();
|
|
@@ -113,15 +116,23 @@
|
|
|
113
116
|
isLoading.value = false;
|
|
114
117
|
isFinished.value = false;
|
|
115
118
|
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
const loading = (loading2) => {
|
|
120
|
+
isLoading.value = loading2;
|
|
121
|
+
isFinished.value = !loading2;
|
|
122
|
+
};
|
|
123
|
+
const execute = (config = {}) => {
|
|
124
|
+
loading(true);
|
|
125
|
+
instance(url, __spreadProps(__spreadValues(__spreadValues({}, defaultConfig), config), { cancelToken: cancelToken.token })).then((r) => {
|
|
126
|
+
response.value = r;
|
|
127
|
+
data.value = r.data;
|
|
128
|
+
}).catch((e) => {
|
|
129
|
+
error.value = e;
|
|
130
|
+
}).finally(() => {
|
|
131
|
+
loading(false);
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
if (options.immediate)
|
|
135
|
+
execute();
|
|
125
136
|
return {
|
|
126
137
|
response,
|
|
127
138
|
data,
|
|
@@ -133,7 +144,8 @@
|
|
|
133
144
|
cancel: abort,
|
|
134
145
|
canceled: aborted,
|
|
135
146
|
aborted,
|
|
136
|
-
abort
|
|
147
|
+
abort,
|
|
148
|
+
execute
|
|
137
149
|
};
|
|
138
150
|
}
|
|
139
151
|
|
package/useAxios.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(l){if(!l.VueDemi){var e={},o=l.Vue;if(o)if(o.version.slice(0,2)==="2."){var c=l.VueCompositionAPI;if(c){for(var
|
|
1
|
+
(function(l){if(!l.VueDemi){var e={},o=l.Vue;if(o)if(o.version.slice(0,2)==="2."){var c=l.VueCompositionAPI;if(c){for(var s in c)e[s]=c[s];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=o,e.Vue2=o,e.version=o.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.")}else if(o.version.slice(0,2)==="3."){for(var s in o)e[s]=o[s];e.isVue2=!1,e.isVue3=!0,e.install=function(){},e.Vue=o,e.Vue2=void 0,e.version=o.version,e.set=function(i,u,a){return Array.isArray(i)?(i.length=Math.max(i.length,u),i.splice(u,1,a),a):(i[u]=a,a)},e.del=function(i,u){if(Array.isArray(i)){i.splice(u,1);return}delete i[u]}}else console.error("[vue-demi] Vue version "+o.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");l.VueDemi=e}})(window),function(l,e,o){"use strict";function c(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var s=c(o),i=Object.defineProperty,u=Object.defineProperties,a=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable,m=(n,r,t)=>r in n?i(n,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[r]=t,O=(n,r)=>{for(var t in r||(r={}))T.call(r,t)&&m(n,t,r[t]);if(h)for(var t of h(r))q.call(r,t)&&m(n,t,r[t]);return n},C=(n,r)=>u(n,a(r));function D(n,...r){let t={},_=s.default,P={immediate:!0};r.length>0&&("request"in r[0]?_=r[0]:t=r[0]),r.length>1&&"request"in r[1]&&(_=r[1]),r.length>=2&&(P=r[r.length-1]);const b=e.shallowRef(),y=e.shallowRef(),d=e.ref(!1),p=e.ref(!1),V=e.ref(!1),j=e.shallowRef(),w=s.default.CancelToken.source(),A=f=>{d.value||!p.value||(w.cancel(f),V.value=!0,p.value=!1,d.value=!1)},x=f=>{p.value=f,d.value=!f},R=(f={})=>{x(!0),_(n,C(O(O({},t),f),{cancelToken:w.token})).then(v=>{b.value=v,y.value=v.data}).catch(v=>{j.value=v}).finally(()=>{x(!1)})};return P.immediate&&R(),{response:b,data:y,error:j,finished:d,loading:p,isFinished:d,isLoading:p,cancel:A,canceled:V,aborted:V,abort:A,execute:R}}l.useAxios=D,Object.defineProperty(l,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},VueDemi,axios);
|
package/useAxios.mjs
CHANGED
|
@@ -21,22 +21,25 @@ var __spreadValues = (a, b) => {
|
|
|
21
21
|
};
|
|
22
22
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
23
|
function useAxios(url, ...args) {
|
|
24
|
-
let
|
|
24
|
+
let defaultConfig = {};
|
|
25
25
|
let instance = axios;
|
|
26
|
+
let options = { immediate: true };
|
|
26
27
|
if (args.length > 0) {
|
|
27
28
|
if ("request" in args[0])
|
|
28
29
|
instance = args[0];
|
|
29
30
|
else
|
|
30
|
-
|
|
31
|
+
defaultConfig = args[0];
|
|
31
32
|
}
|
|
32
33
|
if (args.length > 1) {
|
|
33
34
|
if ("request" in args[1])
|
|
34
35
|
instance = args[1];
|
|
35
36
|
}
|
|
37
|
+
if (args.length >= 2)
|
|
38
|
+
options = args[args.length - 1];
|
|
36
39
|
const response = shallowRef();
|
|
37
40
|
const data = shallowRef();
|
|
38
41
|
const isFinished = ref(false);
|
|
39
|
-
const isLoading = ref(
|
|
42
|
+
const isLoading = ref(false);
|
|
40
43
|
const aborted = ref(false);
|
|
41
44
|
const error = shallowRef();
|
|
42
45
|
const cancelToken = axios.CancelToken.source();
|
|
@@ -48,15 +51,23 @@ function useAxios(url, ...args) {
|
|
|
48
51
|
isLoading.value = false;
|
|
49
52
|
isFinished.value = false;
|
|
50
53
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
const loading = (loading2) => {
|
|
55
|
+
isLoading.value = loading2;
|
|
56
|
+
isFinished.value = !loading2;
|
|
57
|
+
};
|
|
58
|
+
const execute = (config = {}) => {
|
|
59
|
+
loading(true);
|
|
60
|
+
instance(url, __spreadProps(__spreadValues(__spreadValues({}, defaultConfig), config), { cancelToken: cancelToken.token })).then((r) => {
|
|
61
|
+
response.value = r;
|
|
62
|
+
data.value = r.data;
|
|
63
|
+
}).catch((e) => {
|
|
64
|
+
error.value = e;
|
|
65
|
+
}).finally(() => {
|
|
66
|
+
loading(false);
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
if (options.immediate)
|
|
70
|
+
execute();
|
|
60
71
|
return {
|
|
61
72
|
response,
|
|
62
73
|
data,
|
|
@@ -68,7 +79,8 @@ function useAxios(url, ...args) {
|
|
|
68
79
|
cancel: abort,
|
|
69
80
|
canceled: aborted,
|
|
70
81
|
aborted,
|
|
71
|
-
abort
|
|
82
|
+
abort,
|
|
83
|
+
execute
|
|
72
84
|
};
|
|
73
85
|
}
|
|
74
86
|
|