diff --git a/src/commands/bigscreen/construct.ts b/src/commands/bigscreen/construct.ts index 579f9de..e54fac2 100644 --- a/src/commands/bigscreen/construct.ts +++ b/src/commands/bigscreen/construct.ts @@ -253,8 +253,11 @@ async function runConstruct(opts: ConstructOpts): Promise { // 先 addObj 拿 id (web 端 addObj 走 /visual/save, body 包含 visual basic + config detail/component) // 这里 addObj body 用 web 端 addObj 签名 (跟 create 命令一致, 拿 id 走 update 完整 formdata) + // FINDING-B1 (2026-07-02 audit): addParams 必含 enCode, 否则后端入库 enCode=null + // → list 检索不到, menu create 报"主表不存在" const addParams = { title: opts.fullName, + enCode: opts.enCode, // P0-4 修复: 必传 enCode category: opts.category, status: 0, // 先未发布, 拿 id 后 updateObj save 完整 formdata password: '', @@ -272,22 +275,25 @@ async function runConstruct(opts: ConstructOpts): Promise { } log.ok(`✓ addObj 创建空大屏成功 id=${id}`) - // === step 6: updateObj save 完整 formdata (镜像 header.vue:200-211 updateComponent) === + // === step 6: updateComponent save 完整 formdata (镜像 header.vue:200-211 updateComponent) === + // FINDING-B2 (2026-07-02 audit): 旧版用 updateObj(formdata) 错 (updateObj 会再包一层 {visual: data}) + // 正确调用 updateComponent(formdata) — web 端 header.vue:200-211 save 按钮走的就是这个 formdata.visual.id = id ;(formdata.config as Record).visualId = id if (opts.backgroundUrl) { (formdata.visual as Record).backgroundUrl = opts.backgroundUrl } - await loadVisualData.updateObj(formdata) - log.ok(`✓ updateObj save 完整 formdata 成功 (${nav.length} 组件已写入)`) + await loadVisualData.updateComponent(formdata) + log.ok(`✓ updateComponent save 完整 formdata 成功 (${nav.length} 组件已写入)`) // === step 7: 发布 (默认 ON, 镜像 web release 改 status=1) === + // 注: updateObj(data) → web 包成 {visual: data}, 所以传 visual 即可, 不要再包 if (!opts.noRelease) { const info = (await loadVisualData.getObj(id)) as { data?: Record } const visual = info.data if (visual) { visual.status = 1 - await loadVisualData.updateObj(visual) + await loadVisualData.updateObj(visual) // ✓ 正确: web 包 {visual: visual} 跟 publish 行为一致 log.ok(`✓ 大屏已发布 (status=1)`) } else { log.warn(`⚠ 发布跳过: getObj 后端未返 visual`)