zmdms-utils 0.0.7 → 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.
@@ -1,6 +1,6 @@
1
1
  declare function getBaseUrl(processObj: any): {
2
- api: any;
3
- file: any;
2
+ API_URL: any;
3
+ FILE_URL: any;
4
4
  };
5
5
 
6
6
  export { getBaseUrl };
@@ -17,8 +17,8 @@ function getBaseUrl(processObj) {
17
17
  };
18
18
  var currentKey = ENV.toLowerCase() || "dev";
19
19
  return {
20
- api: apiBaseUrlObj[currentKey],
21
- file: fileBaseUrlObj[currentKey],
20
+ API_URL: apiBaseUrlObj[currentKey],
21
+ FILE_URL: fileBaseUrlObj[currentKey],
22
22
  };
23
23
  }
24
24
 
@@ -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,9 +54,13 @@ 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
- console.log(response);
63
+ // console.log(response);
56
64
  // 对返回数据进行解密后 返回给客户端
57
65
  if ((_a = response.config) === null || _a === void 0 ? void 0 : _a.isCrypto) ;
58
66
  return response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-utils",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
package/src/baseUrl.ts CHANGED
@@ -22,7 +22,7 @@ export function getBaseUrl(processObj: any) {
22
22
  const currentKey = ENV.toLowerCase() || "dev";
23
23
 
24
24
  return {
25
- api: apiBaseUrlObj[currentKey],
26
- file: fileBaseUrlObj[currentKey],
25
+ API_URL: apiBaseUrlObj[currentKey],
26
+ FILE_URL: fileBaseUrlObj[currentKey],
27
27
  };
28
28
  }
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,9 +81,13 @@ 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
- console.log(response);
90
+ // console.log(response);
83
91
  // 对返回数据进行解密后 返回给客户端
84
92
  if ((response.config as any)?.isCrypto) {
85
93
  }
@@ -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
  }