@andbridge/glowpod 1.1.12 → 1.2.1
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/build/glowpod.esm.js +76 -1
- package/package.json +3 -2
package/build/glowpod.esm.js
CHANGED
|
@@ -1 +1,76 @@
|
|
|
1
|
-
import e from"axios";
|
|
1
|
+
import e from "axios";
|
|
2
|
+
|
|
3
|
+
class a {
|
|
4
|
+
instance;
|
|
5
|
+
constructor(a) {
|
|
6
|
+
this.instance = e.create(a);
|
|
7
|
+
}
|
|
8
|
+
getInstance=() => this.instance;
|
|
9
|
+
Get=async e => this.instance({
|
|
10
|
+
method: "GET",
|
|
11
|
+
url: e.url,
|
|
12
|
+
params: e.params,
|
|
13
|
+
headers: {
|
|
14
|
+
...e.headers
|
|
15
|
+
},
|
|
16
|
+
...e.others
|
|
17
|
+
});
|
|
18
|
+
Put=async e => this.instance({
|
|
19
|
+
method: "PUT",
|
|
20
|
+
url: e.url,
|
|
21
|
+
data: e.params,
|
|
22
|
+
headers: {
|
|
23
|
+
...e.headers
|
|
24
|
+
},
|
|
25
|
+
...e.others
|
|
26
|
+
});
|
|
27
|
+
Delete=async e => this.instance({
|
|
28
|
+
method: "DELETE",
|
|
29
|
+
url: e.url,
|
|
30
|
+
params: e.params,
|
|
31
|
+
headers: {
|
|
32
|
+
...e.headers
|
|
33
|
+
},
|
|
34
|
+
...e.others
|
|
35
|
+
});
|
|
36
|
+
Post=async e => this.instance({
|
|
37
|
+
method: "POST",
|
|
38
|
+
url: e.url,
|
|
39
|
+
data: e.params,
|
|
40
|
+
headers: {
|
|
41
|
+
...e.headers
|
|
42
|
+
},
|
|
43
|
+
...e.others
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const s = 200, t = 299, r = ({instance: e, authFailedCaller: a = () => {}, networkSuccessCode: r = 200, authFailedCode: o = 401, networkFailedCaller: n = () => {}, serverKillCaller: d = () => {}, responseStruct: c = {
|
|
48
|
+
codeName: "code",
|
|
49
|
+
messageName: "message",
|
|
50
|
+
dataName: "data"
|
|
51
|
+
}, setHeaders: l = async e => {}}) => {
|
|
52
|
+
let i = null, h = !0;
|
|
53
|
+
const u = e => (i && clearTimeout(i), i = setTimeout(() => {
|
|
54
|
+
if (h) return e.status <= s && e.status >= t ? d(e) : e.data?.[c.codeName] == o ? a(e.data) : e.data?.[c.codeName] != r ? n(e.data) : d(e);
|
|
55
|
+
}, 0), () => h = !1);
|
|
56
|
+
e.interceptors.request.use(async e => (e.headers && await (l?.(e.headers)), e), e => (console.log("请求错误拦截器:", e),
|
|
57
|
+
u(e), Promise.reject(e))), e.interceptors.response.use(e => {
|
|
58
|
+
if ("blob" === e.config.responseType) return e;
|
|
59
|
+
if (e.data?.[c.codeName] === r) return e.data?.[c.dataName];
|
|
60
|
+
{
|
|
61
|
+
const a = u(e);
|
|
62
|
+
throw {
|
|
63
|
+
...e,
|
|
64
|
+
hiddenDefaultErrorHandler: a
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}, e => {
|
|
68
|
+
const a = u(e);
|
|
69
|
+
throw {
|
|
70
|
+
...e,
|
|
71
|
+
hiddenDefaultErrorHandler: a
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export { a as GlowPod, r as setupInterceptors };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andbridge/glowpod",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "A axios-based HTTP client library",
|
|
5
5
|
"main": "build/glowpod.js",
|
|
6
6
|
"module": "build/glowpod.esm.js",
|
|
@@ -31,9 +31,10 @@
|
|
|
31
31
|
"@rollup/plugin-babel": "^6.1.0",
|
|
32
32
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
33
33
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
34
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
34
35
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
36
|
+
"@types/node": "^22.15.0",
|
|
35
37
|
"rollup": "^4.53.2",
|
|
36
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
37
38
|
"tslib": "^2.8.1",
|
|
38
39
|
"typescript": "~5.9.3"
|
|
39
40
|
},
|