vue2server7 2.3.0 → 2.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2server7",
3
- "version": "2.3.0",
3
+ "version": "2.3.2",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "nodemon --watch src --ext ts --exec \"ts-node src/app.ts\"",
@@ -2,7 +2,7 @@ const fs = require("fs");
2
2
 
3
3
  const content = fs.readFileSync("input.txt", "utf8");
4
4
 
5
- // Java → TS 类型映射
5
+ // Java → TS 类型
6
6
  function javaToTsType(javaType) {
7
7
  const map = {
8
8
  String: "string",
@@ -19,7 +19,7 @@ function javaToTsType(javaType) {
19
19
  return map[javaType] || "any";
20
20
  }
21
21
 
22
- // 根据 TS 类型生成默认值
22
+ // 默认值
23
23
  function defaultValue(tsType) {
24
24
  switch (tsType) {
25
25
  case "string":
@@ -33,7 +33,6 @@ function defaultValue(tsType) {
33
33
  }
34
34
  }
35
35
 
36
- // 匹配注解 + 字段
37
36
  const regex =
38
37
  /@ApiModelProperty\s*\(\s*value\s*=\s*"([^"]+)"[^)]*\)\s*[\r\n]+\s*private\s+(\w+)\s+(\w+)\s*;/g;
39
38
 
@@ -51,30 +50,26 @@ while ((match = regex.exec(content)) !== null) {
51
50
  const tsType = javaToTsType(javaType);
52
51
 
53
52
  // JSON
54
- jsonResult.push({
55
- field,
56
- label
57
- });
53
+ jsonResult.push({ field, label });
58
54
 
59
55
  // TS
60
56
  tsFields.push(` /** ${label} */\n ${field}: ${tsType};`);
61
57
 
62
- // JS 表单对象
63
- formFields.push(` ${field}: ${defaultValue(tsType)}`);
58
+ // JS 表单对象(带注释)
59
+ formFields.push(` /** ${label} */\n ${field}: ${defaultValue(tsType)}`);
64
60
  }
65
61
 
66
- // 写 JSON
62
+ // 写文件
67
63
  fs.writeFileSync("output.json", JSON.stringify(jsonResult, null, 2));
68
64
 
69
- // 写 TS
70
- const tsContent = `export interface Model {\n${tsFields.join("\n\n")}\n}\n`;
71
- fs.writeFileSync("model.ts", tsContent);
65
+ fs.writeFileSync(
66
+ "model.ts",
67
+ `export interface Model {\n${tsFields.join("\n\n")}\n}\n`
68
+ );
72
69
 
73
- // 写 JS 表单对象
74
- const formContent = `export const formModel = {\n${formFields.join(",\n")}\n};\n`;
75
- fs.writeFileSync("form.js", formContent);
70
+ fs.writeFileSync(
71
+ "form.js",
72
+ `export const formModel = {\n${formFields.join(",\n\n")}\n};\n`
73
+ );
76
74
 
77
- console.log("✅ 已生成:");
78
- console.log(" - output.json");
79
- console.log(" - model.ts");
80
- console.log(" - form.js");
75
+ console.log("✅ 已生成 output.json / model.ts / form.js");
Binary file