apifm-admin 26.6.2

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 ADDED
@@ -0,0 +1,90 @@
1
+ # apifm-admin
2
+
3
+ API 工厂后台接口 SDK,支持 `Web`、`uni-app`、`微信小程序`。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install apifm-admin
9
+ ```
10
+
11
+ ## 快速开始
12
+
13
+ ```js
14
+ import apifmAdmin from 'apifm-admin'
15
+
16
+ apifmAdmin.setConfig({
17
+ token: '后台登录后的 xtoken'
18
+ })
19
+
20
+ const res = await apifmAdmin.loginAdminMobile({
21
+ mobile: '13800138000',
22
+ pwd: '123456',
23
+ rememberMe: true
24
+ })
25
+ ```
26
+
27
+ ## 跨端请求适配
28
+
29
+ 默认优先使用:
30
+
31
+ 1. `uni.request`
32
+ 2. `wx.request`
33
+ 3. `fetch`
34
+
35
+ 也可以手动注入请求适配器:
36
+
37
+ ```js
38
+ import apifmAdmin from 'apifm-admin'
39
+
40
+ apifmAdmin.setRequestAdapter(async (requestOptions) => {
41
+ const { url, method, data, headers } = requestOptions
42
+ const response = await fetch(url, {
43
+ method,
44
+ headers: {
45
+ 'Content-Type': 'application/x-www-form-urlencoded',
46
+ ...headers
47
+ },
48
+ body: method === 'GET' ? undefined : new URLSearchParams(data).toString()
49
+ })
50
+ return response.json()
51
+ })
52
+ ```
53
+
54
+ ## 全局配置
55
+
56
+ ```js
57
+ apifmAdmin.setConfig({
58
+ token: 'xtoken',
59
+ headers: {
60
+ 'x-token': 'xtoken'
61
+ }
62
+ })
63
+ ```
64
+
65
+ 支持动态修改:
66
+
67
+ ```js
68
+ apifmAdmin.setToken('xtoken')
69
+ apifmAdmin.setHeader('tenant-id', '1001')
70
+ apifmAdmin.setDomain('common', 'https://common.apifm.com')
71
+ ```
72
+
73
+ ## 发布
74
+
75
+ ```bash
76
+ npm publish
77
+ ```
78
+
79
+ 执行发布前会自动运行:
80
+
81
+ ```bash
82
+ npm run build
83
+ ```
84
+
85
+ 该命令会重新扫描以下 Java 项目并生成最新 SDK:
86
+
87
+ - `D:\java\apifmCommon`
88
+ - `D:\java\jd-vop`
89
+ - `D:\java\apifmCms`
90
+ - `D:\java\apifactory`