zmdms-utils 0.0.8 → 0.0.9

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.
@@ -48,6 +48,8 @@ interface IOtherOptions {
48
48
  crypto?: Crypto;
49
49
  isTimeoutConfirm?: boolean;
50
50
  isTimeoutConfirmStr?: string;
51
+ interceptorsRequestHandle?: () => void;
52
+ interceptorsResponseHandle?: () => void;
51
53
  }
52
54
 
53
55
  export { AxiosRequest, IOptions, IOtherOptions };
@@ -41,6 +41,10 @@ var AxiosRequest = /** @class */ (function () {
41
41
  };
42
42
  // 拦截请求
43
43
  AxiosRequest.prototype.interceptorsRequest = function () {
44
+ if (this.otherOptions.interceptorsRequestHandle) {
45
+ this.otherOptions.interceptorsRequestHandle();
46
+ return;
47
+ }
44
48
  axios.interceptors.request.use(function (config) {
45
49
  return config;
46
50
  }, function (error) {
@@ -50,6 +54,10 @@ var AxiosRequest = /** @class */ (function () {
50
54
  // 拦截响应
51
55
  AxiosRequest.prototype.interceptorsResponse = function () {
52
56
  var _this = this;
57
+ if (this.otherOptions.interceptorsResponseHandle) {
58
+ this.otherOptions.interceptorsResponseHandle();
59
+ return;
60
+ }
53
61
  axios.interceptors.response.use(function (response) {
54
62
  var _a;
55
63
  // console.log(response);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-utils",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
package/src/request.ts CHANGED
@@ -65,6 +65,10 @@ export class AxiosRequest {
65
65
 
66
66
  // 拦截请求
67
67
  private interceptorsRequest() {
68
+ if (this.otherOptions.interceptorsRequestHandle) {
69
+ this.otherOptions.interceptorsRequestHandle();
70
+ return;
71
+ }
68
72
  axios.interceptors.request.use(
69
73
  (config) => {
70
74
  return config;
@@ -77,6 +81,10 @@ export class AxiosRequest {
77
81
 
78
82
  // 拦截响应
79
83
  private interceptorsResponse() {
84
+ if (this.otherOptions.interceptorsResponseHandle) {
85
+ this.otherOptions.interceptorsResponseHandle();
86
+ return;
87
+ }
80
88
  axios.interceptors.response.use(
81
89
  (response) => {
82
90
  // console.log(response);
@@ -326,4 +334,8 @@ export interface IOtherOptions {
326
334
  isTimeoutConfirm?: boolean;
327
335
  // 超时弹框提示内容
328
336
  isTimeoutConfirmStr?: string;
337
+ // 拦截器自定义
338
+ interceptorsRequestHandle?: () => void;
339
+ // 响应器自定义
340
+ interceptorsResponseHandle?: () => void;
329
341
  }