@hzab/data-model 1.8.8 → 1.8.9-alpha.1
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 +138 -134
- package/README.md +18 -14
- package/package.json +11 -8
- package/src/ArrayUtils.js +539 -539
- package/src/array-data-model.js +422 -422
- package/src/axios.js +7 -5
- package/src/data-model.js +5 -5
package/src/axios.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import
|
|
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 (
|
|
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
|
|
157
|
+
return axiosDef.CancelToken.source();
|
|
156
158
|
}
|
|
157
159
|
|
|
158
|
-
export { axios };
|
|
160
|
+
export { axios, axiosDef };
|
|
159
161
|
|
|
160
162
|
export default axios;
|
package/src/data-model.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from "lodash";
|
|
2
|
-
import axios from "./axios";
|
|
2
|
+
import { axios, axiosDef } from "./axios";
|
|
3
3
|
|
|
4
4
|
import { objToFormData, formDataToObj, _$Temp, setDefaultAxios, setDefaultErrMsg, setNetworkErrMsg } from "./utils";
|
|
5
5
|
|
|
@@ -458,8 +458,8 @@ class DataModel {
|
|
|
458
458
|
}
|
|
459
459
|
|
|
460
460
|
handleRes(response = {}, resolve, reject) {
|
|
461
|
-
if (
|
|
462
|
-
console.info("errorHandler
|
|
461
|
+
if (axiosDef.isCancel(response)) {
|
|
462
|
+
console.info("errorHandler axiosDef.isCancel", response);
|
|
463
463
|
return;
|
|
464
464
|
}
|
|
465
465
|
if (this.isResponse) {
|
|
@@ -504,8 +504,8 @@ class DataModel {
|
|
|
504
504
|
}
|
|
505
505
|
|
|
506
506
|
errorHandler(err = {}, reject) {
|
|
507
|
-
if (
|
|
508
|
-
console.info("errorHandler
|
|
507
|
+
if (axiosDef.isCancel(err)) {
|
|
508
|
+
console.info("errorHandler axiosDef.isCancel", err);
|
|
509
509
|
return;
|
|
510
510
|
}
|
|
511
511
|
if (this.isResponse) {
|