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.
@@ -1,25 +1,52 @@
1
- import { defineConfig } from 'vite'
2
- import vue from '@vitejs/plugin-vue'
3
- import vueDevTools from 'vite-plugin-vue-devtools'
4
-
5
- export default defineConfig({
6
- plugins: [
7
- vue(),
8
- vueDevTools()
9
- ],
10
- server: {
11
- port: 5173,
12
- open: false,
13
- proxy: {
14
- '/api': {
15
- target: 'http://localhost:3000',
16
- changeOrigin: true,
17
- rewrite: (path) => path.replace(/^\/api/, '/api')
18
- }
19
- }
20
- },
21
- build: {
22
- outDir: 'dist',
23
- sourcemap: false
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");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2server7",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "nodemon --watch src --ext ts --exec \"ts-node src/app.ts\"",