beer-network 1.1.1-alpha.16 → 1.1.1-alpha.18
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/api.d.ts +6 -0
- package/api.js +11 -4
- package/elementUtils.d.ts +1 -1
- package/elementUtils.js +1 -1
- package/package.json +1 -1
- package/session.js +9 -0
package/api.d.ts
CHANGED
package/api.js
CHANGED
|
@@ -17,7 +17,8 @@ export default class Fetch {
|
|
|
17
17
|
'Content-Type': 'application/json'
|
|
18
18
|
},
|
|
19
19
|
body: JSON.stringify(body || {}),
|
|
20
|
-
signal: option?.signal || null
|
|
20
|
+
signal: option?.signal || null,
|
|
21
|
+
next: option?.next
|
|
21
22
|
});
|
|
22
23
|
return this.responseJson(response);
|
|
23
24
|
}
|
|
@@ -54,7 +55,8 @@ export default class Fetch {
|
|
|
54
55
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
55
56
|
},
|
|
56
57
|
body: formData,
|
|
57
|
-
signal: option?.signal || null
|
|
58
|
+
signal: option?.signal || null,
|
|
59
|
+
next: option?.next
|
|
58
60
|
});
|
|
59
61
|
return this.responseJson(response);
|
|
60
62
|
}
|
|
@@ -71,7 +73,8 @@ export default class Fetch {
|
|
|
71
73
|
...(header || {})
|
|
72
74
|
},
|
|
73
75
|
body: formData,
|
|
74
|
-
signal: option?.signal || null
|
|
76
|
+
signal: option?.signal || null,
|
|
77
|
+
next: option?.next
|
|
75
78
|
});
|
|
76
79
|
return this.responseJson(response);
|
|
77
80
|
}
|
|
@@ -87,7 +90,8 @@ export default class Fetch {
|
|
|
87
90
|
...this.authorization(),
|
|
88
91
|
...(header || {})
|
|
89
92
|
},
|
|
90
|
-
signal: option?.signal || null
|
|
93
|
+
signal: option?.signal || null,
|
|
94
|
+
next: option?.next
|
|
91
95
|
});
|
|
92
96
|
return this.responseJson(response);
|
|
93
97
|
}
|
|
@@ -272,6 +276,9 @@ export default class Fetch {
|
|
|
272
276
|
*/
|
|
273
277
|
async responseJson(response) {
|
|
274
278
|
const result = await response.json();
|
|
279
|
+
if (typeof window === 'undefined') {
|
|
280
|
+
return result;
|
|
281
|
+
}
|
|
275
282
|
if (result?.code === '401') {
|
|
276
283
|
setTimeout(() => window.location.replace('/auth/login'), 500);
|
|
277
284
|
return result;
|
package/elementUtils.d.ts
CHANGED
package/elementUtils.js
CHANGED
|
@@ -25,7 +25,7 @@ export default class ElementUtils {
|
|
|
25
25
|
static download(url, fileName) {
|
|
26
26
|
const link = document.createElement('a');
|
|
27
27
|
link.href = url;
|
|
28
|
-
link.download = fileName;
|
|
28
|
+
link.download = fileName || '';
|
|
29
29
|
document.body.appendChild(link);
|
|
30
30
|
link.click();
|
|
31
31
|
document.body.removeChild(link);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "beer-network",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.1.1-alpha.
|
|
4
|
+
"version": "1.1.1-alpha.18",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"pub-w": "tsc && copy package.json .\\dist\\package.json && npm publish ./dist",
|
|
7
7
|
"pub-m": "tsc && cp package.json ./dist/package.json && npm publish ./dist"
|
package/session.js
CHANGED
|
@@ -6,6 +6,9 @@ export class Session {
|
|
|
6
6
|
* <li>window.accessToken 设置身份令牌, 直接返回.</li>
|
|
7
7
|
*/
|
|
8
8
|
static getBearer() {
|
|
9
|
+
if (typeof window === 'undefined') {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
9
12
|
if (window.accessToken !== undefined && window.accessToken !== '') {
|
|
10
13
|
return window.accessToken;
|
|
11
14
|
}
|
|
@@ -20,6 +23,9 @@ export class Session {
|
|
|
20
23
|
* 检查令牌是否存在.
|
|
21
24
|
*/
|
|
22
25
|
static checkAccessTokenExist() {
|
|
26
|
+
if (typeof window === 'undefined') {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
23
29
|
const bearer = Session.getBearer();
|
|
24
30
|
return !(bearer === undefined || bearer === '');
|
|
25
31
|
}
|
|
@@ -28,6 +34,9 @@ export class Session {
|
|
|
28
34
|
* @param url 退出之后的地址.
|
|
29
35
|
*/
|
|
30
36
|
static logout(url) {
|
|
37
|
+
if (typeof window === 'undefined') {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
31
40
|
localStorage?.clear();
|
|
32
41
|
sessionStorage?.clear();
|
|
33
42
|
if (url !== undefined && url !== '') {
|