zmdms-utils 0.0.71 → 0.0.72

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.
@@ -14,6 +14,7 @@ declare class AxiosRequest {
14
14
  private messageWarning?;
15
15
  private modalConfirm?;
16
16
  private instanceAxios;
17
+ private tokenKey;
17
18
  constructor(otherOptions: IOtherOptions);
18
19
  private defaultSetting;
19
20
  private interceptorsRequest;
@@ -64,6 +65,8 @@ interface IOtherOptions {
64
65
  commonHeaders?: {
65
66
  [prop: string]: any;
66
67
  };
68
+ /** 请求认证TOKEN KEY */
69
+ tokenKey?: string;
67
70
  /** 超时时间 */
68
71
  timeout?: number;
69
72
  /** 基础url */
@@ -20,9 +20,12 @@ var AxiosRequest = /** @class */ (function () {
20
20
  this.isTimeout = false;
21
21
  // axios单例
22
22
  this.instanceAxios = axios.create();
23
- var crypto = otherOptions.crypto, jumpCallback = otherOptions.jumpCallback, isTimeoutConfirm = otherOptions.isTimeoutConfirm, isTimeoutConfirmStr = otherOptions.isTimeoutConfirmStr, messageWarning = otherOptions.messageWarning, modalConfirm = otherOptions.modalConfirm, resetOtherOptions = __rest(otherOptions, ["crypto", "jumpCallback", "isTimeoutConfirm", "isTimeoutConfirmStr", "messageWarning", "modalConfirm"]);
23
+ // tokenKey
24
+ this.tokenKey = TOKEN_KEY;
25
+ var crypto = otherOptions.crypto, jumpCallback = otherOptions.jumpCallback, isTimeoutConfirm = otherOptions.isTimeoutConfirm, isTimeoutConfirmStr = otherOptions.isTimeoutConfirmStr, messageWarning = otherOptions.messageWarning, modalConfirm = otherOptions.modalConfirm, tokenKey = otherOptions.tokenKey, resetOtherOptions = __rest(otherOptions, ["crypto", "jumpCallback", "isTimeoutConfirm", "isTimeoutConfirmStr", "messageWarning", "modalConfirm", "tokenKey"]);
24
26
  this.otherOptions = __assign(__assign({}, defaultOptions), resetOtherOptions);
25
27
  this.crypto = crypto;
28
+ this.tokenKey = tokenKey || TOKEN_KEY;
26
29
  this.isTimeoutConfirm = isTimeoutConfirm;
27
30
  this.isTimeoutConfirmStr = isTimeoutConfirmStr;
28
31
  this.jumpCallback = jumpCallback;
@@ -226,7 +229,7 @@ var AxiosRequest = /** @class */ (function () {
226
229
  }
227
230
  if (isAuth) {
228
231
  var token = getToken();
229
- newOptions.headers[TOKEN_KEY] = "bearer ".concat(token);
232
+ newOptions.headers[this.tokenKey] = "bearer ".concat(token);
230
233
  }
231
234
  // 遍历params,将undefined值 转为null值
232
235
  if (newOptions.data) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-utils",
3
- "version": "0.0.71",
3
+ "version": "0.0.72",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
package/src/request.ts CHANGED
@@ -36,6 +36,8 @@ export class AxiosRequest {
36
36
  private modalConfirm?: IOtherOptions["modalConfirm"];
37
37
  // axios单例
38
38
  private instanceAxios: AxiosInstance = axios.create();
39
+ // tokenKey
40
+ private tokenKey: string = TOKEN_KEY;
39
41
 
40
42
  constructor(otherOptions: IOtherOptions) {
41
43
  const {
@@ -45,10 +47,12 @@ export class AxiosRequest {
45
47
  isTimeoutConfirmStr,
46
48
  messageWarning,
47
49
  modalConfirm,
50
+ tokenKey,
48
51
  ...resetOtherOptions
49
52
  } = otherOptions;
50
53
  this.otherOptions = { ...defaultOptions, ...resetOtherOptions };
51
54
  this.crypto = crypto;
55
+ this.tokenKey = tokenKey || TOKEN_KEY;
52
56
  this.isTimeoutConfirm = isTimeoutConfirm;
53
57
  this.isTimeoutConfirmStr = isTimeoutConfirmStr;
54
58
  this.jumpCallback = jumpCallback;
@@ -275,7 +279,7 @@ export class AxiosRequest {
275
279
  }
276
280
  if (isAuth) {
277
281
  const token = getToken();
278
- newOptions.headers[TOKEN_KEY] = `bearer ${token}`;
282
+ newOptions.headers[this.tokenKey] = `bearer ${token}`;
279
283
  }
280
284
 
281
285
  // 遍历params,将undefined值 转为null值
@@ -408,6 +412,8 @@ export interface IOtherOptions {
408
412
  Authorization?: string;
409
413
  /** 公用请求头 */
410
414
  commonHeaders?: { [prop: string]: any };
415
+ /** 请求认证TOKEN KEY */
416
+ tokenKey?: string;
411
417
  /** 超时时间 */
412
418
  timeout?: number;
413
419
  /** 基础url */