@ningboyz/apis 1.8.19 → 1.8.20

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ningboyz/apis",
3
- "version": "1.8.19",
3
+ "version": "1.8.20",
4
4
  "private": false,
5
5
  "description": "宁波甬政请求库",
6
6
  "author": "nbyt-syq",
@@ -17,7 +17,7 @@
17
17
  "registry": "https://registry.npmjs.org/"
18
18
  },
19
19
  "dependencies": {
20
- "@ningboyz/types": "1.8.19",
20
+ "@ningboyz/types": "1.8.20",
21
21
  "axios": "1.8.4",
22
22
  "lodash": "^4.17.21"
23
23
  },
package/packages/axios.ts CHANGED
@@ -14,19 +14,25 @@ export interface IAxiosConfig {
14
14
  loseTokenState?: () => void;
15
15
  /** 不需要拼接 /gapi 前缀的模块(如 tyc),传 true 时请求地址原样使用 */
16
16
  noPrefix?: boolean;
17
+ NO_PREFIX_API?: string[];
17
18
  }
18
19
 
19
20
  class HttpRequest {
20
21
  private instance: AxiosInstance;
21
22
  private readonly API_PREFIX: string = "/gapi";
22
23
  private readonly JAVA_API_PREFIX: string = "/japi";
23
- private readonly noPrefix: boolean;
24
+ private readonly NO_PREFIX: boolean;
24
25
  private readonly METHOD_GET: string = "GET";
25
26
  private readonly METHOD_POST: string = "POST";
27
+ private readonly NO_PREFIX_API: string[] = ["/core/ping"];
26
28
 
27
29
  private getRequestUrl(url: string) {
28
30
  /** 不需要前缀的模块(如 tyc)直接返回原地址 */
29
- if (this.noPrefix) {
31
+ if (this.NO_PREFIX) {
32
+ return url;
33
+ }
34
+ const flag = this.NO_PREFIX_API.find((i) => i === url);
35
+ if (flag) {
30
36
  return url;
31
37
  }
32
38
  if (url.startsWith(this.API_PREFIX) || url.startsWith(this.JAVA_API_PREFIX)) {
@@ -42,7 +48,7 @@ class HttpRequest {
42
48
 
43
49
  constructor(config: IAxiosConfig) {
44
50
  const { baseURL, timeout = 60000, getUserInfo, interceptorsRequest, interceptorsResponse, loseTokenState, noPrefix = false } = config;
45
- this.noPrefix = noPrefix;
51
+ this.NO_PREFIX = noPrefix;
46
52
  this.instance = axios.create({
47
53
  baseURL,
48
54
  timeout