@glodon-aiot/apis 3.0.5 → 3.0.6
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.
|
@@ -528,7 +528,7 @@ class Y extends b {
|
|
|
528
528
|
openWhenHidden: !0,
|
|
529
529
|
signal: i,
|
|
530
530
|
onopen(o) {
|
|
531
|
-
return
|
|
531
|
+
return o.ok && r != null && r.onopen && r.onopen(), Promise.resolve();
|
|
532
532
|
},
|
|
533
533
|
onmessage(o) {
|
|
534
534
|
if (!o.data && !o.event && !o.id && !o.retry)
|
|
@@ -114,7 +114,7 @@ class _ extends k {
|
|
|
114
114
|
openWhenHidden: !0,
|
|
115
115
|
signal: i,
|
|
116
116
|
onopen(d) {
|
|
117
|
-
return
|
|
117
|
+
return d.ok && n != null && n.onopen && n.onopen(), Promise.resolve();
|
|
118
118
|
},
|
|
119
119
|
onmessage(d) {
|
|
120
120
|
if (!d.data.includes('{"code": ')) {
|
package/dist/es/base/index.mjs
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var u = (o, s,
|
|
5
|
-
for (var
|
|
6
|
-
|
|
7
|
-
if (
|
|
8
|
-
for (var
|
|
9
|
-
y.call(s,
|
|
1
|
+
var x = Object.defineProperty;
|
|
2
|
+
var l = Object.getOwnPropertySymbols;
|
|
3
|
+
var g = Object.prototype.hasOwnProperty, y = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var u = (o, s, t) => s in o ? x(o, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[s] = t, c = (o, s) => {
|
|
5
|
+
for (var t in s || (s = {}))
|
|
6
|
+
g.call(s, t) && u(o, t, s[t]);
|
|
7
|
+
if (l)
|
|
8
|
+
for (var t of l(s))
|
|
9
|
+
y.call(s, t) && u(o, t, s[t]);
|
|
10
10
|
return o;
|
|
11
11
|
};
|
|
12
|
-
var n = (o, s,
|
|
12
|
+
var n = (o, s, t) => new Promise((e, r) => {
|
|
13
13
|
var p = (a) => {
|
|
14
14
|
try {
|
|
15
|
-
h(
|
|
16
|
-
} catch (
|
|
17
|
-
r(
|
|
15
|
+
h(t.next(a));
|
|
16
|
+
} catch (d) {
|
|
17
|
+
r(d);
|
|
18
18
|
}
|
|
19
19
|
}, i = (a) => {
|
|
20
20
|
try {
|
|
21
|
-
h(
|
|
22
|
-
} catch (
|
|
23
|
-
r(
|
|
21
|
+
h(t.throw(a));
|
|
22
|
+
} catch (d) {
|
|
23
|
+
r(d);
|
|
24
24
|
}
|
|
25
|
-
}, h = (a) => a.done ?
|
|
26
|
-
h((
|
|
25
|
+
}, h = (a) => a.done ? e(a.value) : Promise.resolve(a.value).then(p, i);
|
|
26
|
+
h((t = t.apply(o, s)).next());
|
|
27
27
|
});
|
|
28
28
|
class R {
|
|
29
|
-
constructor(s,
|
|
30
|
-
this.axios = s, this.errorHandler =
|
|
29
|
+
constructor(s, t) {
|
|
30
|
+
this.axios = s, this.errorHandler = t;
|
|
31
31
|
}
|
|
32
|
-
get(s,
|
|
32
|
+
get(s, t, e) {
|
|
33
33
|
return n(this, null, function* () {
|
|
34
34
|
const r = this.axios.get(s, {
|
|
35
|
-
params:
|
|
35
|
+
params: t
|
|
36
36
|
});
|
|
37
|
-
return this.handleResponse(r,
|
|
37
|
+
return this.handleResponse(r, e);
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
listPaged(s,
|
|
40
|
+
listPaged(s, t) {
|
|
41
41
|
return n(this, null, function* () {
|
|
42
|
-
const
|
|
43
|
-
params:
|
|
42
|
+
const e = this.axios.get(s, {
|
|
43
|
+
params: t
|
|
44
44
|
});
|
|
45
|
-
return this.handleResponse(
|
|
45
|
+
return this.handleResponse(e);
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
list(s,
|
|
48
|
+
list(s, t) {
|
|
49
49
|
return n(this, null, function* () {
|
|
50
|
-
const
|
|
51
|
-
params:
|
|
50
|
+
const e = this.axios.get(s, {
|
|
51
|
+
params: t
|
|
52
52
|
});
|
|
53
|
-
return this.handleResponse(
|
|
53
|
+
return this.handleResponse(e);
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
|
-
delete(s,
|
|
56
|
+
delete(s, t) {
|
|
57
57
|
return n(this, null, function* () {
|
|
58
|
-
const
|
|
59
|
-
params:
|
|
58
|
+
const e = this.axios.delete(s, {
|
|
59
|
+
params: t
|
|
60
60
|
});
|
|
61
|
-
return this.handleResponse(
|
|
61
|
+
return this.handleResponse(e);
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
post(s,
|
|
64
|
+
post(s, t, e, r) {
|
|
65
65
|
return n(this, null, function* () {
|
|
66
|
-
const p = this.axios.post(s,
|
|
67
|
-
params:
|
|
66
|
+
const p = this.axios.post(s, t, c({
|
|
67
|
+
params: e
|
|
68
68
|
}, r));
|
|
69
69
|
return this.handleResponse(p);
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
-
postForm(s,
|
|
72
|
+
postForm(s, t, e) {
|
|
73
73
|
return n(this, null, function* () {
|
|
74
|
-
const r = this.axios.post(s,
|
|
75
|
-
params:
|
|
74
|
+
const r = this.axios.post(s, t, {
|
|
75
|
+
params: e,
|
|
76
76
|
headers: {
|
|
77
77
|
"Content-Type": "multipart/form-data"
|
|
78
78
|
}
|
|
@@ -80,31 +80,31 @@ class R {
|
|
|
80
80
|
return this.handleResponse(r);
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
-
patch(s,
|
|
83
|
+
patch(s, t, e) {
|
|
84
84
|
return n(this, null, function* () {
|
|
85
|
-
const r = this.axios.patch(s,
|
|
86
|
-
params:
|
|
85
|
+
const r = this.axios.patch(s, t, {
|
|
86
|
+
params: e
|
|
87
87
|
});
|
|
88
88
|
return this.handleResponse(r);
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
-
put(s,
|
|
91
|
+
put(s, t) {
|
|
92
92
|
return n(this, null, function* () {
|
|
93
|
-
const
|
|
94
|
-
return this.handleResponse(
|
|
93
|
+
const e = this.axios.put(s, t);
|
|
94
|
+
return this.handleResponse(e);
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
|
-
upload(s,
|
|
97
|
+
upload(s, t, e) {
|
|
98
98
|
return n(this, null, function* () {
|
|
99
|
-
const r = this.axios.post(s,
|
|
99
|
+
const r = this.axios.post(s, t, c({}, e));
|
|
100
100
|
return this.handleResponse(r);
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
|
-
getNonStandard(s,
|
|
103
|
+
getNonStandard(s, t) {
|
|
104
104
|
return n(this, null, function* () {
|
|
105
|
-
const
|
|
105
|
+
const e = this.axios.get(s, t);
|
|
106
106
|
try {
|
|
107
|
-
const r = yield
|
|
107
|
+
const r = yield e;
|
|
108
108
|
if (r.status === 200)
|
|
109
109
|
return r;
|
|
110
110
|
} catch (r) {
|
|
@@ -112,11 +112,11 @@ class R {
|
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
-
postNonStandard(s,
|
|
115
|
+
postNonStandard(s, t, e, r) {
|
|
116
116
|
return n(this, null, function* () {
|
|
117
117
|
var h, a;
|
|
118
|
-
const i = yield this.axios.post(s,
|
|
119
|
-
params:
|
|
118
|
+
const i = yield this.axios.post(s, t, c({
|
|
119
|
+
params: e
|
|
120
120
|
}, r));
|
|
121
121
|
if (i.status === 200)
|
|
122
122
|
if ((h = i.data) != null && h.code)
|
|
@@ -125,20 +125,20 @@ class R {
|
|
|
125
125
|
return i.data;
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
handleResponse(s,
|
|
128
|
+
handleResponse(s, t) {
|
|
129
129
|
return n(this, null, function* () {
|
|
130
130
|
try {
|
|
131
|
-
const
|
|
132
|
-
return this.handleAppError(
|
|
133
|
-
} catch (
|
|
134
|
-
throw this.handleError(
|
|
131
|
+
const e = yield s;
|
|
132
|
+
return this.handleAppError(e.data, t).data;
|
|
133
|
+
} catch (e) {
|
|
134
|
+
throw this.handleError(e);
|
|
135
135
|
}
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
handleAppError(s,
|
|
139
|
-
var
|
|
138
|
+
handleAppError(s, t) {
|
|
139
|
+
var e;
|
|
140
140
|
if (s.code < 200 || s.code >= 300)
|
|
141
|
-
throw (
|
|
141
|
+
throw (e = this.errorHandler) != null && e.onAppStatusError ? this.errorHandler.onAppStatusError(s.code, E(s.code, s.message), t) : console.error("未处理应用错误:", s), {
|
|
142
142
|
isAxiosError: !1,
|
|
143
143
|
message: s.message
|
|
144
144
|
};
|
|
@@ -146,8 +146,8 @@ class R {
|
|
|
146
146
|
}
|
|
147
147
|
// https://github.com/axios/axios#handling-errors
|
|
148
148
|
handleError(s) {
|
|
149
|
-
var
|
|
150
|
-
return s.response ? (
|
|
149
|
+
var t, e;
|
|
150
|
+
return s.response ? (t = this.errorHandler) != null && t.onHttpStatusError && (console.log("HTTP 错误", this.errorHandler), this.errorHandler.onHttpStatusError(s.response.status, "", s.response)) : s.request ? (console.log(s.request), (e = this.errorHandler) != null && e.onNetworkError && this.errorHandler.onNetworkError()) : console.error("axios request config error:", s), new Error(s.message);
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
const f = (o) => o >= 10002 && o <= 10012, E = (o, s) => f(o) ? "数据操作错误" : s || "未知接口错误";
|