worsoft-frontend-codegen-local-mcp 0.1.45 → 0.1.46
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 +51 -39
- 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.46';
|
|
9
9
|
const PROTOCOL_VERSION = '2024-11-05';
|
|
10
10
|
const TOOL_NAME = 'worsoft_codegen_local_generate_frontend';
|
|
11
11
|
const STYLE_CATALOG_PATH = path.join(__dirname, 'assets', 'style-catalog.json');
|
|
@@ -871,22 +871,21 @@ function mapFieldType(field) {
|
|
|
871
871
|
return 'text';
|
|
872
872
|
}
|
|
873
873
|
|
|
874
|
-
function normalizeStructuredFormType(value) {
|
|
875
|
-
const normalized = String(value || '').trim().toLowerCase();
|
|
876
|
-
if (!normalized) return '';
|
|
877
|
-
if (normalized === 'date') return 'date';
|
|
878
|
-
if (normalized === 'datetime') return 'datetime';
|
|
879
|
-
if (normalized === 'microme-operator') return 'number';
|
|
880
|
-
if (normalized === 'upload'
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
}
|
|
874
|
+
function normalizeStructuredFormType(value) {
|
|
875
|
+
const normalized = String(value || '').trim().toLowerCase();
|
|
876
|
+
if (!normalized) return '';
|
|
877
|
+
if (normalized === 'date') return 'date';
|
|
878
|
+
if (normalized === 'datetime') return 'datetime';
|
|
879
|
+
if (normalized === 'microme-operator') return 'number';
|
|
880
|
+
if (normalized === 'upload') {
|
|
881
|
+
return 'upload';
|
|
882
|
+
}
|
|
883
|
+
if (normalized === 'picker') {
|
|
884
|
+
return 'text';
|
|
885
|
+
}
|
|
886
|
+
if (['text', 'select', 'textarea', 'number'].includes(normalized)) {
|
|
887
|
+
return normalized;
|
|
888
|
+
}
|
|
890
889
|
throw new Error('Unsupported explicit component/form type: ' + normalized);
|
|
891
890
|
}
|
|
892
891
|
|
|
@@ -1621,18 +1620,20 @@ function renderTableColumn(field) {
|
|
|
1621
1620
|
return ` <el-table-column prop="${field.attrName}" label="${label}" show-overflow-tooltip />`;
|
|
1622
1621
|
}
|
|
1623
1622
|
|
|
1624
|
-
function renderChildTableColumn(field, childListName) {
|
|
1625
|
-
const label = stripDictAnnotation(field.comment).replace(/'/g, "\\'");
|
|
1626
|
-
const rules = field.notNull ? ` :rules="[{ required: true, trigger: 'blur' }]"` : '';
|
|
1627
|
-
const inputPlaceholderExpr = `inputPlaceholder(getChildFieldLabel('${childListName}', '${field.attrName}'))`;
|
|
1628
|
-
const selectPlaceholderExpr = `selectPlaceholder(getChildFieldLabel('${childListName}', '${field.attrName}'))`;
|
|
1629
|
-
|
|
1630
|
-
let control = ` <el-input v-model="row.${field.attrName}" :placeholder="${inputPlaceholderExpr}" />`;
|
|
1631
|
-
if (field.formType === '
|
|
1632
|
-
control =
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1623
|
+
function renderChildTableColumn(field, childListName) {
|
|
1624
|
+
const label = stripDictAnnotation(field.comment).replace(/'/g, "\\'");
|
|
1625
|
+
const rules = field.notNull ? ` :rules="[{ required: true, trigger: 'blur' }]"` : '';
|
|
1626
|
+
const inputPlaceholderExpr = `inputPlaceholder(getChildFieldLabel('${childListName}', '${field.attrName}'))`;
|
|
1627
|
+
const selectPlaceholderExpr = `selectPlaceholder(getChildFieldLabel('${childListName}', '${field.attrName}'))`;
|
|
1628
|
+
|
|
1629
|
+
let control = ` <el-input v-model="row.${field.attrName}" :placeholder="${inputPlaceholderExpr}" />`;
|
|
1630
|
+
if (field.formType === 'upload') {
|
|
1631
|
+
control = ` <UploadFile v-model="row.${field.attrName}" />`;
|
|
1632
|
+
} else if (field.formType === 'select' && field.dictType) {
|
|
1633
|
+
control = [
|
|
1634
|
+
` <el-select v-model="row.${field.attrName}" :placeholder="${selectPlaceholderExpr}" style="width: 100%">`,
|
|
1635
|
+
` <el-option v-for="item in ${field.dictType}" :key="item.value" :label="item.label" :value="item.value" />`,
|
|
1636
|
+
' </el-select>',
|
|
1636
1637
|
].join('\n');
|
|
1637
1638
|
} else if (field.formType === 'number') {
|
|
1638
1639
|
const max = field.comment.includes('%') || /\u6BD4\u4F8B/.test(field.comment) ? ' :max="100"' : '';
|
|
@@ -1860,16 +1861,27 @@ function renderFieldCommentV2(field, indent = ' ') {
|
|
|
1860
1861
|
return indent + '<!-- 字段:' + label + ' -->';
|
|
1861
1862
|
}
|
|
1862
1863
|
|
|
1863
|
-
function renderFormFieldV2(field) {
|
|
1864
|
-
const prop = field.attrName;
|
|
1865
|
-
const labelExpr = `getMasterFieldLabel('${prop}')`;
|
|
1866
|
-
const dictExpr = `getMasterFieldMeta('${prop}')?.dictType`;
|
|
1867
|
-
const disabledAttr = renderDisabledAttrV2(field);
|
|
1868
|
-
|
|
1869
|
-
if (field.formType === '
|
|
1870
|
-
return [
|
|
1871
|
-
renderFieldCommentV2(field),
|
|
1872
|
-
` <el-col :span="
|
|
1864
|
+
function renderFormFieldV2(field) {
|
|
1865
|
+
const prop = field.attrName;
|
|
1866
|
+
const labelExpr = `getMasterFieldLabel('${prop}')`;
|
|
1867
|
+
const dictExpr = `getMasterFieldMeta('${prop}')?.dictType`;
|
|
1868
|
+
const disabledAttr = renderDisabledAttrV2(field);
|
|
1869
|
+
|
|
1870
|
+
if (field.formType === 'upload') {
|
|
1871
|
+
return [
|
|
1872
|
+
renderFieldCommentV2(field),
|
|
1873
|
+
` <el-col :span="24" class="mb20">`,
|
|
1874
|
+
` <el-form-item :label="${labelExpr}" prop="${prop}">`,
|
|
1875
|
+
` <UploadFile v-model="form.${prop}"${disabledAttr} />`,
|
|
1876
|
+
' </el-form-item>',
|
|
1877
|
+
' </el-col>',
|
|
1878
|
+
].join('\n');
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
if (field.formType === 'select') {
|
|
1882
|
+
return [
|
|
1883
|
+
renderFieldCommentV2(field),
|
|
1884
|
+
` <el-col :span="12" class="mb20">`,
|
|
1873
1885
|
` <el-form-item :label="${labelExpr}" prop="${prop}">`,
|
|
1874
1886
|
` <el-select v-model="form.${prop}" :placeholder="selectPlaceholder(${labelExpr})" style="width: 100%"${disabledAttr}>`,
|
|
1875
1887
|
` <el-option v-for="item in getDictOptions(${dictExpr})" :key="item.value" :label="item.label" :value="item.value" />`,
|
package/package.json
CHANGED