sh-tools 1.1.2 → 1.2.0

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": "sh-tools",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "description": "基于xe-ajax和xe-utils二次封装",
5
5
  "main": "packages/index.js",
6
6
  "scripts": {
@@ -13,9 +13,9 @@
13
13
  "license": "ISC",
14
14
  "dependencies": {
15
15
  "hot-formula-parser": "^4.0.0",
16
- "view-ui-plus": "^1.3.1",
16
+ "view-ui-plus": "^1.3.14",
17
17
  "xe-ajax": "^4.0.5",
18
- "xe-utils": "^3.5.10"
18
+ "xe-utils": "^3.5.11"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@babel/core": "^7.12.16",
@@ -2,26 +2,19 @@ import XEAjax from 'xe-ajax'
2
2
  import { Notice } from 'view-ui-plus'
3
3
 
4
4
  class HttpRequest {
5
- constructor(options = {}, gateWay = {}) {
5
+ constructor(options = {}) {
6
6
  this.instance = XEAjax
7
7
  this.options = options
8
- this.gateWay = gateWay
9
8
  this.setOptions(options)
10
9
  this.interceptors()
11
10
  }
12
11
  setOptions(options) {
13
12
  this.instance.setup(options)
14
13
  }
15
- #setRequest(request) {
16
- if (this.options && this.options?.setRequest && 'function' == typeof this.options.setRequest) {
17
- this.options.setRequest(request)
18
- }
14
+ setRequest(request) {
19
15
  return request
20
16
  }
21
- #setResponse(response) {
22
- if (this.options && this.options?.setResponse && 'function' == typeof this.options.setResponse) {
23
- this.options.setResponse(response)
24
- }
17
+ setResponse(response) {
25
18
  return response
26
19
  }
27
20
  request(options) {
@@ -52,11 +45,7 @@ class HttpRequest {
52
45
  interceptors() {
53
46
  // 请求拦截
54
47
  this.instance.interceptors.request.use((request, next) => {
55
- if (this.gateWay && this.gateWay[serveName] && !request.origin) {
56
- let serveName = request.url.split('/')[request.url.startsWith('/') ? 1 : 0]
57
- request.origin = this.gateWay[serveName]
58
- }
59
- this.#setRequest(request)
48
+ this.setRequest(request)
60
49
  next()
61
50
  })
62
51
  // 响应拦截
@@ -91,7 +80,7 @@ class HttpRequest {
91
80
  Notice.error({ title: `系统提示 ${status}`, desc: errorMsg, duration: duration })
92
81
  break
93
82
  }
94
- this.#setResponse(resBody)
83
+ this.setResponse(resBody)
95
84
  next({ status: 200, body: resBody })
96
85
  }
97
86
  }