@hzab/data-model 1.8.4 → 1.8.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # @hzab/data-model@1.8.5
2
+
3
+ fix: getToken opt.hasCookie 是否读取 cookie 的 token。默认不读取 cookie 的 token
4
+ fix: setToken 默认不设置到 cookie 上
5
+
1
6
  # @hzab/data-model@1.8.4
2
7
 
3
8
  fix: response undefined 兼容处理
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/data-model",
3
- "version": "1.8.4",
3
+ "version": "1.8.6",
4
4
  "description": "data model",
5
5
  "main": "src",
6
6
  "scripts": {
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 !== false) {
15
+ if (hasCookie) {
16
16
  const { cookieAttrs } = opt || {};
17
17
  const cookieOpt = _.merge(
18
18
  {
@@ -30,10 +30,14 @@ export function setToken(token = "", opt) {
30
30
  * 获取 token
31
31
  * @returns
32
32
  */
33
- export function getToken() {
34
- let token = Cookies.get(TOKEN) || "";
35
- if (token) {
36
- return token;
33
+ export function getToken(opt) {
34
+ const { hasCookie = false } = opt || {};
35
+ let token = "";
36
+ if (hasCookie) {
37
+ token = Cookies.get(TOKEN) || "";
38
+ if (token) {
39
+ return token;
40
+ }
37
41
  }
38
42
  token = localStorage.getItem(TOKEN);
39
43
  return token;