@jetlinks-web/core 2.1.4 → 2.1.5

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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/axios.ts +8 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetlinks-web/core",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
4
  "main": "index.ts",
5
5
  "module": "index.ts",
6
6
  "keywords": [
@@ -21,9 +21,9 @@
21
21
  "dependencies": {
22
22
  "axios": "^1.7.4",
23
23
  "rxjs": "^7.8.1",
24
- "@jetlinks-web/types": "^1.0.2",
25
- "@jetlinks-web/constants": "^1.0.8",
26
- "@jetlinks-web/utils": "^1.2.8"
24
+ "@jetlinks-web/constants": "^1.0.9",
25
+ "@jetlinks-web/utils": "^1.2.8",
26
+ "@jetlinks-web/types": "^1.0.2"
27
27
  },
28
28
  "publishConfig": {
29
29
  "registry": "https://registry.npmjs.org/",
package/src/axios.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { TOKEN_KEY, BASE_API } from '@jetlinks-web/constants'
1
+ import { TOKEN_KEY, BASE_API, LOCAL_BASE_API } from '@jetlinks-web/constants'
2
2
  import { getToken } from '@jetlinks-web/utils'
3
3
  import axios from 'axios'
4
4
  import type {
@@ -66,11 +66,17 @@ const controller = new AbortController();
66
66
  const handleRequest = (config: InternalAxiosRequestConfig) => {
67
67
  const token = getToken()
68
68
  const lang = localStorage.getItem(_options.langKey)
69
+ const env = localStorage.getItem(LOCAL_BASE_API)
69
70
 
70
71
  if (lang) {
71
72
  config.headers[_options.langKey] = lang
72
73
  }
73
74
 
75
+ if (!config.url.startsWith(env)) {
76
+ const _url = config.url.startsWith('/') ? config.url : `/${config.url}`
77
+ config.url = env + _url
78
+ }
79
+
74
80
  // 没有token,并且该接口需要token校验
75
81
  if (!token && !_options.filter_url?.some((url) => config.url?.includes(url))) {
76
82
  // 跳转登录页
@@ -258,7 +264,7 @@ export class Request {
258
264
  * @param {object} options 请求配置
259
265
  * @returns {Promise<AxiosResponse<any>>} 不分页查询结果
260
266
  */
261
- noPage(data?: any={}, options: RequestOptions = {
267
+ noPage(data: any={}, options: RequestOptions = {
262
268
  url: undefined,
263
269
  method: undefined,
264
270
  }) {