worsoft-frontend-codegen-local-mcp 0.1.6 → 0.1.7
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 +20 -9
- 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.7';
|
|
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');
|
|
@@ -339,7 +339,7 @@ function buildChildSectionTitleKey(model, childModel) {
|
|
|
339
339
|
function buildLocaleLeaf(model) {
|
|
340
340
|
const leaf = {
|
|
341
341
|
title: model.tableComment,
|
|
342
|
-
fields: Object.fromEntries(model.visibleFields.map((field) => [field.attrName, field.comment])),
|
|
342
|
+
fields: Object.fromEntries(model.visibleFields.map((field) => [field.attrName, stripDictAnnotation(field.comment)])),
|
|
343
343
|
placeholders: {
|
|
344
344
|
input: '请输入{label}',
|
|
345
345
|
select: '请选择{label}',
|
|
@@ -368,7 +368,7 @@ function buildLocaleLeaf(model) {
|
|
|
368
368
|
childModel.listName,
|
|
369
369
|
{
|
|
370
370
|
title: childModel.tableComment,
|
|
371
|
-
fields: Object.fromEntries(childModel.visibleFields.map((field) => [field.attrName, field.comment])),
|
|
371
|
+
fields: Object.fromEntries(childModel.visibleFields.map((field) => [field.attrName, stripDictAnnotation(field.comment)])),
|
|
372
372
|
},
|
|
373
373
|
])
|
|
374
374
|
);
|
|
@@ -577,6 +577,17 @@ function normalizeDictType(value) {
|
|
|
577
577
|
return normalized.replace(/^['"`]+|['"`]+$/g, '');
|
|
578
578
|
}
|
|
579
579
|
|
|
580
|
+
function stripDictAnnotation(label) {
|
|
581
|
+
const text = String(label || '').trim();
|
|
582
|
+
if (!text) {
|
|
583
|
+
return '';
|
|
584
|
+
}
|
|
585
|
+
return text
|
|
586
|
+
.replace(/\s*[((]\s*(?:字典|dict)(?:类型|type)?\s*[::=]?\s*[a-zA-Z0-9_-]+\s*[))]\s*/gi, '')
|
|
587
|
+
.replace(/\s+/g, ' ')
|
|
588
|
+
.trim();
|
|
589
|
+
}
|
|
590
|
+
|
|
580
591
|
function extractDictType(text) {
|
|
581
592
|
const normalized = String(text || '').trim();
|
|
582
593
|
if (!normalized) {
|
|
@@ -1166,7 +1177,7 @@ function renderTemplate(templateText, replacements) {
|
|
|
1166
1177
|
}
|
|
1167
1178
|
|
|
1168
1179
|
function renderFormField(field) {
|
|
1169
|
-
const label = field.comment.replace(/'/g, "\\'");
|
|
1180
|
+
const label = stripDictAnnotation(field.comment).replace(/'/g, "\\'");
|
|
1170
1181
|
const prop = field.attrName;
|
|
1171
1182
|
|
|
1172
1183
|
if (field.formType === 'select') {
|
|
@@ -1225,7 +1236,7 @@ function renderFormField(field) {
|
|
|
1225
1236
|
}
|
|
1226
1237
|
|
|
1227
1238
|
function renderTableColumn(field) {
|
|
1228
|
-
const label = field.comment.replace(/'/g, "\\'");
|
|
1239
|
+
const label = stripDictAnnotation(field.comment).replace(/'/g, "\\'");
|
|
1229
1240
|
if (field.dictType) {
|
|
1230
1241
|
return [
|
|
1231
1242
|
` <el-table-column prop="${field.attrName}" label="${label}" show-overflow-tooltip>`,
|
|
@@ -1239,7 +1250,7 @@ function renderTableColumn(field) {
|
|
|
1239
1250
|
}
|
|
1240
1251
|
|
|
1241
1252
|
function renderChildTableColumn(field, childListName) {
|
|
1242
|
-
const label = field.comment.replace(/'/g, "\\'");
|
|
1253
|
+
const label = stripDictAnnotation(field.comment).replace(/'/g, "\\'");
|
|
1243
1254
|
const rules = field.notNull ? ` :rules="[{ required: true, trigger: 'blur' }]"` : '';
|
|
1244
1255
|
|
|
1245
1256
|
let control = ` <el-input v-model="row.${field.attrName}" />`;
|
|
@@ -1267,7 +1278,7 @@ function renderChildTableColumn(field, childListName) {
|
|
|
1267
1278
|
}
|
|
1268
1279
|
|
|
1269
1280
|
function renderOptionField(field) {
|
|
1270
|
-
const label = field.comment.replace(/'/g, "\\'");
|
|
1281
|
+
const label = stripDictAnnotation(field.comment).replace(/'/g, "\\'");
|
|
1271
1282
|
return ` ${field.attrName}: { show:true, alwaysHide:false, smart:false, label: '${label}', width: '120' },`;
|
|
1272
1283
|
}
|
|
1273
1284
|
|
|
@@ -1446,7 +1457,7 @@ function renderFormFieldV2(field) {
|
|
|
1446
1457
|
}
|
|
1447
1458
|
|
|
1448
1459
|
function renderTableColumnV2(field, dictRegistryRefs) {
|
|
1449
|
-
const label = field.comment.replace(/'/g, "\\'");
|
|
1460
|
+
const label = stripDictAnnotation(field.comment).replace(/'/g, "\\'");
|
|
1450
1461
|
const parts = [`prop: '${field.attrName}'`, `label: '${label}'`];
|
|
1451
1462
|
const width = getDefaultOptionFieldWidthV2(field);
|
|
1452
1463
|
|
|
@@ -1514,7 +1525,7 @@ function renderChildSectionV2(childModel, childCount) {
|
|
|
1514
1525
|
|
|
1515
1526
|
function renderValidationRule(field) {
|
|
1516
1527
|
if (!field.notNull) return null;
|
|
1517
|
-
const label = field.comment.replace(/'/g, "\\'");
|
|
1528
|
+
const label = stripDictAnnotation(field.comment).replace(/'/g, "\\'");
|
|
1518
1529
|
return ` ${field.attrName}: [{ required: true, message: '${label}不能为空', trigger: 'blur' }],`;
|
|
1519
1530
|
}
|
|
1520
1531
|
|
package/package.json
CHANGED