From c5db30f8172d28c4b19f2720484d4799bbb4a42d Mon Sep 17 00:00:00 2001 From: que01 Date: Fri, 9 Oct 2026 16:14:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A1=A5=E9=BD=90=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E5=8C=BA=E5=9F=9F=E4=B8=8E=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .codex-tasks/visual-editor-closure/EPIC.md | 7 ++++ .../visual-editor-closure/PROGRESS.md | 12 ++++++ .../visual-editor-closure/SUBTASKS.csv | 6 +++ .../src/features/brand/PresentationEditor.tsx | 2 +- apps/taro/test/browser/admin-editor.spec.ts | 11 +++++ docs/visual-editor-next-steps.md | 41 ++++++++++++++++++- .../config/src/generated-template-packages.js | 20 ++++++++- .../taro/index.tsx | 2 +- .../template-acheng-campus-food/template.json | 18 ++++++++ 9 files changed, 115 insertions(+), 4 deletions(-) create mode 100644 .codex-tasks/visual-editor-closure/EPIC.md create mode 100644 .codex-tasks/visual-editor-closure/PROGRESS.md create mode 100644 .codex-tasks/visual-editor-closure/SUBTASKS.csv diff --git a/.codex-tasks/visual-editor-closure/EPIC.md b/.codex-tasks/visual-editor-closure/EPIC.md new file mode 100644 index 0000000..c8799bf --- /dev/null +++ b/.codex-tasks/visual-editor-closure/EPIC.md @@ -0,0 +1,7 @@ +# 可视化编辑闭环 + +执行方案:docs/visual-editor-next-steps.md。 +基线:feat/admin-component-preview / 541304a。 +状态源:本目录 SUBTASKS.csv;旧 visual-editor 任务保留为历史。 +当前仅完成规划,实现未开始。各子任务开始前建立 tasks 对应目录的 SPEC.md、TODO.csv、PROGRESS.md,补充具体验证命令和证据。 +完成条件:全部子任务通过,业务内容有明确编辑入口,真实保存、发布隔离及生产部署验证完成。 diff --git a/.codex-tasks/visual-editor-closure/PROGRESS.md b/.codex-tasks/visual-editor-closure/PROGRESS.md new file mode 100644 index 0000000..65733c0 --- /dev/null +++ b/.codex-tasks/visual-editor-closure/PROGRESS.md @@ -0,0 +1,12 @@ +# 进度记录 + +2026-10-09:与现有 ADR 0020、后续计划和交付清单对齐,制定四阶段实施计划。 +2026-10-09:完成任务 1。盘点两套模板页面与 manifest / renderer 目标,修复餐饮首页身份区点选、咨询页字段过滤和首页业务目标 key;`pnpm validate:templates` 19 项通过,浏览器测试 2 项通过。 + +- 任务:可视化内容编辑闭环。 +- 形态:epic。 +- 进度:1/5 子任务完成,任务 2 进行中。 +- 当前:统一选区绑定,处理嵌套目标、重复记录和切页失效选择。 +- 验证:`pnpm validate:templates` 通过;`ADMIN_URL=http://localhost:3005 pnpm --filter @personal-brand/taro test:browser -- admin-editor.spec.ts` 通过。 +- 文件:.codex-tasks/visual-editor-closure/SUBTASKS.csv。 +- 下一步:任务 1,建立覆盖清单,逐页复现不能点选和表单映射问题。 diff --git a/.codex-tasks/visual-editor-closure/SUBTASKS.csv b/.codex-tasks/visual-editor-closure/SUBTASKS.csv new file mode 100644 index 0000000..e5b813c --- /dev/null +++ b/.codex-tasks/visual-editor-closure/SUBTASKS.csv @@ -0,0 +1,6 @@ +id,task,task_type,status,depends_on,task_dir,acceptance_criteria,validation_command,completed_at,retry_count,notes +1,逐页建立覆盖清单,single-full,DONE,,tasks/coverage,所有页面内容与字段对应且缺陷可复现,pnpm validate:templates; pnpm --filter @personal-brand/taro test:browser -- admin-editor.spec.ts,2026-10-09,0,已盘点两套模板页面;首批缺口已复现并修复:首页身份区目标、咨询品牌字段过滤、餐饮首页目标 key;契约 19 项和浏览器 2 项通过 +2,修复通用选区绑定与模板发现,single-full,IN_PROGRESS,1,tasks/contract,混合来源及重复记录映射正确且契约测试通过,,,0,已完成首批 manifest/renderer 对齐,继续处理嵌套目标、重复记录和失效选区 +3,整理选区面板与保存交互,single-full,TODO,2,tasks/inspector,布局及失败和未保存切换验证通过,,,0,实施前补充验证命令 +4,接通咨询字段编辑,single-full,TODO,2;3,tasks/inquiry,配置保存重载一致且历史提交不受损,,,0,实施前补充验证命令 +5,全页面回归与部署验收,single-full,TODO,1;2;3;4,tasks/delivery,覆盖清单及工程门槛和部署验收通过,,,0,实施前补充验证命令 diff --git a/apps/admin/src/features/brand/PresentationEditor.tsx b/apps/admin/src/features/brand/PresentationEditor.tsx index b342b39..e9a86ac 100644 --- a/apps/admin/src/features/brand/PresentationEditor.tsx +++ b/apps/admin/src/features/brand/PresentationEditor.tsx @@ -253,7 +253,7 @@ export function PresentationEditor({ ? trustQuery.data?.find((item) => item.id === selection?.recordId) : undefined; const editableSections = filterSectionsForPreviewTarget( - visibleSections.filter((section) => section.target === "brand"), + visibleSections.filter((section) => section.target === "brand" || section.target === "inquiry"), selectedTarget?.key, ); const recordSection = useMemo( diff --git a/apps/taro/test/browser/admin-editor.spec.ts b/apps/taro/test/browser/admin-editor.spec.ts index 1e4a13f..03462b3 100644 --- a/apps/taro/test/browser/admin-editor.spec.ts +++ b/apps/taro/test/browser/admin-editor.spec.ts @@ -191,10 +191,18 @@ const templateContent = { page: "home", target: "brand", previewTargets: [ + { key: "food.home.identity", label: "主理人身份" }, { key: "food.home.location", label: "服务地点" }, { key: "food.home.offerings-heading", label: "餐品区域标题" }, ], fields: [ + { + key: "identity", + binding: "brand.config.founder", + previewTarget: "food.home.identity", + label: "主理人姓名", + input: "text", + }, { key: "stallTitle", binding: "brand.config.visualPresentation.home.stallTitle", @@ -295,6 +303,9 @@ test("Admin 按通用预览目标筛选字段并同步品牌草稿", async ({ pa await expect(page.getByText("小程序页面配置")).toBeVisible(); const preview = page.locator(".component-template-preview"); await expect(preview.locator(".food-home .name")).toContainText("测试主理人"); + await preview.locator('[data-editor-target="food.home.identity"]').click(); + await expect(page.getByLabel("主理人姓名")).toBeVisible(); + await page.keyboard.press("Escape"); const dimensions = await preview.evaluate((element) => { const canvas = element.querySelector(".component-template-preview__canvas")!; const name = element.querySelector(".name")!; diff --git a/docs/visual-editor-next-steps.md b/docs/visual-editor-next-steps.md index 1c28164..1a54a1b 100644 --- a/docs/visual-editor-next-steps.md +++ b/docs/visual-editor-next-steps.md @@ -36,4 +36,43 @@ Admin 直接复用 Taro renderer,模板原始 CSS 按 750 设计宽度转换 ## 推进顺序 -先完成选区契约与覆盖层,作为一个可验收提交;再分批接入记录编辑与保存语义;最后补齐跨模板测试和发布验收。每次提交展示具体可操作闭环,保留回退到当前分支基线的能力。 +以下计划以 feat/admin-component-preview / 541304a 为基线。已有交互仅部分通过测试,不能视为逐页完成。实施状态以 `.codex-tasks/visual-editor-closure/SUBTASKS.csv` 为准,旧任务记录保留。 + +### 第一阶段:覆盖清单与绑定修复 + +1. 逐页盘点餐饮、林境模板,建立 coverage.csv:模板、页面、区域、实际读取字段、声明 binding、实体来源、记录定位、编辑入口、缺陷和验证证据。区分业务内容、访客输入、导航及装饰;空数据区域也纳入。 +2. 优先复现首页身份区域缺少点选标记、咨询区域标为 inquiry 却包含 brand 文案导致字段过滤、咨询字段缺少独立目标。继续逐页排查,不将这些示例视为全部缺陷。 +3. 补充 ADR 0020 后统一解析:区域表示页面位置,binding 决定字段来源;记录用稳定 ID,咨询字段用表单 ID 与字段 key。混合来源不能依赖 section.target 单一分类。模板包声明,Admin 通用解析。 +4. 修复嵌套目标、重复记录、无效选区与空区域新增入口;模板和 renderer 从包目录发现,建立可主动检出缺失映射的契约测试。 + +验收:所有声明页面进入清单;首页身份、咨询文案和重复卡片可准确定位;有意破坏映射时测试失败。 + +### 第二阶段:区域编辑面板 + +- 显示页面、区域、具体记录和未保存状态。未选择时显示区域导航,选中后只显示对应字段。 +- 普通字段默认单列,图片有预览与替换入口,列表支持逐项增删排序。依据面板宽度安排布局,消除强制双列和固定空白,不堆叠重复卡片。 +- 字段焦点与选区双向定位,高亮随滚动、图片加载、长文本更新且不改变模板布局。 +- 保存范围明确;失败保留值并可重试;有草稿时切区域、页面或品牌提供保存、放弃、取消选择。 + +验收:窄面板无溢出,长表单操作可达;图片、长文本、列表及保存失败、切换路径均有浏览器验证。 + +### 第三阶段:咨询表单编辑 + +- 区分页面文案、表单结构和访客试填。点击具体字段后编辑标题、提示、必填、类型及适用选项,复用现有验证规则。 +- 支持增删排序、空表单创建及条件显隐配置,检查条件引用有效性。 +- 复用 InquiryForm API、版本与发布语义;类型变更和删除不得破坏历史提交快照。预览不创建真实咨询、不读取客户记录。 + +验收:修改即时展示且保存重载一致;选择题、日期、长文本、条件字段、空状态均覆盖。接口若有变更,必须覆盖授权、品牌隔离、校验失败及成功持久化。 + +### 第四阶段:全页面与部署验收 + +- 按清单逐项验证点选、字段、草稿、保存、刷新;结合自动发现的契约检查与关键浏览器场景,不仅检查 DOM 存在。 +- 使用隔离品牌验证真实 API 保存、草稿与公开内容隔离、发布后读取一致,不覆盖用户开发数据。 +- 对照两套模板视觉;验证 320/390 画布、图片解码、页脚、表单;运行 H5 和小程序构建检查共享组件回归。 +- 运行 format:check、lint、相关 typecheck、validate:templates、Admin tests/build、浏览器测试及涉及的 API/API Client 测试。生产静态与子路径部署可用,无按模板单独运行服务需求。 + +验收:本轮覆盖项都有通过证据;未完成项保持显式状态。按依赖提交可运行单元,提供预览与验证记录,合并仍等待用户确认。 + +## 本轮边界 + +本次先制定计划,功能实施尚未开始。聚焦内容编辑,不做任意拖拽布局或 HTML 入库。保留模板视觉和 H5 回退;不重置数据库或 seed,必要结构调整先制定兼容迁移。 diff --git a/packages/config/src/generated-template-packages.js b/packages/config/src/generated-template-packages.js index a4ce022..6ff34c3 100644 --- a/packages/config/src/generated-template-packages.js +++ b/packages/config/src/generated-template-packages.js @@ -251,6 +251,10 @@ export const generatedTemplatePackageRegistry = [ "page": "home", "target": "brand", "previewTargets": [ + { + "key": "food.home.identity", + "label": "主理人身份" + }, { "key": "food.home.location", "label": "服务地点" @@ -269,6 +273,20 @@ export const generatedTemplatePackageRegistry = [ } ], "fields": [ + { + "key": "founder", + "binding": "brand.config.founder", + "label": "主理人姓名", + "input": "text", + "previewTarget": "food.home.identity" + }, + { + "key": "title", + "binding": "brand.config.title", + "label": "身份说明", + "input": "text", + "previewTarget": "food.home.identity" + }, { "key": "stallTitle", "previewTarget": "food.home.location", @@ -2623,4 +2641,4 @@ export const generatedTemplatePackageRegistry = [ } ]; export const generatedTemplatePackageRegistryHash = - "495374aaba6d94ef9597a525a8ca3af221d9fb44e7eaf34d75b71b8b6070bd2f"; + "4c99ea207a1a3689f19179ee3e56401585b838c2eeda237487943ca856dbbe52"; diff --git a/packages/template-acheng-campus-food/taro/index.tsx b/packages/template-acheng-campus-food/taro/index.tsx index 5e1784b..e9bdfcb 100644 --- a/packages/template-acheng-campus-food/taro/index.tsx +++ b/packages/template-acheng-campus-food/taro/index.tsx @@ -16,7 +16,7 @@ function Home({ workspace }: { workspace: RuntimeWorkspace }) { - + {text(brand.avatarUrl) && } {text(brand.founder)} diff --git a/packages/template-acheng-campus-food/template.json b/packages/template-acheng-campus-food/template.json index 1d57ff2..b30dee4 100644 --- a/packages/template-acheng-campus-food/template.json +++ b/packages/template-acheng-campus-food/template.json @@ -244,6 +244,10 @@ "page": "home", "target": "brand", "previewTargets": [ + { + "key": "food.home.identity", + "label": "主理人身份" + }, { "key": "food.home.location", "label": "服务地点" @@ -262,6 +266,20 @@ } ], "fields": [ + { + "key": "founder", + "binding": "brand.config.founder", + "label": "主理人姓名", + "input": "text", + "previewTarget": "food.home.identity" + }, + { + "key": "title", + "binding": "brand.config.title", + "label": "身份说明", + "input": "text", + "previewTarget": "food.home.identity" + }, { "key": "stallTitle", "previewTarget": "food.home.location",