zmdms-utils 0.0.32 → 0.0.33

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,4 +1,4 @@
1
- import { AxiosResponse, AxiosRequestConfig } from 'axios';
1
+ import { AxiosResponse, AxiosRequestConfig, InternalAxiosRequestConfig } from 'axios';
2
2
  import { Crypto } from './crypto.js';
3
3
 
4
4
  declare class AxiosRequest {
@@ -63,6 +63,7 @@ interface IOtherOptions {
63
63
  isTimeoutConfirmStr?: string;
64
64
  /** 拦截器自定义 */
65
65
  interceptorsRequestHandle?: () => void;
66
+ interceptorsRequestConfig?: (config: InternalAxiosRequestConfig<any>) => InternalAxiosRequestConfig<any>;
66
67
  /** 响应器自定义 */
67
68
  interceptorsResponseHandle?: () => void;
68
69
  }
@@ -42,11 +42,15 @@ var AxiosRequest = /** @class */ (function () {
42
42
  };
43
43
  // 拦截请求
44
44
  AxiosRequest.prototype.interceptorsRequest = function () {
45
+ var _this = this;
45
46
  if (this.otherOptions.interceptorsRequestHandle) {
46
47
  this.otherOptions.interceptorsRequestHandle();
47
48
  return;
48
49
  }
49
50
  axios.interceptors.request.use(function (config) {
51
+ if (_this.otherOptions.interceptorsRequestConfig) {
52
+ return _this.otherOptions.interceptorsRequestConfig(config);
53
+ }
50
54
  return config;
51
55
  }, function (error) {
52
56
  return Promise.reject(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-utils",
3
- "version": "0.0.32",
3
+ "version": "0.0.33",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
package/src/request.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  // 请求方法
2
- import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
2
+ import axios, {
3
+ AxiosRequestConfig,
4
+ AxiosResponse,
5
+ InternalAxiosRequestConfig,
6
+ } from "axios";
3
7
  import { getToken, removeToken } from "./auth";
4
8
  import { Crypto } from "./crypto";
5
9
  import { TOKEN_KEY } from "./constants";
@@ -72,6 +76,9 @@ export class AxiosRequest {
72
76
  }
73
77
  axios.interceptors.request.use(
74
78
  (config) => {
79
+ if (this.otherOptions.interceptorsRequestConfig) {
80
+ return this.otherOptions.interceptorsRequestConfig(config);
81
+ }
75
82
  return config;
76
83
  },
77
84
  (error) => {
@@ -381,6 +388,9 @@ export interface IOtherOptions {
381
388
  isTimeoutConfirmStr?: string;
382
389
  /** 拦截器自定义 */
383
390
  interceptorsRequestHandle?: () => void;
391
+ interceptorsRequestConfig?: (
392
+ config: InternalAxiosRequestConfig<any>
393
+ ) => InternalAxiosRequestConfig<any>;
384
394
  /** 响应器自定义 */
385
395
  interceptorsResponseHandle?: () => void;
386
396
  }