diff --git a/src/commands/form/create.ts b/src/commands/form/create.ts index 26ccb92..5de7fec 100644 --- a/src/commands/form/create.ts +++ b/src/commands/form/create.ts @@ -28,6 +28,10 @@ interface CreateOpts { enableFlow?: string flowId?: string autoRelease?: boolean + /** v0.7.3 (盲点 47): 建完发布后自动挂菜单到指定父目录, 避免浏览器验证 step check-list 找不到 vxe-table */ + autoCreateMenu?: boolean + /** 父菜单 id (--autoCreateMenu 时必传, 用 dacli menu list --keyword=... 拿) */ + menuParentId?: string json?: boolean /** 5.10.1 AI 快速建表 — 自然语言描述, 平台 LLM 生成 enCode/fullName/fields */ ai?: string @@ -55,6 +59,8 @@ export function buildFormCreateCommand(): Command { .option('--enableFlow <0|1>', '是否绑工作流', '0') .option('--flowId ', '工作流 id (enableFlow=1 时必传)') .option('--autoRelease', '建完立刻发布 (type=4 自动跳过)', false) + .option('--autoCreateMenu', '发布后自动挂菜单 (需传 --menuParentId, 避免浏览器验证找不到 list 页)', false) + .option('--menuParentId ', '挂菜单的父目录 id (--autoCreateMenu 时必传; 走 dacli menu list --keyword=... 拿)') .option('--ai ', '白皮书 5.10.1 AI 快速建表 — 自然语言描述, 平台 LLM 生成 enCode/fullName/fields, 走 type=4 视图兜底') .option('--ai-field ', '白皮书 5.10.2 AI 推荐字段 — 自然语言描述, 平台 LLM 推荐单字段, 只输出建议不建表单') .option('--no-verify', '跳过浏览器层验证 (默认硬阻塞)') @@ -261,6 +267,26 @@ export function buildFormCreateCommand(): Command { log.warn('type=4 视图自动跳过 release (会 400)') } + // v0.7.3 (盲点 47): 发布后自动挂菜单, 避免浏览器验证 step check-list 找不到 vxe-table + if (opts.autoCreateMenu && newId !== '(unknown)' && newId !== '(unknown)') { + if (!opts.menuParentId) { + log.error('--autoCreateMenu 必传 --menuParentId (用 dacli menu list --keyword=目录名 拿顶级目录 id)') + if (opts.json) printJson({ id: newId, enCode: opts.enCode, type, webType, menuError: 'no parent' }) + } else { + log.info(`挂菜单: POST /visualdev/Base/${newId}/Actions/Module pcParentId=${opts.menuParentId}`) + // 复用 web CreateMenuModal 真实 body: pc=1, app=0, platformRelease=String + const mr = await c.postJson(`/visualdev/Base/${newId}/Actions/Module`, { + pc: 1, + app: 0, + pcModuleParentId: [opts.menuParentId], + appModuleParentId: [], + platformRelease: JSON.stringify({ pc: 1, app: 0 }), + }) + if (mr.code === 200) log.ok(`菜单挂载成功 (parentId=${opts.menuParentId})`) + else log.warn(`菜单挂载失败 (code=${mr.code}): ${mr.msg}`) + } + } + if (opts.json) printJson({ id: newId, enCode: opts.enCode, type, webType }) // Phase 3: 浏览器层验证 (默认硬阻塞, --verify=warn / --no-verify 可绕过) @@ -295,6 +321,8 @@ export function buildFormCreateCommand(): Command { '--enableFlow': '0|1', '--flowId': '工作流 id', '--autoRelease': '建完立刻发布 (type=4 自动跳过)', + '--autoCreateMenu': 'v0.7.3 (盲点 47) 发布后自动挂菜单 (需 --menuParentId, 避免浏览器验证失败)', + '--menuParentId': '挂菜单的父目录 id (--autoCreateMenu 时必传; 用 dacli menu list 拿)', '--ai': '白皮书 5.10.1 AI 快速建表 — 自然语言描述生成 enCode/fullName/fields', '--ai-field': '白皮书 5.10.2 AI 推荐字段 — 只输出建议不建表单', '--no-verify': '跳过浏览器层验证 (默认硬阻塞)', diff --git a/tests/e2e/verify-form.ts b/tests/e2e/verify-form.ts index e7017a9..b2c0995 100644 --- a/tests/e2e/verify-form.ts +++ b/tests/e2e/verify-form.ts @@ -116,12 +116,15 @@ async function resolveMenuEnCode(formId: string, appCode: string): Promise x.enCode === formEnCode) if (m?.enCode) return m.enCode - // b) urlAddress 末尾包含 form enCode (model/) + // b) urlAddress 末尾包含 form enCode (model/ + 5字符后缀) m = flat.find((x: any) => { const u = String(x.urlAddress || '') - return u === `model/${formEnCode}` || u.endsWith(`/${formEnCode}`) + return u === `model/${formEnCode}` || u.startsWith(`model/${formEnCode}`) }) if (m?.enCode) return m.enCode + // c) v0.7.3: menu.moduleId == formId (web Actions/Module 挂菜单时 moduleId 字段是 formId) + m = flat.find((x: any) => String(x.moduleId) === String(formId)) + if (m?.enCode) return m.enCode return null }