im-ui-mobile 0.0.61 → 0.0.63

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 +1 -1
  2. package/utils/requester.js +12 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "im-ui-mobile",
3
- "version": "0.0.61",
3
+ "version": "0.0.63",
4
4
  "description": "A Vue3.0 + typescript instant messaging component library for Uniapp",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -3,8 +3,7 @@ export default class Requester {
3
3
  this.baseURL = baseURL;
4
4
  this.options = options;
5
5
  this.timeout = options.timeout || 10000;
6
- // this.accessToken = getToken();
7
- this.headers = {
6
+ this.header = {
8
7
  'Content-Type': 'application/json',
9
8
  // 'Authorization': `Bearer ${this.accessToken}`,
10
9
  // 'AccessToken': this.accessToken,
@@ -14,19 +13,24 @@ export default class Requester {
14
13
 
15
14
  // 设置 token
16
15
  setToken(token) {
17
- this.headers['Authorization'] = `Bearer ${token}`;
18
- this.headers['AccessToken'] = token;
16
+ this.header['Authorization'] = `Bearer ${token}`;
17
+ this.header['AccessToken'] = token;
19
18
  }
20
19
 
21
20
  // 基础请求方法
22
21
  async request(options) {
23
- this.options = { ...this.options, ...options };
24
- this.options.url = this.baseURL + this.options.url;
25
-
22
+ this.options = {
23
+ ...this.options,
24
+ ...options
25
+ };
26
+ this.header = {
27
+ ...options.header
28
+ };
26
29
  return new Promise((resolve, reject) => {
27
30
  uni.request({
31
+ header: this.header,
28
32
  timeout: this.timeout,
29
- header: this.headers,
33
+ url: this.baseURL + this.options.url,
30
34
  ...this.options,
31
35
  success: (res) => {
32
36
  const data = res.data;