ol-base-components 2.7.1 → 2.7.3
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/.prettierrc +2 -3
- package/package.json +1 -1
- package/src/api/run.js +6 -0
- package/src/bin/add.js +19 -7
- package/src/bin/initTemplate.js +12 -13
- package/src/utils/initData.js +7 -3
package/.prettierrc
CHANGED
|
@@ -6,9 +6,8 @@
|
|
|
6
6
|
"trailingComma": "es5",
|
|
7
7
|
"bracketSpacing": true,
|
|
8
8
|
"arrowParens": "avoid",
|
|
9
|
-
"endOfLine": "
|
|
9
|
+
"endOfLine": "crlf",
|
|
10
10
|
"vueIndentScriptAndStyle": true,
|
|
11
11
|
"htmlWhitespaceSensitivity": "css",
|
|
12
|
-
"singleAttributePerLine": false
|
|
13
|
-
"trimTrailingWhitespace": true
|
|
12
|
+
"singleAttributePerLine": false
|
|
14
13
|
}
|
package/package.json
CHANGED
package/src/api/run.js
CHANGED
|
@@ -122,6 +122,12 @@ const generateApiModules = swagger => {
|
|
|
122
122
|
if (apiModules[tag]) {
|
|
123
123
|
const summary = details.summary || "";
|
|
124
124
|
apiModules[tag][key] = `${key}: "${removeCurlyBraces(url)}", //${method} ${summary}\n`;
|
|
125
|
+
// 不去出带花括号的,键名加上特殊字段
|
|
126
|
+
if (url.includes("{")) {
|
|
127
|
+
apiModules[tag][
|
|
128
|
+
`${key}CompleteUrl`
|
|
129
|
+
] = `${key}CompleteUrl: "${url}", //${method} ${summary}\n`;
|
|
130
|
+
}
|
|
125
131
|
}
|
|
126
132
|
});
|
|
127
133
|
}
|
package/src/bin/add.js
CHANGED
|
@@ -51,7 +51,7 @@ try {
|
|
|
51
51
|
type: "input",
|
|
52
52
|
name: "pageUrl",
|
|
53
53
|
message: "请输入分页接口地址(必填):",
|
|
54
|
-
default: "/api/app/admission-info/
|
|
54
|
+
default: "/api/app/admission-info/paged-result",
|
|
55
55
|
validate: input => {
|
|
56
56
|
if (!input.trim()) {
|
|
57
57
|
return "分页接口地址不能为空";
|
|
@@ -106,6 +106,7 @@ try {
|
|
|
106
106
|
},
|
|
107
107
|
]);
|
|
108
108
|
|
|
109
|
+
let baseUrl = "";
|
|
109
110
|
let idField = "id";
|
|
110
111
|
let addUrl = "";
|
|
111
112
|
let editUrl = "";
|
|
@@ -114,12 +115,22 @@ try {
|
|
|
114
115
|
|
|
115
116
|
// 如果有新增/编辑/删除/详情功能,直接使用分页接口地址
|
|
116
117
|
if (operationsAnswer.operations.length > 0) {
|
|
117
|
-
//
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
// baseUrl
|
|
119
|
+
const baseUrlAnswer = await inquirer.prompt([
|
|
120
|
+
{
|
|
121
|
+
type: "input",
|
|
122
|
+
name: "baseUrl",
|
|
123
|
+
message: "请输入操作接口的基础路径:",
|
|
124
|
+
default: "/api/app/admission-info/admission-info",
|
|
125
|
+
validate: input => {
|
|
126
|
+
if (!input.trim()) {
|
|
127
|
+
return "操作接口的基础路径不能为空";
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
]);
|
|
133
|
+
baseUrl = baseUrlAnswer.baseUrl;
|
|
123
134
|
|
|
124
135
|
// 询问ID字段名
|
|
125
136
|
const idFieldAnswer = await inquirer.prompt([
|
|
@@ -191,6 +202,7 @@ try {
|
|
|
191
202
|
pageUrl: pageUrlAnswer.pageUrl,
|
|
192
203
|
hasExport: exportAnswer.hasExport,
|
|
193
204
|
exportUrl: exportUrl,
|
|
205
|
+
baseUrl,
|
|
194
206
|
hasAdd: operationsAnswer.operations.includes("add"),
|
|
195
207
|
addUrl: addUrl,
|
|
196
208
|
hasEdit: operationsAnswer.operations.includes("edit"),
|
package/src/bin/initTemplate.js
CHANGED
|
@@ -32,25 +32,26 @@ const vue2Template = (moduleName, config = {}) => {
|
|
|
32
32
|
console.log(888, config);
|
|
33
33
|
|
|
34
34
|
// 生成各种接口的key名称
|
|
35
|
-
let pageUrlKey = ""
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
let pageUrlKey = "",
|
|
36
|
+
exportUrlKey = "",
|
|
37
|
+
addUrlKey = "",
|
|
38
|
+
editUrlKey = "",
|
|
39
|
+
deleteUrlKey = "",
|
|
40
|
+
detailUrlKey = "",
|
|
41
|
+
baseUrlKey = ""; //接口选择优先级:新增 > 编辑 > 详,
|
|
41
42
|
|
|
42
43
|
if (config.pageUrl) pageUrlKey = generateKeyName(config.pageUrl, "get");
|
|
43
44
|
if (config.exportUrl) exportUrlKey = generateKeyName(config.exportUrl, "post");
|
|
44
|
-
if (config.
|
|
45
|
-
if (config.editUrl) editUrlKey = generateKeyName(config.editUrl, "put");
|
|
45
|
+
if (config.detailUrl) baseUrlKey = detailUrlKey = generateKeyName(config.detailUrl, "get");
|
|
46
|
+
if (config.editUrl) baseUrlKey = editUrlKey = generateKeyName(config.editUrl, "put");
|
|
47
|
+
if (config.addUrl) baseUrlKey = addUrlKey = generateKeyName(config.addUrl, "post");
|
|
46
48
|
if (config.deleteUrl) deleteUrlKey = generateKeyName(config.deleteUrl, "delete");
|
|
47
|
-
if (config.detailUrl) detailUrlKey = generateKeyName(config.detailUrl, "get");
|
|
48
49
|
|
|
49
50
|
// 生成导入语句
|
|
50
51
|
const generateImports = () => {
|
|
51
52
|
const imports = [];
|
|
52
53
|
if (config.pageUrl) imports.push(`${pageUrlKey}`);
|
|
53
|
-
if (config.addUrl) imports.push(`${addUrlKey}`);
|
|
54
|
+
if (config.addUrl || config.baseUrl) imports.push(`${addUrlKey}`);
|
|
54
55
|
if (config.editUrl) imports.push(`${editUrlKey}`);
|
|
55
56
|
if (config.deleteUrl) imports.push(`${deleteUrlKey}`);
|
|
56
57
|
if (config.detailUrl) imports.push(`${detailUrlKey}`);
|
|
@@ -103,8 +104,6 @@ const vue2Template = (moduleName, config = {}) => {
|
|
|
103
104
|
|
|
104
105
|
// onSubmit
|
|
105
106
|
if (config.hasAdd || config.hasEdit) {
|
|
106
|
-
// editUrlKey
|
|
107
|
-
// addUrlKey
|
|
108
107
|
methods.push(`
|
|
109
108
|
async onSubmit({ form, data }) {
|
|
110
109
|
if(form.type === 1){
|
|
@@ -178,7 +177,7 @@ const vue2Template = (moduleName, config = {}) => {
|
|
|
178
177
|
? `<el-dialog :title="this.form.title" :visible.sync="dialogVisible" width="80%">
|
|
179
178
|
<ol-form
|
|
180
179
|
v-if="dialogVisible"
|
|
181
|
-
:url="swaggerUrl.${
|
|
180
|
+
:url="swaggerUrl.${baseUrlKey}"
|
|
182
181
|
:form="form"
|
|
183
182
|
@onCancel="onCancel"
|
|
184
183
|
@onSubmit="onSubmit"
|
package/src/utils/initData.js
CHANGED
|
@@ -29,11 +29,15 @@ const javaTypeToformType = javaType => {
|
|
|
29
29
|
export const initForm = options => {
|
|
30
30
|
const { url, form } = options;
|
|
31
31
|
getData().then(swaggerData => {
|
|
32
|
-
|
|
32
|
+
// swagger数据可以来源于,新增接口/编辑接口/详情接口(优先级:新增接口>编辑接口>详情接口)
|
|
33
|
+
let entity = {},
|
|
34
|
+
schema = {},
|
|
35
|
+
properties = {};
|
|
36
|
+
entity = swaggerData.paths[url].post;
|
|
33
37
|
// 添加title
|
|
34
38
|
// if (!form.title) form.title = entity.summary;
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
schema = entity.requestBody.content["application/json"].schema;
|
|
40
|
+
properties = schema.properties;
|
|
37
41
|
// 生成model
|
|
38
42
|
// 1.循环model,将properties中prop相同的匹配,属性合并,model权限大,properties权限小,且保持响应式
|
|
39
43
|
form.model.forEach(item => {
|