@gm-mobile/mp-request 3.9.3-beta.8 → 3.9.3
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/package.json +5 -5
- package/src/index.ts +2 -1
- package/src/init.ts +9 -0
- package/src/request.ts +5 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gm-mobile/mp-request",
|
|
3
|
-
"version": "3.9.3
|
|
3
|
+
"version": "3.9.3",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "zhongsink <zhongink@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/gmfe/gm-mobile#readme",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"url": "https://github.com/gmfe/gm-mobile/issues"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@gm-mobile/c-tool": "^3.9.3
|
|
24
|
-
"@gm-mobile/locales": "^3.9.3
|
|
25
|
-
"@gm-mobile/mp": "^3.9.3
|
|
23
|
+
"@gm-mobile/c-tool": "^3.9.3",
|
|
24
|
+
"@gm-mobile/locales": "^3.9.3",
|
|
25
|
+
"@gm-mobile/mp": "^3.9.3",
|
|
26
26
|
"js-base64": "^3.6.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"taro-axios": "^1.1.1",
|
|
31
31
|
"weapp-cookie": "^1.4.6"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "1f1d2b656046efe6479f05f9fde2e34cb99df4de"
|
|
34
34
|
}
|
package/src/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ import configHeaders from './config_headers'
|
|
|
4
4
|
import configTrace from './config_trace'
|
|
5
5
|
import configError from './config_error'
|
|
6
6
|
import configProgress from './config_progress'
|
|
7
|
-
import { initAuth, clearAuth } from './init'
|
|
7
|
+
import { initAuth, clearAuth, setAccessToken } from './init'
|
|
8
8
|
|
|
9
9
|
export {
|
|
10
10
|
initAuth,
|
|
@@ -15,5 +15,6 @@ export {
|
|
|
15
15
|
configTrace,
|
|
16
16
|
configError,
|
|
17
17
|
configProgress,
|
|
18
|
+
setAccessToken,
|
|
18
19
|
}
|
|
19
20
|
export type { Response } from './types'
|
package/src/init.ts
CHANGED
|
@@ -39,3 +39,12 @@ export function clearAuth() {
|
|
|
39
39
|
LocalStorage.remove(accessTokenKey)
|
|
40
40
|
accessToken = undefined
|
|
41
41
|
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @description: 设置新的token
|
|
45
|
+
* @param {string} newAccessToken 新token
|
|
46
|
+
*/
|
|
47
|
+
export function setAccessToken(newAccessToken: string) {
|
|
48
|
+
LocalStorage.set(accessTokenKey, newAccessToken)
|
|
49
|
+
accessToken = newAccessToken
|
|
50
|
+
}
|
package/src/request.ts
CHANGED
|
@@ -52,11 +52,11 @@ class RequestBase<Data> {
|
|
|
52
52
|
const formatRes = formatToResponse<Data>(res)
|
|
53
53
|
|
|
54
54
|
// log 在这里做,不能在 formatToResponse,因为它可能被调用多次
|
|
55
|
-
console.groupCollapsed(`request ${res.config.url}`)
|
|
56
|
-
console.log('code', formatRes.code)
|
|
57
|
-
console.log('message.description', formatRes.message.description)
|
|
58
|
-
console.log('message.detail', formatRes.message.detail)
|
|
59
|
-
console.groupEnd()
|
|
55
|
+
// console.groupCollapsed(`request ${res.config.url}`)
|
|
56
|
+
// console.log('code', formatRes.code)
|
|
57
|
+
// console.log('message.description', formatRes.message.description)
|
|
58
|
+
// console.log('message.detail', formatRes.message.detail)
|
|
59
|
+
// console.groupEnd()
|
|
60
60
|
|
|
61
61
|
return formatRes
|
|
62
62
|
})
|