worsoft-frontend-codegen-local-mcp 0.1.47 → 0.1.49

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.
@@ -163,5 +163,3 @@ onMounted(() => {
163
163
  initPage();
164
164
  });
165
165
  </script>
166
-
167
-
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.47';
8
+ const SERVER_VERSION = '0.1.48';
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');
@@ -1631,8 +1631,8 @@ function renderTableColumn(field) {
1631
1631
  }
1632
1632
 
1633
1633
  function renderChildTableColumn(field, childListName) {
1634
- const label = stripDictAnnotation(field.comment).replace(/'/g, "\\'");
1635
1634
  const rules = field.notNull ? ` :rules="[{ required: true, trigger: 'blur' }]"` : '';
1635
+ const labelExpr = `getChildFieldLabel('${childListName}', '${field.attrName}')`;
1636
1636
  const inputPlaceholderExpr = `inputPlaceholder(getChildFieldLabel('${childListName}', '${field.attrName}'))`;
1637
1637
  const selectPlaceholderExpr = `selectPlaceholder(getChildFieldLabel('${childListName}', '${field.attrName}'))`;
1638
1638
 
@@ -1650,12 +1650,12 @@ function renderChildTableColumn(field, childListName) {
1650
1650
  const precision = field.sqlType === 'DECIMAL' && field.scale ? ` :precision="${field.scale}" :step="0.01"` : '';
1651
1651
  control = ` <el-input-number v-model="row.${field.attrName}" :min="0"${max}${precision} style="width: 100%" />`;
1652
1652
  }
1653
-
1654
- return [
1655
- ` <el-table-column label="${label}" prop="${field.attrName}">`,
1656
- ' <template #default="{ row, $index }">',
1657
- ` <el-form-item :prop="\`${childListName}.\${$index}.${field.attrName}\`"${rules}>`,
1658
- control,
1653
+
1654
+ return [
1655
+ ` <el-table-column :label="${labelExpr}" prop="${field.attrName}">`,
1656
+ ' <template #default="{ row, $index }">',
1657
+ ` <el-form-item :prop="\`${childListName}.\${$index}.${field.attrName}\`"${rules}>`,
1658
+ control,
1659
1659
  ' </el-form-item>',
1660
1660
  ' </template>',
1661
1661
  ' </el-table-column>',
@@ -1672,10 +1672,15 @@ function renderFilterType(field) {
1672
1672
  return ` ${field.attrName}: 30,`;
1673
1673
  }
1674
1674
 
1675
- function renderDefaultLine(field) {
1676
- if (field.formType === 'number') return ` ${field.attrName}: 0,`;
1677
- return ` ${field.attrName}: '',`;
1678
- }
1675
+ function renderDefaultLine(field) {
1676
+ if (field.attrName === 'createUserId') return ` ${field.attrName}: Session.getUserId(),`;
1677
+ if (field.attrName === 'createUser') return ` ${field.attrName}: Session.getUsername(),`;
1678
+ if (field.attrName === 'billDate') return ` ${field.attrName}: moment(new Date()).format('YYYY-MM-DD'),`;
1679
+ if (field.attrName === 'billStateId' || field.fieldName === 'bill_state_id') return ` ${field.attrName}: '0',`;
1680
+ if (field.attrName === 'createTime') return ` ${field.attrName}: moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),`;
1681
+ if (field.formType === 'number') return ` ${field.attrName}: 0,`;
1682
+ return ` ${field.attrName}: '',`;
1683
+ }
1679
1684
 
1680
1685
  function renderFormRulesV2(fields) {
1681
1686
  return fields
@@ -1701,23 +1706,22 @@ function renderChildListDefaultLine(childModel) {
1701
1706
  return ` ${childModel.listName}: [],`;
1702
1707
  }
1703
1708
 
1704
- function renderChildTempDeclaration(childModel) {
1705
- return [
1706
- `const childTemp${childModel.className} = reactive({`,
1707
- renderChildTempDefaults(childModel),
1708
- '});',
1709
- ].join('\n');
1710
- }
1711
-
1712
- function renderChildSection(childModel, childCount) {
1713
- const title = childModel.tableComment.replace(/'/g, "\\'");
1714
- const deleteExpression = `deleteChild(obj, '${childModel.pk.attrName}')`;
1709
+ function renderChildTempDeclaration(childModel) {
1710
+ return [
1711
+ `const childTemp${childModel.className} = reactive({`,
1712
+ renderChildTempDefaults(childModel),
1713
+ '});',
1714
+ ].join('\n');
1715
+ }
1715
1716
 
1716
- return [
1717
- ' <el-col :span="24" class="mb20">',
1718
- ` <div class="mb10" style="font-weight: 600;">${title}</div>`,
1719
- ` <sc-form-table v-model="form.${childModel.listName}" :addTemplate="childTemp${childModel.className}" @delete="(obj) => ${deleteExpression}" :placeholder="t('common.noData')">`,
1720
- childModel.visibleFields.map((field) => renderChildTableColumn(field, childModel.listName)).join('\n'),
1717
+ function renderChildSection(childModel, childCount) {
1718
+ const deleteExpression = `deleteChild(obj, '${childModel.pk.attrName}')`;
1719
+
1720
+ return [
1721
+ ' <el-col :span="24" class="mb20">',
1722
+ ` <div class="mb10" style="font-weight: 600;">{{ childSectionTitle('${childModel.listName}') }}</div>`,
1723
+ ` <sc-form-table v-model="form.${childModel.listName}" :addTemplate="childTemp${childModel.className}" @delete="(obj) => ${deleteExpression}" :placeholder="t('common.noData')">`,
1724
+ childModel.visibleFields.map((field) => renderChildTableColumn(field, childModel.listName)).join('\n'),
1721
1725
  ' </sc-form-table>',
1722
1726
  ' </el-col>',
1723
1727
  ].join('\n');
@@ -1868,7 +1872,7 @@ function isAttachmentLikeField(field) {
1868
1872
 
1869
1873
  function renderFieldCommentV2(field, indent = ' ') {
1870
1874
  const label = stripDictAnnotation(field.comment || field.attrName).replace(/-->/g, '').trim() || field.attrName;
1871
- return indent + '<!-- 字段:' + label + ' -->';
1875
+ return indent + '<!-- ' + label + ' -->';
1872
1876
  }
1873
1877
 
1874
1878
  function renderFormFieldV2(field) {
@@ -2312,96 +2316,6 @@ defineExpose({
2312
2316
  </script>
2313
2317
  `;
2314
2318
  }
2315
- function renderMultiLevelPanelVue() {
2316
- return `<template>
2317
- <el-container class="layout-padding-auto layout-padding-view dict-page-body">
2318
- <div class="mb8" style="width: 100%">
2319
- <el-button icon="folder-add" type="primary" class="ml10" :disabled="addDisabled" @click="$emit('add')">{{ t('common.addBtn') }}</el-button>
2320
- </div>
2321
-
2322
- <el-main style="padding: 0; min-height: 0;">
2323
- <el-table :data="dataList" v-loading="loading" border height="100%" highlight-current-row @current-change="handleCurrentChange">
2324
- <el-table-column type="index" :label="t('common.serial')" width="60" />
2325
- <el-table-column
2326
- v-for="column in columns"
2327
- :key="column.key"
2328
- :prop="column.key"
2329
- :label="resolveLabel(column.labelKey, column.key || '')"
2330
- :min-width="column.width || '120'"
2331
- show-overflow-tooltip
2332
- >
2333
- <template #default="scope">
2334
- <dict-tag v-if="column.dictType" :options="getDictOptions(column.dictType)" :value="scope.row[column.key]" />
2335
- <span v-else>{{ scope.row[column.key] }}</span>
2336
- </template>
2337
- </el-table-column>
2338
- <el-table-column :label="t('common.action')" width="240">
2339
- <template #default="scope">
2340
- <el-button icon="edit-pen" text type="primary" @click="$emit('edit', scope.row)">{{ t('common.editBtn') }}</el-button>
2341
- <el-button icon="delete" text type="primary" @click="$emit('delete', scope.row)">{{ t('common.delBtn') }}</el-button>
2342
- <el-button v-if="statusField && !isEnabled(scope.row[statusField])" icon="circle-check" text type="primary" @click="$emit('enable', scope.row)">闂備礁鎲¢崙褰掑垂閹惰棄鏋?/el-button>
2343
- <el-button v-if="statusField && isEnabled(scope.row[statusField])" icon="remove" text type="primary" @click="$emit('disable', scope.row)">缂傚倷绀侀崐鐑芥嚄閸洖鏋?/el-button>
2344
- </template>
2345
- </el-table-column>
2346
- </el-table>
2347
- </el-main>
2348
-
2349
- <el-footer style="height: auto; padding: 10px 0 0 0; flex-shrink: 0;">
2350
- <pagination
2351
- :current-page="currentPage"
2352
- :page-size="pageSize"
2353
- :total="total"
2354
- @current-change="$emit('current-change', $event)"
2355
- @size-change="$emit('size-change', $event)"
2356
- />
2357
- </el-footer>
2358
- </el-container>
2359
- </template>
2360
-
2361
- <script setup lang="ts" name="MultiLevelDictPanel">
2362
- import { useDict } from '/@/hooks/dict';
2363
- import { useI18n } from 'vue-i18n';
2364
-
2365
- const props = defineProps({
2366
- columns: { type: Array, required: true },
2367
- dictTypes: { type: Array, default: () => [] },
2368
- dataList: { type: Array, default: () => [] },
2369
- loading: { type: Boolean, default: false },
2370
- addDisabled: { type: Boolean, default: false },
2371
- statusField: { type: String, default: '' },
2372
- currentPage: { type: Number, default: 1 },
2373
- pageSize: { type: Number, default: 10 },
2374
- total: { type: Number, default: 0 },
2375
- });
2376
-
2377
- const emit = defineEmits(['add', 'edit', 'delete', 'enable', 'disable', 'current-change', 'size-change', 'select-row']);
2378
-
2379
- const { t } = useI18n();
2380
- const dictRefs = useDict(...props.dictTypes);
2381
-
2382
- const resolveLabel = (labelKey?: string, fallback = '') => {
2383
- if (!labelKey) return fallback;
2384
- const translated = t(labelKey);
2385
- return translated === labelKey ? fallback : translated;
2386
- };
2387
-
2388
- const getDictOptions = (dictType?: string) => (dictType ? dictRefs[dictType]?.value || [] : []);
2389
-
2390
- const isEnabled = (value: any) => ['1', 1, true, 'true', 'enable', 'enabled'].includes(value);
2391
-
2392
- const handleCurrentChange = (row: any) => {
2393
- if (row) emit('select-row', row);
2394
- };
2395
- </script>
2396
-
2397
- <style scoped>
2398
- .dict-page-body {
2399
- height: 100%;
2400
- }
2401
- </style>
2402
- `;
2403
- }
2404
-
2405
2319
  function renderMultiLevelSchemaListSlot(levelVarName, activeKeyVarName, activeModuleVarName) {
2406
2320
  return [
2407
2321
  ` <div class="multi-level-slot" v-if="${levelVarName}">`,
@@ -2426,8 +2340,8 @@ function renderMultiLevelSchemaListSlot(levelVarName, activeKeyVarName, activeMo
2426
2340
  ` <template #actions="{ row }">`,
2427
2341
  ` <el-button v-if="showModuleAction(${activeModuleVarName}.key, 'edit', row)" icon="edit-pen" text type="primary" @click="openEdit(${activeModuleVarName}.key, row)">{{ t('common.editBtn') }}</el-button>`,
2428
2342
  ` <el-button v-if="showModuleAction(${activeModuleVarName}.key, 'delete', row)" icon="delete" text type="primary" @click="handleDelete(${activeModuleVarName}.key, row)">{{ t('common.delBtn') }}</el-button>`,
2429
- ` <el-button v-if="showModuleAction(${activeModuleVarName}.key, 'enable', row)" icon="circle-check" text type="primary" @click="handleEnable(${activeModuleVarName}.key, row)">鍚敤</el-button>`,
2430
- ` <el-button v-if="showModuleAction(${activeModuleVarName}.key, 'disable', row)" icon="remove" text type="primary" @click="handleDisable(${activeModuleVarName}.key, row)">绂佺敤</el-button>`,
2343
+ ` <el-button v-if="showModuleAction(${activeModuleVarName}.key, 'enable', row)" icon="circle-check" text type="primary" @click="handleEnable(${activeModuleVarName}.key, row)">闁告凹鍨抽弫?/el-button>`,
2344
+ ` <el-button v-if="showModuleAction(${activeModuleVarName}.key, 'disable', row)" icon="remove" text type="primary" @click="handleDisable(${activeModuleVarName}.key, row)">缂佸倷鑳堕弫?/el-button>`,
2431
2345
  ` </template>`,
2432
2346
  ` </SchemaListTable>`,
2433
2347
  ' </div>',
@@ -2590,8 +2504,8 @@ const resolveLabel = (labelKey?: string, fallback = '') => {
2590
2504
  const resolveModuleTitle = (moduleConfig: any) => resolveLabel(moduleConfig?.titleKey, moduleConfig?.key || '');
2591
2505
  const getDictOptions = (dictType?: string) => (dictType ? dictRefs[dictType]?.value || [] : []);
2592
2506
  const isStatusEnabled = (value: any) => ['1', 1, true, 'true', 'enable', 'enabled'].includes(value);
2593
- const isStatusNew = (value: any) => ['0', 0, false, 'false', 'new', '新增'].includes(value);
2594
- const isStatusNewOrDisabled = (value: any) => ['0', 0, false, 'false', 'new', '新增', '2', '禁用', 'disabled'].includes(value);
2507
+ const isStatusNew = (value: any) => ['0', 0, false, 'false', 'new', '閺傛澘顤?].includes(value);
2508
+ const isStatusNewOrDisabled = (value: any) => ['0', 0, false, 'false', 'new', '閺傛澘顤?, '2', '缁備胶鏁?, 'disabled'].includes(value);
2595
2509
  const showModuleAction = (moduleKey: string, action: 'edit' | 'delete' | 'enable' | 'disable', row: any): boolean => {
2596
2510
  const moduleConfig = moduleConfigs[moduleKey];
2597
2511
  const statusValue = moduleConfig?.statusField ? row?.[moduleConfig.statusField] : undefined;
@@ -2802,8 +2716,8 @@ function renderSingleTableDialogDictHelpers(model) {
2802
2716
  const statusField = model.statusField;
2803
2717
  return [
2804
2718
  "const isStatusEnabled = (value: any) => ['1', 1, true, 'true', 'enable', 'enabled'].includes(value);",
2805
- "const isStatusNew = (value: any) => ['0', 0, false, 'false', 'new', '新增'].includes(value);",
2806
- "const isStatusNewOrDisabled = (value: any) => ['0', 0, false, 'false', 'new', '新增', '2', '禁用', 'disabled'].includes(value);",
2719
+ "const isStatusNew = (value: any) => ['0', 0, false, 'false', 'new', '閺傛澘顤?].includes(value);",
2720
+ "const isStatusNewOrDisabled = (value: any) => ['0', 0, false, 'false', 'new', '閺傛澘顤?, '2', '缁備胶鏁?, 'disabled'].includes(value);",
2807
2721
  '',
2808
2722
  "const showDictAction = (action: 'edit' | 'delete' | 'enable' | 'disable', row: any): boolean => {",
2809
2723
  ` const status = row?.${statusField};`,
@@ -3240,3 +3154,4 @@ start();
3240
3154
 
3241
3155
 
3242
3156
 
3157
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "worsoft-frontend-codegen-local-mcp",
3
- "version": "0.1.47",
3
+ "version": "0.1.49",
4
4
  "description": "Worsoft frontend local-template code generation MCP server.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "worsoft <sw@worsoft.vip>",