ol-base-components 2.2.0 → 2.2.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 CHANGED
@@ -59,6 +59,45 @@ import { swaggerUnload } from "ol-base-components";
59
59
  swaggerUnload()
60
60
  ```
61
61
 
62
+ ## API 脚本
63
+
64
+ ### 1. `api.js`
65
+
66
+ `api.js` 脚本用于从指定的 Swagger URL 获取 API 数据,并生成相应的 API 模块文件。
67
+
68
+ #### 使用方法
69
+
70
+ ```bash
71
+ npx api http://192.168.xxx.xxx [outputPath]
72
+ ```
73
+
74
+ - **参数**:
75
+ - `http://192.168.xxx.xxx` 是 Swagger API 的基础 URL。
76
+ - `[outputPath]` 是可选参数,指定生成的文件路径,默认为 `src/api/swagger.js`。
77
+ - **作用**:该脚本会自动生成 Swagger 数据的 API 接口模块,并保存到指定的目录中,且包含JSDoc,方便查看接口入参及类型。
78
+
79
+ #### 效果图
80
+
81
+ ![Local demo](./src/assets/api.png "Local demo")
82
+
83
+ ### 2. `run.js`
84
+
85
+ `run.js` 脚本用于从指定的 Swagger URL 下载 Swagger JSON 文件,并生成相应的 API 模块文件。
86
+
87
+ #### 使用方法
88
+
89
+ ```bash
90
+ npx run http://192.168.xxx.xxx [outputPath]
91
+ ```
92
+
93
+ - **参数**:
94
+ - `http://192.168.xxx.xxx` 是 Swagger API 的基础 URL。
95
+ - `[outputPath]` 是可选参数,指定生成的文件路径,默认为 `src/api/modules`。
96
+ - **作用**:该脚本会从指定的 Swagger URL 下载 Swagger JSON 数据,并生成相应的 API 接口路径文件。
97
+
98
+ #### 效果图
99
+
100
+ ![Local demo](./src/assets/run.png "Local demo")
62
101
 
63
102
  ## 组件示例
64
103
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ol-base-components",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "private": false,
5
5
  "main": "src/package/index.js",
6
6
  "bin": {
@@ -47,7 +47,7 @@
47
47
  "keywords": [
48
48
  "ol-base-components"
49
49
  ],
50
- "description": "二次封装的通用组件库。table,form",
50
+ "description": "二次封装的通用组件库。table,form。核心解决前后端字段联调问题。",
51
51
  "browserslist": [
52
52
  "> 1%",
53
53
  "last 2 versions",
package/src/api/api.js CHANGED
@@ -105,7 +105,7 @@ const generateApiModules = (swagger) => {
105
105
  tags.forEach((tag) => {
106
106
  apiModules[
107
107
  tag.name
108
- ] = `import { get, post, put, del } from "@/api/request/sendRuest"\n`;
108
+ ] = `import { api } from "@/api/request/sendRuest"\n`;
109
109
  });
110
110
 
111
111
  for (const [url, methods] of Object.entries(paths)) {
@@ -188,8 +188,9 @@ const generateApiModules = (swagger) => {
188
188
  method
189
189
  )} = (${functionParams}) => {\n`;
190
190
 
191
- functionDoc += ` return ${MethodEnum[method]}({\n`;
191
+ functionDoc += ` return api({\n`;
192
192
  functionDoc += ` url: \`${url.replace(/{/g, "${")}\`,\n`;
193
+ functionDoc += ` method: "${MethodEnum[method]}",\n`;
193
194
  if (hasQuery) functionDoc += ` params,\n`;
194
195
  if (hasBody) functionDoc += ` data: body,\n`;
195
196
  functionDoc += ` });\n`;
Binary file
Binary file