im-ui-mobile 0.0.60 → 0.0.62

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": "im-ui-mobile",
3
- "version": "0.0.60",
3
+ "version": "0.0.62",
4
4
  "description": "A Vue3.0 + typescript instant messaging component library for Uniapp",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1,6 +1,6 @@
1
1
  /// <reference types="@dcloudio/types" />
2
2
  import type { Response } from '../libs/index';
3
- export default class Requester {
3
+ declare class Requester {
4
4
  private baseURL;
5
5
  private options;
6
6
  private timeout;
@@ -14,3 +14,4 @@ export default class Requester {
14
14
  put<T = any>(url: string, data?: any, options?: Partial<UniApp.RequestOptions>): Promise<Response<T>>;
15
15
  delete<T = any>(url: string, data?: any, options?: Partial<UniApp.RequestOptions>): Promise<Response<T>>;
16
16
  }
17
+ export default Requester;
@@ -1,10 +1,9 @@
1
- class Requester {
1
+ export default class Requester {
2
2
  constructor(baseURL, options = {}) {
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,21 @@ 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
22
  this.options.url = this.baseURL + this.options.url;
23
+ this.options.header = this.header
24
+ this.options.timeout = this.timeout
25
+ this.options = {
26
+ ...options
27
+ };
25
28
 
26
29
  return new Promise((resolve, reject) => {
27
30
  uni.request({
28
- timeout: this.timeout,
29
- header: this.headers,
30
31
  ...this.options,
31
32
  success: (res) => {
32
33
  const data = res.data;
@@ -79,6 +80,4 @@ class Requester {
79
80
  delete(url, data, options) {
80
81
  return this.request({ url, method: 'DELETE', data, ...options });
81
82
  }
82
- }
83
-
84
- export default { Requester }
83
+ }