zmdms-utils 0.0.32 → 0.0.34

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,5 +1,6 @@
1
1
  declare function getBaseUrl(processObj: any): {
2
2
  API_URL: any;
3
+ CICOMS_API_URL: any;
3
4
  FILE_URL: any;
4
5
  };
5
6
 
@@ -8,6 +8,13 @@ function getBaseUrl(processObj) {
8
8
  stage: processObj.REACT_APP_API_STAGE || window.location.origin,
9
9
  product: processObj.REACT_APP_API_PRODUCT || window.location.origin,
10
10
  };
11
+ // 数字中心各个环境地址
12
+ var cicomsApiBaseUrlObj = {
13
+ dev: processObj.REACT_APP_CICOMS_API_DEV || "http://10.100.234.36:8082",
14
+ test: processObj.REACT_APP_CICOMS_API_TEST || "http://10.100.234.36:8082",
15
+ stage: processObj.REACT_APP_CICOMS_API_STAGE || window.location.origin,
16
+ product: processObj.REACT_APP_CICOMS_API_PRODUCT || window.location.origin,
17
+ };
11
18
  // file 服务器
12
19
  var fileBaseUrlObj = {
13
20
  dev: processObj.REACT_APP_FILE_DEV || "http://192.168.0.134:89",
@@ -18,6 +25,7 @@ function getBaseUrl(processObj) {
18
25
  var currentKey = ENV.toLowerCase() || "dev";
19
26
  return {
20
27
  API_URL: apiBaseUrlObj[currentKey],
28
+ CICOMS_API_URL: cicomsApiBaseUrlObj[currentKey],
21
29
  FILE_URL: fileBaseUrlObj[currentKey],
22
30
  };
23
31
  }
@@ -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.34",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
package/src/baseUrl.ts CHANGED
@@ -10,6 +10,14 @@ export function getBaseUrl(processObj: any) {
10
10
  product: processObj.REACT_APP_API_PRODUCT || window.location.origin,
11
11
  };
12
12
 
13
+ // 数字中心各个环境地址
14
+ const cicomsApiBaseUrlObj: any = {
15
+ dev: processObj.REACT_APP_CICOMS_API_DEV || "http://10.100.234.36:8082",
16
+ test: processObj.REACT_APP_CICOMS_API_TEST || "http://10.100.234.36:8082",
17
+ stage: processObj.REACT_APP_CICOMS_API_STAGE || window.location.origin,
18
+ product: processObj.REACT_APP_CICOMS_API_PRODUCT || window.location.origin,
19
+ };
20
+
13
21
  // file 服务器
14
22
  const fileBaseUrlObj: any = {
15
23
  dev: processObj.REACT_APP_FILE_DEV || "http://192.168.0.134:89",
@@ -23,6 +31,7 @@ export function getBaseUrl(processObj: any) {
23
31
 
24
32
  return {
25
33
  API_URL: apiBaseUrlObj[currentKey],
34
+ CICOMS_API_URL: cicomsApiBaseUrlObj[currentKey],
26
35
  FILE_URL: fileBaseUrlObj[currentKey],
27
36
  };
28
37
  }
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
  }