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

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.
@@ -66,6 +66,12 @@ const {
66
66
  const childSectionTitle = (groupName: string) => t(`${pageI18nKey}.children.${groupName}.title`);
67
67
 
68
68
  // 统一维护表单默认值,初始化和重置都复用这一份
69
+ const formatCurrentDateTime = () => {
70
+ const now = new Date();
71
+ const pad = (value: number) => String(value).padStart(2, '0');
72
+ return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`;
73
+ };
74
+
69
75
  const createDefaultFormState = () => ({
70
76
  {{FORM_DEFAULTS}}
71
77
  {{CHILD_FORM_LIST_DEFAULTS}}
@@ -163,5 +169,3 @@ onMounted(() => {
163
169
  initPage();
164
170
  });
165
171
  </script>
166
-
167
-
@@ -42,6 +42,12 @@ const {
42
42
  } = useCrudPageMeta(dataMasterEntity, dictRefs);
43
43
 
44
44
  // 表单数据模型
45
+ const formatCurrentDateTime = () => {
46
+ const now = new Date();
47
+ const pad = (value: number) => String(value).padStart(2, '0');
48
+ return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`;
49
+ };
50
+
45
51
  const createDefaultFormState = () => ({
46
52
  {{FORM_DEFAULTS}}
47
53
  });
@@ -56,6 +56,12 @@ const {
56
56
  } = useCrudPageMeta(dataMasterEntity, dictRefs);
57
57
 
58
58
  // 表单数据模型
59
+ const formatCurrentDateTime = () => {
60
+ const now = new Date();
61
+ const pad = (value: number) => String(value).padStart(2, '0');
62
+ return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`;
63
+ };
64
+
59
65
  const createDefaultFormState = () => ({
60
66
  {{FORM_DEFAULTS}}
61
67
  });
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');
@@ -1672,10 +1672,13 @@ 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 === 'createTime') return ` ${field.attrName}: formatCurrentDateTime(),`;
1679
+ if (field.formType === 'number') return ` ${field.attrName}: 0,`;
1680
+ return ` ${field.attrName}: '',`;
1681
+ }
1679
1682
 
1680
1683
  function renderFormRulesV2(fields) {
1681
1684
  return fields
@@ -1701,13 +1704,13 @@ function renderChildListDefaultLine(childModel) {
1701
1704
  return ` ${childModel.listName}: [],`;
1702
1705
  }
1703
1706
 
1704
- function renderChildTempDeclaration(childModel) {
1705
- return [
1706
- `const childTemp${childModel.className} = reactive({`,
1707
- renderChildTempDefaults(childModel),
1708
- '});',
1709
- ].join('\n');
1710
- }
1707
+ function renderChildTempDeclaration(childModel) {
1708
+ return [
1709
+ `const childTemp${childModel.className} = reactive({`,
1710
+ renderChildTempDefaults(childModel),
1711
+ '});',
1712
+ ].join('\n');
1713
+ }
1711
1714
 
1712
1715
  function renderChildSection(childModel, childCount) {
1713
1716
  const title = childModel.tableComment.replace(/'/g, "\\'");
@@ -1868,7 +1871,7 @@ function isAttachmentLikeField(field) {
1868
1871
 
1869
1872
  function renderFieldCommentV2(field, indent = ' ') {
1870
1873
  const label = stripDictAnnotation(field.comment || field.attrName).replace(/-->/g, '').trim() || field.attrName;
1871
- return indent + '<!-- 字段:' + label + ' -->';
1874
+ return indent + '<!-- ' + label + ' -->';
1872
1875
  }
1873
1876
 
1874
1877
  function renderFormFieldV2(field) {
@@ -2312,96 +2315,6 @@ defineExpose({
2312
2315
  </script>
2313
2316
  `;
2314
2317
  }
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
2318
  function renderMultiLevelSchemaListSlot(levelVarName, activeKeyVarName, activeModuleVarName) {
2406
2319
  return [
2407
2320
  ` <div class="multi-level-slot" v-if="${levelVarName}">`,
@@ -2426,8 +2339,8 @@ function renderMultiLevelSchemaListSlot(levelVarName, activeKeyVarName, activeMo
2426
2339
  ` <template #actions="{ row }">`,
2427
2340
  ` <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
2341
  ` <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>`,
2342
+ ` <el-button v-if="showModuleAction(${activeModuleVarName}.key, 'enable', row)" icon="circle-check" text type="primary" @click="handleEnable(${activeModuleVarName}.key, row)">闁告凹鍨抽弫?/el-button>`,
2343
+ ` <el-button v-if="showModuleAction(${activeModuleVarName}.key, 'disable', row)" icon="remove" text type="primary" @click="handleDisable(${activeModuleVarName}.key, row)">缂佸倷鑳堕弫?/el-button>`,
2431
2344
  ` </template>`,
2432
2345
  ` </SchemaListTable>`,
2433
2346
  ' </div>',
@@ -2590,8 +2503,8 @@ const resolveLabel = (labelKey?: string, fallback = '') => {
2590
2503
  const resolveModuleTitle = (moduleConfig: any) => resolveLabel(moduleConfig?.titleKey, moduleConfig?.key || '');
2591
2504
  const getDictOptions = (dictType?: string) => (dictType ? dictRefs[dictType]?.value || [] : []);
2592
2505
  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);
2506
+ const isStatusNew = (value: any) => ['0', 0, false, 'false', 'new', '閺傛澘顤?].includes(value);
2507
+ const isStatusNewOrDisabled = (value: any) => ['0', 0, false, 'false', 'new', '閺傛澘顤?, '2', '缁備胶鏁?, 'disabled'].includes(value);
2595
2508
  const showModuleAction = (moduleKey: string, action: 'edit' | 'delete' | 'enable' | 'disable', row: any): boolean => {
2596
2509
  const moduleConfig = moduleConfigs[moduleKey];
2597
2510
  const statusValue = moduleConfig?.statusField ? row?.[moduleConfig.statusField] : undefined;
@@ -2802,8 +2715,8 @@ function renderSingleTableDialogDictHelpers(model) {
2802
2715
  const statusField = model.statusField;
2803
2716
  return [
2804
2717
  "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);",
2718
+ "const isStatusNew = (value: any) => ['0', 0, false, 'false', 'new', '閺傛澘顤?].includes(value);",
2719
+ "const isStatusNewOrDisabled = (value: any) => ['0', 0, false, 'false', 'new', '閺傛澘顤?, '2', '缁備胶鏁?, 'disabled'].includes(value);",
2807
2720
  '',
2808
2721
  "const showDictAction = (action: 'edit' | 'delete' | 'enable' | 'disable', row: any): boolean => {",
2809
2722
  ` const status = row?.${statusField};`,
@@ -3240,3 +3153,4 @@ start();
3240
3153
 
3241
3154
 
3242
3155
 
3156
+
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.48",
4
4
  "description": "Worsoft frontend local-template code generation MCP server.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "worsoft <sw@worsoft.vip>",