@hzab/data-model 1.8.8 → 1.8.9-alpha.0

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/src/axios.js CHANGED
@@ -1,9 +1,11 @@
1
- import axios from "axios";
1
+ import axiosDef from "axios";
2
2
  import Cookies from "js-cookie";
3
3
  import _ from "lodash";
4
4
 
5
5
  export const TOKEN = "token";
6
6
 
7
+ const axios = axiosDef.create();
8
+
7
9
  /**
8
10
  * 设置 token
9
11
  * @param {string} token
@@ -43,7 +45,7 @@ export function getToken(opt) {
43
45
  return token;
44
46
  }
45
47
 
46
- export const temp = { axiosList: [axios] };
48
+ export const temp = { axiosList: [axios, axiosDef] };
47
49
 
48
50
  export function setAxios(axiosList) {
49
51
  temp.axiosList = [...temp.axiosList, ...axiosList];
@@ -92,7 +94,7 @@ export function handleErrCb(errCb, opt) {
92
94
  }
93
95
 
94
96
  return (error) => {
95
- if (axios.isCancel(error)) {
97
+ if (axiosDef.isCancel(error)) {
96
98
  console.info("axios 请求已取消:", error);
97
99
  return Promise.reject(error);
98
100
  }
@@ -152,9 +154,9 @@ export function setAxBaseUrl(url) {
152
154
  * @returns
153
155
  */
154
156
  export function getCancelTokenSource() {
155
- return axios.CancelToken.source();
157
+ return axiosDef.CancelToken.source();
156
158
  }
157
159
 
158
- export { axios };
160
+ export { axios, axiosDef };
159
161
 
160
162
  export default axios;