worsoft-frontend-codegen-local-mcp 0.1.13 → 0.1.15
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/mcp_server.js +82 -23
- package/package.json +1 -1
package/mcp_server.js
CHANGED
|
@@ -5,7 +5,7 @@ const fs = require('fs');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
|
|
7
7
|
const SERVER_NAME = 'worsoft-codegen-local';
|
|
8
|
-
const SERVER_VERSION = '0.1.
|
|
8
|
+
const SERVER_VERSION = '0.1.15';
|
|
9
9
|
const PROTOCOL_VERSION = '2024-11-05';
|
|
10
10
|
const TOOL_NAME = 'worsoft_codegen_local_generate_frontend';
|
|
11
11
|
const TEMPLATE_LIBRARY_ROOT = path.resolve(__dirname, '..', 'template');
|
|
@@ -581,16 +581,16 @@ function normalizeDictType(value) {
|
|
|
581
581
|
return normalized.replace(/^['"`]+|['"`]+$/g, '');
|
|
582
582
|
}
|
|
583
583
|
|
|
584
|
-
function stripDictAnnotation(label) {
|
|
585
|
-
const text = String(label || '').trim();
|
|
586
|
-
if (!text) {
|
|
587
|
-
return '';
|
|
588
|
-
}
|
|
589
|
-
return text
|
|
590
|
-
.replace(/\s*[\(\uFF08][^()\uFF08\uFF09]
|
|
591
|
-
.replace(/\s+/g, ' ')
|
|
592
|
-
.trim();
|
|
593
|
-
}
|
|
584
|
+
function stripDictAnnotation(label) {
|
|
585
|
+
const text = String(label || '').trim();
|
|
586
|
+
if (!text) {
|
|
587
|
+
return '';
|
|
588
|
+
}
|
|
589
|
+
return text
|
|
590
|
+
.replace(/\s*[\(\uFF08][^()\uFF08\uFF09]*[\)\uFF09]\s*/g, ' ')
|
|
591
|
+
.replace(/\s+/g, ' ')
|
|
592
|
+
.trim();
|
|
593
|
+
}
|
|
594
594
|
|
|
595
595
|
function extractDictType(text) {
|
|
596
596
|
const normalized = String(text || '').trim();
|
|
@@ -1304,18 +1304,77 @@ function renderChildResetListLines(children) {
|
|
|
1304
1304
|
return children.map((childModel) => ` form.${childModel.listName} = [];`).join('\n');
|
|
1305
1305
|
}
|
|
1306
1306
|
|
|
1307
|
-
function renderDictImportBlock(dictTypes) {
|
|
1308
|
-
if (!dictTypes.length) return '';
|
|
1309
|
-
return [
|
|
1310
|
-
"import { useDict } from '/@/hooks/dict';",
|
|
1311
|
-
`const { ${dictTypes.join(', ')} } = useDict(${dictTypes.map((item) => `'${item}'`).join(', ')});`,
|
|
1312
|
-
].join('\n');
|
|
1313
|
-
}
|
|
1314
|
-
|
|
1315
|
-
function
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1307
|
+
function renderDictImportBlock(dictTypes) {
|
|
1308
|
+
if (!dictTypes.length) return '';
|
|
1309
|
+
return [
|
|
1310
|
+
"import { useDict } from '/@/hooks/dict';",
|
|
1311
|
+
`const { ${dictTypes.join(', ')} } = useDict(${dictTypes.map((item) => `'${item}'`).join(', ')});`,
|
|
1312
|
+
].join('\n');
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
function normalizeWidthLabel(field) {
|
|
1316
|
+
return stripDictAnnotation(field.comment).replace(/\s+/g, '').trim();
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
function getLabelVisibleLength(label) {
|
|
1320
|
+
return String(label || '').replace(/[()()【】\[\]{}《》::,,、.\-_\s]/g, '').length;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
function matchesAnyLabel(label, values) {
|
|
1324
|
+
return values.some((value) => label === value);
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
function includesAnyLabel(label, values) {
|
|
1328
|
+
return values.some((value) => label.includes(value));
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
function getDefaultOptionFieldWidthV2(field) {
|
|
1332
|
+
const label = normalizeWidthLabel(field);
|
|
1333
|
+
const visibleLength = getLabelVisibleLength(label);
|
|
1334
|
+
|
|
1335
|
+
if (field.formType === 'textarea') return '300';
|
|
1336
|
+
|
|
1337
|
+
if (matchesAnyLabel(label, ['状态', '单据状态'])) return '80';
|
|
1338
|
+
if (label === '项目编号') return '80';
|
|
1339
|
+
if (label === '统一社会信用代码') return '160';
|
|
1340
|
+
if (label === '项目简称') return '200';
|
|
1341
|
+
if (matchesAnyLabel(label, ['国家'])) return '100';
|
|
1342
|
+
if (matchesAnyLabel(label, ['省份', '城市'])) return '120';
|
|
1343
|
+
if (label === '资质使用') return '200';
|
|
1344
|
+
if (label === '规模') return '100';
|
|
1345
|
+
if (matchesAnyLabel(label, ['电话'])) return '100';
|
|
1346
|
+
if (matchesAnyLabel(label, ['物资名称', '作业名称'])) return '150';
|
|
1347
|
+
if (matchesAnyLabel(label, ['规格型号', '计量单位'])) return '80';
|
|
1348
|
+
if (label === '材料特征') return '200';
|
|
1349
|
+
|
|
1350
|
+
if (matchesAnyLabel(label, ['合同编号', '单据编号']) || (label !== '项目编号' && label.endsWith('编码'))) return '200';
|
|
1351
|
+
|
|
1352
|
+
if (matchesAnyLabel(label, [
|
|
1353
|
+
'项目名称',
|
|
1354
|
+
'项目名称合同',
|
|
1355
|
+
'项目名称中文',
|
|
1356
|
+
'招标项目名称',
|
|
1357
|
+
'合同名称',
|
|
1358
|
+
'合同名称合同',
|
|
1359
|
+
'合同名称中文',
|
|
1360
|
+
])) return '350';
|
|
1361
|
+
|
|
1362
|
+
if (matchesAnyLabel(label, ['跟踪单位', '主跟踪人', '组织机构全路径'])) return '200';
|
|
1363
|
+
if (matchesAnyLabel(label, ['业主单位', '监理单位', '设计单位', '分包单位', '供应商名称'])) return '250';
|
|
1364
|
+
if (matchesAnyLabel(label, ['业主简称', '供应商简称'])) return '150';
|
|
1365
|
+
|
|
1366
|
+
if (label.endsWith('人')) return '90';
|
|
1367
|
+
|
|
1368
|
+
if (includesAnyLabel(label, ['金额'])) return '180';
|
|
1369
|
+
if (includesAnyLabel(label, ['数量', '单价', '数额'])) return '140';
|
|
1370
|
+
|
|
1371
|
+
if (field.formType === 'datetime') return '150';
|
|
1372
|
+
if (field.formType === 'date') return visibleLength > 7 ? '170' : '90';
|
|
1373
|
+
|
|
1374
|
+
if (field.formType === 'select') return visibleLength > 5 ? '200' : '100';
|
|
1375
|
+
|
|
1376
|
+
return '100';
|
|
1377
|
+
}
|
|
1319
1378
|
|
|
1320
1379
|
function renderOptionFieldV2(field, labelKey, dictRegistryRefs, indent = ' ') {
|
|
1321
1380
|
const parts = [`key: '${field.attrName}'`, `labelKey: '${labelKey}'`];
|
package/package.json
CHANGED