worsoft-frontend-codegen-local-mcp 0.1.22 → 0.1.23
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 +70 -53
- 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.23';
|
|
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');
|
|
@@ -1249,21 +1249,32 @@ function renderTextareaMaxlengthAttrsV2(field) {
|
|
|
1249
1249
|
if (!field.length) return '';
|
|
1250
1250
|
return ` :maxlength="${field.length}" show-word-limit`;
|
|
1251
1251
|
}
|
|
1252
|
-
|
|
1252
|
+
|
|
1253
|
+
function renderDisabledAttrV2(field) {
|
|
1254
|
+
return field.readonly ? ' disabled' : '';
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
function renderFieldCommentV2(field, indent = ' ') {
|
|
1258
|
+
const label = stripDictAnnotation(field.comment || field.attrName).replace(/-->/g, '').trim() || field.attrName;
|
|
1259
|
+
return `${indent}<!-- 字段:${label} -->`;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1253
1262
|
function renderFormFieldV2(field) {
|
|
1254
1263
|
const prop = field.attrName;
|
|
1255
1264
|
const labelExpr = `getMasterFieldLabel('${prop}')`;
|
|
1256
1265
|
const dictExpr = `getMasterFieldMeta('${prop}')?.dictType`;
|
|
1266
|
+
const disabledAttr = renderDisabledAttrV2(field);
|
|
1257
1267
|
|
|
1258
1268
|
if (field.formType === 'select') {
|
|
1259
1269
|
return [
|
|
1270
|
+
renderFieldCommentV2(field),
|
|
1260
1271
|
` <el-col :span="12" class="mb20">`,
|
|
1261
1272
|
` <el-form-item :label="${labelExpr}" prop="${prop}">`,
|
|
1262
|
-
` <el-select v-model="form.${prop}" :placeholder="selectPlaceholder(${labelExpr})" style="width: 100%">`,
|
|
1273
|
+
` <el-select v-model="form.${prop}" :placeholder="selectPlaceholder(${labelExpr})" style="width: 100%"${disabledAttr}>`,
|
|
1263
1274
|
` <el-option v-for="item in getDictOptions(${dictExpr})" :key="item.value" :label="item.label" :value="Number(item.value)" />`,
|
|
1264
|
-
' </el-select>',
|
|
1265
|
-
' </el-form-item>',
|
|
1266
|
-
' </el-col>',
|
|
1275
|
+
' </el-select>',
|
|
1276
|
+
' </el-form-item>',
|
|
1277
|
+
' </el-col>',
|
|
1267
1278
|
].join('\n');
|
|
1268
1279
|
}
|
|
1269
1280
|
|
|
@@ -1271,46 +1282,50 @@ function renderFormFieldV2(field) {
|
|
|
1271
1282
|
const max = field.comment.includes('%') || /\u6BD4\u4F8B/.test(field.comment) ? ' :max="100"' : '';
|
|
1272
1283
|
const precision = field.sqlType === 'DECIMAL' && field.scale ? ` :precision="${field.scale}" :step="0.01"` : '';
|
|
1273
1284
|
return [
|
|
1285
|
+
renderFieldCommentV2(field),
|
|
1274
1286
|
` <el-col :span="12" class="mb20">`,
|
|
1275
1287
|
` <el-form-item :label="${labelExpr}" prop="${prop}">`,
|
|
1276
|
-
` <el-input-number v-model="form.${prop}" :min="0"${max}${precision} :placeholder="inputPlaceholder(${labelExpr})" style="width: 100%" />`,
|
|
1288
|
+
` <el-input-number v-model="form.${prop}" :min="0"${max}${precision} :placeholder="inputPlaceholder(${labelExpr})" style="width: 100%"${disabledAttr} />`,
|
|
1277
1289
|
' </el-form-item>',
|
|
1278
|
-
' </el-col>',
|
|
1279
|
-
].join('\n');
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1290
|
+
' </el-col>',
|
|
1291
|
+
].join('\n');
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1282
1294
|
if (field.formType === 'datetime' || field.formType === 'date') {
|
|
1283
1295
|
const pickerType = field.formType === 'datetime' ? 'datetime' : 'date';
|
|
1284
1296
|
const formatName = field.formType === 'datetime' ? 'dateTimeStr' : 'dateStr';
|
|
1285
1297
|
return [
|
|
1298
|
+
renderFieldCommentV2(field),
|
|
1286
1299
|
` <el-col :span="12" class="mb20">`,
|
|
1287
1300
|
` <el-form-item :label="${labelExpr}" prop="${prop}">`,
|
|
1288
|
-
` <el-date-picker type="${pickerType}" :placeholder="inputPlaceholder(${labelExpr})" v-model="form.${prop}" :value-format="${formatName}" style="width: 100%"></el-date-picker>`,
|
|
1301
|
+
` <el-date-picker type="${pickerType}" :placeholder="inputPlaceholder(${labelExpr})" v-model="form.${prop}" :value-format="${formatName}" style="width: 100%"${disabledAttr}></el-date-picker>`,
|
|
1289
1302
|
' </el-form-item>',
|
|
1290
|
-
' </el-col>',
|
|
1291
|
-
].join('\n');
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1303
|
+
' </el-col>',
|
|
1304
|
+
].join('\n');
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1294
1307
|
if (field.formType === 'textarea') {
|
|
1295
1308
|
const textareaAttrs = renderTextareaMaxlengthAttrsV2(field);
|
|
1296
1309
|
return [
|
|
1310
|
+
renderFieldCommentV2(field),
|
|
1297
1311
|
` <el-col :span="24" class="mb20">`,
|
|
1298
1312
|
` <el-form-item :label="${labelExpr}" prop="${prop}">`,
|
|
1299
|
-
` <el-input type="textarea" v-model="form.${prop}" :placeholder="inputPlaceholder(${labelExpr})"${textareaAttrs} />`,
|
|
1313
|
+
` <el-input type="textarea" v-model="form.${prop}" :placeholder="inputPlaceholder(${labelExpr})"${textareaAttrs}${disabledAttr} />`,
|
|
1300
1314
|
' </el-form-item>',
|
|
1301
|
-
' </el-col>',
|
|
1302
|
-
].join('\n');
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1315
|
+
' </el-col>',
|
|
1316
|
+
].join('\n');
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1305
1319
|
const maxlengthAttr = renderInputMaxlengthAttr(field);
|
|
1306
1320
|
return [
|
|
1321
|
+
renderFieldCommentV2(field),
|
|
1307
1322
|
` <el-col :span="12" class="mb20">`,
|
|
1308
1323
|
` <el-form-item :label="${labelExpr}" prop="${prop}">`,
|
|
1309
|
-
` <el-input v-model="form.${prop}" :placeholder="inputPlaceholder(${labelExpr})"${maxlengthAttr} />`,
|
|
1324
|
+
` <el-input v-model="form.${prop}" :placeholder="inputPlaceholder(${labelExpr})"${maxlengthAttr}${disabledAttr} />`,
|
|
1310
1325
|
' </el-form-item>',
|
|
1311
|
-
' </el-col>',
|
|
1312
|
-
].join('\n');
|
|
1313
|
-
}
|
|
1326
|
+
' </el-col>',
|
|
1327
|
+
].join('\n');
|
|
1328
|
+
}
|
|
1314
1329
|
|
|
1315
1330
|
function renderTableColumnV2(field, dictRegistryRefs) {
|
|
1316
1331
|
const label = stripDictAnnotation(field.comment).replace(/'/g, "\\'");
|
|
@@ -1328,34 +1343,36 @@ function renderTableColumnV2(field, dictRegistryRefs) {
|
|
|
1328
1343
|
return ` { ${parts.join(', ')} },`;
|
|
1329
1344
|
}
|
|
1330
1345
|
|
|
1331
|
-
function renderChildTableColumnV2(field, childListName) {
|
|
1332
|
-
const rules = field.notNull ? ` :rules="[{ required: true, trigger: 'blur' }]"` : '';
|
|
1333
|
-
const labelExpr = `getChildFieldLabel('${childListName}', '${field.attrName}')`;
|
|
1334
|
-
const dictExpr = `getChildFieldMeta('${childListName}', '${field.attrName}')?.dictType`;
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
`
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
const
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
const
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
`
|
|
1346
|
+
function renderChildTableColumnV2(field, childListName) {
|
|
1347
|
+
const rules = field.notNull ? ` :rules="[{ required: true, trigger: 'blur' }]"` : '';
|
|
1348
|
+
const labelExpr = `getChildFieldLabel('${childListName}', '${field.attrName}')`;
|
|
1349
|
+
const dictExpr = `getChildFieldMeta('${childListName}', '${field.attrName}')?.dictType`;
|
|
1350
|
+
const disabledAttr = renderDisabledAttrV2(field);
|
|
1351
|
+
|
|
1352
|
+
let control = ` <el-input v-model="row.${field.attrName}" :placeholder="inputPlaceholder(${labelExpr})"${renderTextMaxlengthAttrV2(field)}${disabledAttr} />`;
|
|
1353
|
+
if (field.formType === 'select' && field.dictType) {
|
|
1354
|
+
control = [
|
|
1355
|
+
` <el-select v-model="row.${field.attrName}" :placeholder="selectPlaceholder(${labelExpr})" style="width: 100%"${disabledAttr}>`,
|
|
1356
|
+
` <el-option v-for="item in getDictOptions(${dictExpr})" :key="item.value" :label="item.label" :value="Number(item.value)" />`,
|
|
1357
|
+
' </el-select>',
|
|
1358
|
+
].join('\n');
|
|
1359
|
+
} else if (field.formType === 'number') {
|
|
1360
|
+
const max = field.comment.includes('%') || /\u6BD4\u4F8B/.test(field.comment) ? ' :max="100"' : '';
|
|
1361
|
+
const precision = field.sqlType === 'DECIMAL' && field.scale ? ` :precision="${field.scale}" :step="0.01"` : '';
|
|
1362
|
+
control = ` <el-input-number v-model="row.${field.attrName}" :min="0"${max}${precision} style="width: 100%"${disabledAttr} />`;
|
|
1363
|
+
} else if (field.formType === 'datetime' || field.formType === 'date') {
|
|
1364
|
+
const pickerType = field.formType === 'datetime' ? 'datetime' : 'date';
|
|
1365
|
+
const formatName = field.formType === 'datetime' ? 'dateTimeStr' : 'dateStr';
|
|
1366
|
+
control = ` <el-date-picker type="${pickerType}" v-model="row.${field.attrName}" :value-format="${formatName}" :placeholder="inputPlaceholder(${labelExpr})" style="width: 100%"${disabledAttr}></el-date-picker>`;
|
|
1367
|
+
} else if (field.formType === 'textarea') {
|
|
1368
|
+
control = ` <el-input type="textarea" v-model="row.${field.attrName}" :placeholder="inputPlaceholder(${labelExpr})"${renderTextareaMaxlengthAttrsV2(field)}${disabledAttr} />`;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
return [
|
|
1372
|
+
renderFieldCommentV2(field, ' '),
|
|
1373
|
+
` <el-table-column :label="${labelExpr}" prop="${field.attrName}">`,
|
|
1374
|
+
' <template #default="{ row, $index }">',
|
|
1375
|
+
` <el-form-item :prop="\`${childListName}.\${$index}.${field.attrName}\`"${rules}>`,
|
|
1359
1376
|
control,
|
|
1360
1377
|
' </el-form-item>',
|
|
1361
1378
|
' </template>',
|
package/package.json
CHANGED