@hzab/data-model 1.8.4 → 1.8.5
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/CHANGELOG.md +5 -0
- package/package.json +1 -1
- package/src/axios.js +9 -6
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/axios.js
CHANGED
|
@@ -10,9 +10,9 @@ export const TOKEN = "token";
|
|
|
10
10
|
* @param {Object} opt
|
|
11
11
|
*/
|
|
12
12
|
export function setToken(token = "", opt) {
|
|
13
|
-
const { hasCookie } = opt || {};
|
|
13
|
+
const { hasCookie = false } = opt || {};
|
|
14
14
|
const _t = token || "";
|
|
15
|
-
if (hasCookie
|
|
15
|
+
if (hasCookie) {
|
|
16
16
|
const { cookieAttrs } = opt || {};
|
|
17
17
|
const cookieOpt = _.merge(
|
|
18
18
|
{
|
|
@@ -30,10 +30,13 @@ export function setToken(token = "", opt) {
|
|
|
30
30
|
* 获取 token
|
|
31
31
|
* @returns
|
|
32
32
|
*/
|
|
33
|
-
export function getToken() {
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
|
|
33
|
+
export function getToken(opt) {
|
|
34
|
+
const { hasCookie = false } = opt || {};
|
|
35
|
+
if (hasCookie) {
|
|
36
|
+
let token = Cookies.get(TOKEN) || "";
|
|
37
|
+
if (token) {
|
|
38
|
+
return token;
|
|
39
|
+
}
|
|
37
40
|
}
|
|
38
41
|
token = localStorage.getItem(TOKEN);
|
|
39
42
|
return token;
|