@hzab/data-model 2.0.0-alpha.0 → 2.0.0-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 +2 -1
- package/package.json +1 -1
- package/src/data-model.ts +6 -6
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/data-model.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from "lodash";
|
|
2
|
-
import { axios,
|
|
2
|
+
import { axios, isCancel } from "./axios";
|
|
3
3
|
import {
|
|
4
4
|
objToFormData,
|
|
5
5
|
formDataToObj,
|
|
@@ -406,7 +406,7 @@ class DataModel<T = any> {
|
|
|
406
406
|
const params = _.merge({}, record, ctx);
|
|
407
407
|
_.each(params, (value, key) => {
|
|
408
408
|
if (!_.isString(value) || !_.isNumber(value) || _.isBoolean(value)) {
|
|
409
|
-
apiUrl = apiUrl.replace(new RegExp(`:${key}$|:${key}(
|
|
409
|
+
apiUrl = apiUrl.replace(new RegExp(`:${key}$|:${key}(?=/)`), value);
|
|
410
410
|
}
|
|
411
411
|
});
|
|
412
412
|
return apiUrl;
|
|
@@ -704,8 +704,8 @@ class DataModel<T = any> {
|
|
|
704
704
|
* @param reject 失败回调
|
|
705
705
|
*/
|
|
706
706
|
handleRes(response: any, resolve: (res: any) => void, reject: (err: ApiError) => void) {
|
|
707
|
-
if (
|
|
708
|
-
console.info("errorHandler
|
|
707
|
+
if (isCancel(response)) {
|
|
708
|
+
console.info("errorHandler isCancel", response);
|
|
709
709
|
return;
|
|
710
710
|
}
|
|
711
711
|
if (this.isResponse) {
|
|
@@ -755,8 +755,8 @@ class DataModel<T = any> {
|
|
|
755
755
|
* @param reject Promise reject 回调
|
|
756
756
|
*/
|
|
757
757
|
errorHandler(err: any = {}, reject: (err: ApiError) => void) {
|
|
758
|
-
if (
|
|
759
|
-
console.info("errorHandler
|
|
758
|
+
if (isCancel(err)) {
|
|
759
|
+
console.info("errorHandler isCancel", err);
|
|
760
760
|
return;
|
|
761
761
|
}
|
|
762
762
|
if (this.isResponse) {
|