vue2server7 2.1.0 → 2.2.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/frontEnd/vite.config.js +52 -25
- package/package.json +1 -1
package/frontEnd/vite.config.js
CHANGED
|
@@ -1,25 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
|
|
3
|
+
const content = fs.readFileSync("input.txt", "utf8");
|
|
4
|
+
|
|
5
|
+
// Java 类型 → TS 类型映射
|
|
6
|
+
function javaToTsType(javaType) {
|
|
7
|
+
const map = {
|
|
8
|
+
String: "string",
|
|
9
|
+
Integer: "number",
|
|
10
|
+
Long: "number",
|
|
11
|
+
Double: "number",
|
|
12
|
+
Float: "number",
|
|
13
|
+
BigDecimal: "number",
|
|
14
|
+
Boolean: "boolean",
|
|
15
|
+
Date: "string",
|
|
16
|
+
LocalDate: "string",
|
|
17
|
+
LocalDateTime: "string"
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return map[javaType] || "any";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// 正则匹配 注解 + 字段
|
|
24
|
+
const regex =
|
|
25
|
+
/@ApiModelProperty\s*\(\s*value\s*=\s*"([^"]+)"[^)]*\)\s*[\r\n]+\s*private\s+(\w+)\s+(\w+)\s*;/g;
|
|
26
|
+
|
|
27
|
+
let match;
|
|
28
|
+
const jsonResult = [];
|
|
29
|
+
const tsFields = [];
|
|
30
|
+
|
|
31
|
+
while ((match = regex.exec(content)) !== null) {
|
|
32
|
+
const label = match[1]; // 中文
|
|
33
|
+
const javaType = match[2]; // Java类型
|
|
34
|
+
const field = match[3]; // 字段名
|
|
35
|
+
const tsType = javaToTsType(javaType);
|
|
36
|
+
|
|
37
|
+
jsonResult.push({
|
|
38
|
+
field,
|
|
39
|
+
label
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
tsFields.push(` /** ${label} */\n ${field}: ${tsType};`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 输出 JSON 文件
|
|
46
|
+
fs.writeFileSync("output.json", JSON.stringify(jsonResult, null, 2));
|
|
47
|
+
|
|
48
|
+
// 输出 TS 文件
|
|
49
|
+
const tsContent = `export interface Model {\n${tsFields.join("\n\n")}\n}\n`;
|
|
50
|
+
fs.writeFileSync("model.ts", tsContent);
|
|
51
|
+
|
|
52
|
+
console.log("✅ 已生成 output.json 和 model.ts");
|