@polyv/request-plugin-global-params 2.7.1 → 2.8.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/README.md CHANGED
@@ -4,15 +4,15 @@
4
4
 
5
5
  ## 实例化参数
6
6
 
7
- | 参数名 | 用途 | 类型 | 默认值 |
8
- | - | - | - | - |
9
- | `useGlobalParams` | 是否使用全局 params 参数 | `boolean` | `true` |
10
- | `globalParams` | 全局参数 | `object \| function` | - |
7
+ | 参数名 | 用途 | 类型 | 默认值 |
8
+ | ----------------- | ------------------------ | -------------------- | ------ |
9
+ | `useGlobalParams` | 是否使用全局 params 参数 | `boolean` | `true` |
10
+ | `globalParams` | 全局参数 | `object \| function` | - |
11
11
 
12
12
  ## 请求选项
13
13
 
14
- | 参数名 | 用途 | 类型 | 默认值 |
15
- | - | - | - | - |
14
+ | 参数名 | 用途 | 类型 | 默认值 |
15
+ | ----------------- | ------------------------ | --------- | ------ |
16
16
  | `useGlobalParams` | 是否使用全局 params 参数 | `boolean` | `true` |
17
17
 
18
18
  ## 使用方式
@@ -30,25 +30,29 @@ const requester = new PolyvRequest({
30
30
  channelId: 'xxx',
31
31
  },
32
32
  }),
33
- ]
33
+ ],
34
34
  });
35
35
 
36
36
  // 传入方法,支持返回 Promise
37
37
  const requester = new PolyvRequest({
38
38
  requestPlugins: [
39
39
  new GlobalParamsRequestPlugin({
40
- globalParams: async (options) => {
40
+ globalParams: async options => {
41
41
  return {
42
42
  viewerId: 'xxx',
43
43
  channelId: 'xxx',
44
44
  };
45
45
  },
46
46
  }),
47
- ]
47
+ ],
48
48
  });
49
49
 
50
50
  // 如果你想在某个请求中,不带全局参数时
51
- requester.get('/xxxx', {}, {
52
- useGlobalParams: false,
53
- });
51
+ requester.get(
52
+ '/xxxx',
53
+ {},
54
+ {
55
+ useGlobalParams: false,
56
+ },
57
+ );
54
58
  ```
@@ -1,5 +1,5 @@
1
1
  import type { RequestOptions, RequestPlugin } from '@polyv/request-core';
2
- import { GlobalParamsRequestPluginConfig } from './types';
2
+ import type { GlobalParamsRequestPluginConfig } from './types';
3
3
  export * from './types';
4
4
  /**
5
5
  * 全局 params 参数请求插件
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@polyv/request-plugin-global-params",
3
- "version": "2.7.1",
3
+ "version": "2.8.0",
4
4
  "main": "./index.js",
5
5
  "dependencies": {
6
- "@polyv/request-core": "2.7.1"
6
+ "@polyv/request-core": "2.8.0"
7
7
  },
8
- "types": "./index.d.ts"
8
+ "types": "./index.d.ts",
9
+ "type": "module",
10
+ "miniprogram": "./"
9
11
  }
package/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { RequestOptions, UniversalParams } from '@polyv/request-core';
1
+ import type { RequestOptions, UniversalParams } from '@polyv/request-core';
2
2
  export interface GlobalParamsRequestPluginConfig<Options extends RequestOptions = RequestOptions> {
3
3
  /**
4
4
  * 是否使用全局 params 参数