From 8f252d088a44bc45f2daaa90e2eed11133cbaea6 Mon Sep 17 00:00:00 2001 From: que01 Date: Sun, 25 Oct 2026 10:41:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=8B=AC=E7=AB=8B?= =?UTF-8?q?=E5=B7=A5=E5=9D=8A=E4=B8=9A=E5=8A=A1=E8=AF=A6=E6=83=85=E5=8C=BA?= =?UTF-8?q?=E5=9D=97=E5=AD=97=E6=AE=B5=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../raw/completion-evidence.json | 4 +- .../raw/manual-review.json | 8 +- .../features/services/OfferingEditorModal.tsx | 45 +-- .../src/features/services/ServicesPage.tsx | 66 ++-- .../src/features/services/offering-preview.ts | 42 +- apps/api/test/http.integration.test.js | 6 +- .../browser/atelier-services-editor.spec.ts | 370 ++++++++++++++++++ .../brand-creation-and-page-scheme.spec.ts | 8 +- .../taro/test/browser/services-editor.spec.ts | 9 +- config/template-build.json | 2 +- docs/template-registry.md | 2 +- .../config/src/generated-template-packages.ts | 56 ++- .../template-atelier-solopreneur/package.json | 2 +- .../taro/index.tsx | 24 +- .../template.json | 54 ++- 15 files changed, 553 insertions(+), 145 deletions(-) create mode 100644 apps/taro/test/browser/atelier-services-editor.spec.ts diff --git a/.codex-tasks/template-audit-execution/raw/completion-evidence.json b/.codex-tasks/template-audit-execution/raw/completion-evidence.json index 9cfda75..4b8168f 100644 --- a/.codex-tasks/template-audit-execution/raw/completion-evidence.json +++ b/.codex-tasks/template-audit-execution/raw/completion-evidence.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "scope": "模板完成证据登记,保留命令、日志与产物哈希", - "generatedAt": "2026-10-24T02:35:52.145Z", + "generatedAt": "2026-10-25T02:41:08.525Z", "templates": { "acheng-campus-food": { "real-manifest-interaction": { @@ -256,5 +256,5 @@ } } }, - "sourceTreeHash": "a5506179992f144e6b4afb0f0dfc295c5d722a5aadf7027fd785479a8276320f" + "sourceTreeHash": "44138bf1bea4fa9e0a9344d81357a7a3fe9abe3594836a92c0db5c4e7483524c" } diff --git a/.codex-tasks/template-audit-execution/raw/manual-review.json b/.codex-tasks/template-audit-execution/raw/manual-review.json index 4d35f3e..927faae 100644 --- a/.codex-tasks/template-audit-execution/raw/manual-review.json +++ b/.codex-tasks/template-audit-execution/raw/manual-review.json @@ -1212,7 +1212,7 @@ "code": "CONDITIONAL_RENDER_REVIEW", "severity": "review", "file": "packages/template-atelier-solopreneur/taro/index.tsx", - "target": "atelier-solopreneur.detail.projectDetail", + "target": "atelier-solopreneur.detail.projectHero", "line": 310, "message": "条件显示需验证全部分支与空数据入口。", "reviewStatus": "source-reviewed", @@ -1229,7 +1229,7 @@ "code": "UNRESOLVED_RENDER_VALUE", "severity": "review", "file": "packages/template-atelier-solopreneur/taro/index.tsx", - "target": "atelier-solopreneur.detail.projectDetail", + "target": "atelier-solopreneur.detail.projectFacts", "page": "detail", "expression": "[item.category, item.area, item.series].filter", "line": 340, @@ -1248,7 +1248,7 @@ "code": "DYNAMIC_TARGET_REVIEW", "severity": "review", "file": "packages/template-atelier-solopreneur/taro/index.tsx", - "line": 433, + "line": 453, "message": "动态目标需用真实 manifest 和实际记录验证分支。", "reviewStatus": "source-reviewed", "decision": "formTargets 为固定映射,模板只对 inquiry 注入 chips 和隐私区,其余共享页面保持原 children;没有动态业务 binding。", @@ -1860,7 +1860,7 @@ "severity": "review", "file": "packages/template-atelier-solopreneur/taro/index.tsx", "page": "detail", - "target": "atelier-solopreneur.detail.projectDetail", + "target": "atelier-solopreneur.detail.projectFacts", "expression": "[item.category, item.area, item.series].filter(Boolean).map", "line": 340, "message": "需要核对循环项或间接映射,不能视为已覆盖。", diff --git a/apps/admin/src/features/services/OfferingEditorModal.tsx b/apps/admin/src/features/services/OfferingEditorModal.tsx index a328e22..2c96b0c 100644 --- a/apps/admin/src/features/services/OfferingEditorModal.tsx +++ b/apps/admin/src/features/services/OfferingEditorModal.tsx @@ -13,14 +13,6 @@ import type { PreviewSelection, PreviewTarget } from "../brand/preview-selection import type { FormInstance } from "antd"; import "./ServicesPage.css"; -const OFFERING_BASE_FIELD_BINDINGS: Record = { - name: "offering.name", - summary: "offering.summary", - description: "offering.description", - priceText: "offering.priceText", - coverUrl: "offering.coverUrl", -}; - type OfferingEditorModalProps = { open: boolean; editingOffering: Offering | null; @@ -33,7 +25,7 @@ type OfferingEditorModalProps = { selectedTarget: PreviewTarget | undefined; templateFieldSection: TemplateAdminSection; hasTemplateDetailCopy: boolean; - listTarget: PreviewTarget; + listTarget: PreviewTarget | undefined; detailTarget: PreviewTarget | undefined; saving: boolean; onClose: () => void; @@ -67,25 +59,21 @@ export function OfferingEditorModal({ onEditInBrand, }: OfferingEditorModalProps) { const formScroll = useRef(null); - const defaultPreviewTarget = previewPage === "offerings" ? listTarget : detailTarget; - const previewSelectionTarget = selectedTarget ?? defaultPreviewTarget; + const previewPageTarget = previewPage === "offerings" ? listTarget : detailTarget; + const previewSelectionTarget = selectedTarget ?? previewPageTarget; + const viewOptions = [ + ...(listTarget ? [{ value: "offerings" as const, label: "列表卡片" }] : []), + ...(detailTarget ? [{ value: "detail" as const, label: "详情内容" }] : []), + ]; const previewSelection: PreviewSelection | undefined = previewSelectionTarget ? previewSelectionTarget.source === "offering" && editingOffering ? { targetKey: previewSelectionTarget.key, recordId: editingOffering.id } : { targetKey: previewSelectionTarget.key } : undefined; - // 点选某个区块后,右侧只保留该区块真正会展示的字段;未点选时仍展示完整表单。 - const visibleBaseFields = (() => { - if (!selectedTarget) return undefined; - if (selectedTarget.source !== "offering") return new Set(); - const bindings = new Set(activePreviewBindings); - return new Set( - Object.entries(OFFERING_BASE_FIELD_BINDINGS) - .filter(([, binding]) => bindings.has(binding)) - .map(([name]) => name), - ); - })(); - const isBaseFieldVisible = (name: string) => !visibleBaseFields || visibleBaseFields.has(name); + // 标准字段与模板字段使用同一份 manifest binding;点选后只显示当前区域真正声明的字段。 + const activeBindingSet = new Set(activePreviewBindings); + const isBaseFieldVisible = (name: string) => + !selectedTarget || activeBindingSet.has(`offering.${name}`); const showDescriptionField = !hasTemplateDetailCopy && isBaseFieldVisible("description"); const hasVisibleBaseFields = ["kind", "name", "summary", "priceText", "coverUrl", "sortOrder", "isEnabled"].some((name) => @@ -120,10 +108,7 @@ export function OfferingEditorModal({ onValuesChange(allValues)} - onFinish={onFinish} + // 动态隐藏的字段会被卸载,onFinish 默认只返回仍挂载的字段。 + // 提交时读取完整表单存储,避免切换区块后隐藏字段的修改丢失。 + onFinish={() => onFinish(form.getFieldsValue(true) as Record)} >
{selectedTarget ? ( diff --git a/apps/admin/src/features/services/ServicesPage.tsx b/apps/admin/src/features/services/ServicesPage.tsx index b7c545e..0254c02 100644 --- a/apps/admin/src/features/services/ServicesPage.tsx +++ b/apps/admin/src/features/services/ServicesPage.tsx @@ -34,53 +34,35 @@ export function ServicesPage() { const sections = workspace.data?.templateContent?.admin.sections ?? []; const previewTargets = useMemo(() => previewTargetsByPage(sections), [sections]); const fieldsByTarget = useMemo(() => previewFieldsByTarget(sections), [sections]); + // 只使用 manifest 中真实存在的业务卡片区域;模板没有对应区域时不显示列表预览。 const listTarget = useMemo( - () => - previewTargets.offerings.find((target) => - templateFields.some((field) => field.previewTarget === target.key), - ) ?? { - key: "offering.list.item", - label: "业务卡片", - page: "offerings", - source: "offering" as const, - }, - [previewTargets, templateFields], + () => previewTargets.offerings.find((target) => target.source === "offering"), + [previewTargets], ); const detailTarget = useMemo( () => previewTargets.detail.find((target) => target.source === "offering"), [previewTargets], ); - const listFields = useMemo( - () => templateFields.filter((field) => field.previewTarget === listTarget.key), - [templateFields, listTarget.key], - ); - const detailFields = useMemo( - () => templateFields.filter((field) => field.previewTarget === detailTarget?.key), - [templateFields, detailTarget?.key], - ); - const otherFields = useMemo( - () => - templateFields.filter( - (field) => !listFields.includes(field) && !detailFields.includes(field), - ), - [templateFields, listFields, detailFields], - ); - const pageTemplateFields = useMemo( - () => - editor.previewPage === "offerings" - ? [...listFields, ...otherFields.filter((field) => field.page === "offerings")] - : [...detailFields, ...otherFields.filter((field) => field.page === "detail")], - [editor.previewPage, listFields, detailFields, otherFields], - ); + // 页面级字段必须按该页所有真实预览区域收集,不能只取列表/详情首个区域, + // 否则模板把详情拆成多个区域后,未点选的“全部字段”会漏掉后续区域。 + const pageTemplateFields = useMemo(() => { + const targets = + editor.previewPage === "offerings" ? previewTargets.offerings : previewTargets.detail; + const targetKeys = new Set(targets.map((target) => target.key)); + return templateFields.filter( + (field) => + (field.previewTarget && targetKeys.has(field.previewTarget)) || + (!field.previewTarget && + field.page === (editor.previewPage === "offerings" ? listTarget?.page : "detail")), + ); + }, [editor.previewPage, listTarget?.page, previewTargets, templateFields]); // 点选预览区块后,右侧只保留该区块对应的字段,与小程序页面点选编辑保持一致。 const selectedTarget = useMemo(() => { if (!editor.previewTargetKey) return undefined; - return ( - previewTargets[editor.previewPage].find((target) => target.key === editor.previewTargetKey) ?? - (editor.previewTargetKey === listTarget.key ? listTarget : undefined) ?? - (editor.previewTargetKey === detailTarget?.key ? detailTarget : undefined) + return previewTargets[editor.previewPage].find( + (target) => target.key === editor.previewTargetKey, ); - }, [editor.previewPage, editor.previewTargetKey, previewTargets, listTarget, detailTarget]); + }, [editor.previewPage, editor.previewTargetKey, previewTargets]); const activeTemplateFields = useMemo( () => selectedTarget @@ -114,13 +96,13 @@ export function ServicesPage() { const navigateToBrand = () => { if (!editor.editingOffering) return; + const target = + selectedTarget ?? (editor.previewPage === "offerings" ? listTarget : detailTarget); + if (!target) return; void navigate("/admin/brand", { state: { - targetKey: - editor.previewTargetKey ?? - (editor.previewPage === "offerings" - ? listTarget.key - : (detailTarget?.key ?? listTarget.key)), + page: target.page, + targetKey: target.key, recordId: editor.editingOffering.id, }, }); diff --git a/apps/admin/src/features/services/offering-preview.ts b/apps/admin/src/features/services/offering-preview.ts index d2045a0..ca997d3 100644 --- a/apps/admin/src/features/services/offering-preview.ts +++ b/apps/admin/src/features/services/offering-preview.ts @@ -10,26 +10,30 @@ import { applyPresentationValues } from "../../lib/presentation/presentation-bin export function previewTargetsByPage( sections: AdminTemplateContent["admin"]["sections"], ): Record<"offerings" | "detail", PreviewTarget[]> { - const result: Record<"offerings" | "detail", PreviewTarget[]> = { - offerings: [], - detail: [], + const targets = sections.flatMap((section) => + (section.previewTargets ?? []).map((target) => ({ + ...target, + page: section.page, + source: section.fields.some( + (field) => field.binding.startsWith("offering.") && field.previewTarget === target.key, + ) + ? ("offering" as const) + : section.target, + })), + ); + const pages = [...new Set(sections.map((section) => section.page))]; + const offeringPages = pages.filter( + (page) => + page !== "detail" && + targets.some((target) => target.page === page && target.source === "offering"), + ); + // 业务卡片不一定在“服务页”:独立工坊把案例卡片放在首页。优先使用专门的 + // offerings 页,没有时退回第一个包含业务记录的页面。 + const listPage = offeringPages.find((page) => page === "offerings") ?? offeringPages[0]; + return { + offerings: listPage ? targets.filter((target) => target.page === listPage) : [], + detail: targets.filter((target) => target.page === "detail"), }; - for (const page of ["offerings", "detail"] as const) { - result[page] = sections - .filter((section) => section.page === page) - .flatMap((section) => - (section.previewTargets ?? []).map((target) => ({ - ...target, - page: section.page, - source: section.fields.some( - (field) => field.binding.startsWith("offering.") && field.previewTarget === target.key, - ) - ? "offering" - : section.target, - })), - ); - } - return result; } export function previewFieldsByTarget( diff --git a/apps/api/test/http.integration.test.js b/apps/api/test/http.integration.test.js index f468ea0..ed8eebf 100644 --- a/apps/api/test/http.integration.test.js +++ b/apps/api/test/http.integration.test.js @@ -390,7 +390,7 @@ test("平台模板管理员可以按行业预览版本,且预览不写入品 // 预览只允许使用平台当前已部署的精确 renderer 版本;复用 prepare 阶段导入的基线版本, // 避免测试自造一个 renderer 尚未部署的新版本。 const baselineVersion = await prisma.templatePackageVersion.findFirstOrThrow({ - where: { packageKey: "atelier-solopreneur", version: "1.3.2", status: "published" }, + where: { packageKey: "atelier-solopreneur", version: "1.3.3", status: "published" }, }); const versionId = baselineVersion.id; @@ -2338,7 +2338,7 @@ test("brand creation options are owner-scoped", async () => { assert.equal(linjingScheme.isLatestForPackage, true); const atelierScheme = options.pageSchemes.find((scheme) => scheme.name.includes("工坊")); assert.ok(atelierScheme); - assert.equal(atelierScheme.version, "1.3.2"); + assert.equal(atelierScheme.version, "1.3.3"); assert.deepEqual(atelierScheme.supportedBusinessTypes, ["personal"]); assert.equal( options.pageSchemes.some( @@ -2366,7 +2366,7 @@ test("owner can create an isolated brand", async () => { const atelier = await prisma.templatePackageVersion.findFirstOrThrow({ where: { packageKey: "atelier-solopreneur", - version: "1.3.2", + version: "1.3.3", status: "published", }, }); diff --git a/apps/taro/test/browser/atelier-services-editor.spec.ts b/apps/taro/test/browser/atelier-services-editor.spec.ts new file mode 100644 index 0000000..245bd94 --- /dev/null +++ b/apps/taro/test/browser/atelier-services-editor.spec.ts @@ -0,0 +1,370 @@ +import fs from "node:fs"; +import { test, expect, type Page } from "@playwright/test"; + +const adminOrigin = process.env.ADMIN_URL || "http://localhost:3005"; +const consoleWarnings = new WeakMap(); + +test.beforeEach(({ page }) => { + const warnings: string[] = []; + consoleWarnings.set(page, warnings); + page.on("console", (message) => { + const text = message.text(); + const isWarning = + message.type() === "warning" || + (message.type() === "error" && + (text.startsWith("Warning:") || + text.includes("non-boolean attribute") || + text.includes("empty string"))); + if (isWarning) warnings.push(text); + }); +}); + +test.afterEach(({ page }) => { + expect(consoleWarnings.get(page) ?? []).toEqual([]); +}); + +const templateContent = JSON.parse( + fs.readFileSync("../../packages/template-atelier-solopreneur/template.json", "utf8"), +); +const brand = { + id: "atelier-brand-fixture", + slug: "atelier-preview-fixture", + name: "独立工坊", + templateKey: "personal", + tagline: "为独立创作者建立可信的个人品牌", + description: "品牌策略、视觉叙事与长期陪伴。", + avatarUrl: "", + coverUrl: "", + hours: "工作日 10:00-18:00", + address: "杭州", + deliveryNote: "", + contactPhone: "13800138000", + contactWechat: "atelier-example", + config: { + founder: "林予", + title: "品牌顾问", + atelier: { + identity: { status: "可预约", experience: "8 年经验", tags: [] }, + badges: [{ title: "真实案例" }], + features: [], + audiences: [], + deliverables: [], + process: [], + proofs: [], + faqs: [], + }, + visualPresentation: { + home: { + eyebrow: "PERSONAL BRAND", + title: "让专业被看见", + subtitle: "从定位到表达", + primaryAction: "预约沟通", + secondaryAction: "查看案例", + casesTitle: "试点案例", + casesSubtitle: "真实项目", + caseAction: "全部案例", + featuresTitle: "合作方式", + featuresEnglish: "METHOD", + audienceTitle: "适合谁", + audienceEnglish: "AUDIENCE", + ctaTitle: "一起梳理品牌", + ctaSubtitle: "先聊清楚目标", + ctaAction: "发起咨询", + }, + detail: { + priceLabel: "合作方式", + spaceLabel: "适用场景", + backgroundTitle: "项目背景", + conceptTitle: "设计理念", + craftsTitle: "交付要点", + materialsTitle: "能力构成", + inquiryAction: "咨询这个案例", + inquiryHint: "提交后会在工作台跟进", + }, + }, + }, +}; +const adminOffering = { + id: "atelier-project-fixture", + kind: "service", + name: "山野茶品牌焕新", + summary: "为在地茶品牌建立清晰、可信的视觉与叙事体系。", + description: "案例详情说明", + priceText: "¥ 30,000 起", + coverUrl: "", + isEnabled: true, + sortOrder: 0, + config: { + categoryKey: "portfolio", + categoryLabel: "品牌视觉", + area: "杭州", + series: "品牌焕新", + spaceType: "线上与线下", + keywords: ["个人品牌", "视觉叙事"], + details: { + background: "品牌已有稳定客群,但表达缺少统一线索。", + designConcept: "以山野节气为线索,建立克制的视觉秩序。", + crafts: ["品牌定位梳理", "视觉系统交付", "落地陪跑"], + materialsList: [ + { name: "品牌策略", spec: "定位、叙事与内容框架" }, + { name: "视觉系统", spec: "标志、字体、色彩与版式" }, + ], + }, + detailHero: "", + }, +}; +const runtimeWorkspace = { + schemaVersion: "1.0.0", + publication: { status: "published", version: 1 }, + brand: { + ...brand, + ...brand.config, + visualPresentation: brand.config.visualPresentation, + atelier: brand.config.atelier, + }, + visualTemplate: { + key: "atelier-solopreneur", + version: templateContent.version, + name: templateContent.displayName, + }, + templateData: {}, + navigation: { tabs: [] }, + offerings: [ + { + id: adminOffering.id, + name: adminOffering.name, + summary: adminOffering.summary, + priceText: adminOffering.priceText, + coverUrl: adminOffering.coverUrl, + enabled: true, + kind: adminOffering.kind, + priceAmount: null, + schemaKey: "personal-offering", + schemaVersion: "1.0.0", + presentation: { + categoryKey: adminOffering.config.categoryKey, + categoryLabel: adminOffering.config.categoryLabel, + heroImage: adminOffering.config.detailHero, + keywords: adminOffering.config.keywords, + media: [], + details: structuredClone(adminOffering.config.details), + area: adminOffering.config.area, + series: adminOffering.config.series, + spaceType: adminOffering.config.spaceType, + }, + sections: [], + }, + ], + inquiryForms: [], + trustItems: [], + trustPresentation: {}, + capabilities: [], + theme: { colors: {} }, +}; + +test("独立工坊业务编辑按真实 manifest 区块过滤字段", async ({ page }) => { + test.setTimeout(90000); + let savedBody: any; + await page.setViewportSize({ width: 1920, height: 1000 }); + await page.route("**/api/**", async (route) => { + const url = new URL(route.request().url()); + const path = url.pathname.replace(/^\/api/, ""); + if (path === "/admin/session/current") + return route.fulfill({ status: 401, json: { error: { message: "未登录" } } }); + if (path === "/admin/session/login") + return route.fulfill({ + json: { + displayName: "测试管理员", + role: "owner", + mustChangePassword: false, + }, + }); + if (path === "/admin/brands") + return route.fulfill({ json: [{ id: brand.id, role: "owner", brand }] }); + if (path === "/admin/workspace/offerings") + return route.fulfill({ + json: [{ ...adminOffering, config: structuredClone(adminOffering.config) }], + }); + if (path === "/admin/workspace/forms") return route.fulfill({ json: [] }); + if ( + path === `/admin/workspace/offerings/${adminOffering.id}` && + route.request().method() === "PATCH" + ) { + savedBody = route.request().postDataJSON(); + Object.assign(adminOffering, structuredClone(savedBody)); + runtimeWorkspace.offerings[0] = { + ...runtimeWorkspace.offerings[0], + name: adminOffering.name, + summary: adminOffering.summary, + priceText: adminOffering.priceText, + coverUrl: adminOffering.coverUrl, + presentation: { + ...runtimeWorkspace.offerings[0].presentation, + ...structuredClone(adminOffering.config), + details: structuredClone(adminOffering.config.details), + heroImage: adminOffering.config.detailHero, + }, + }; + return route.fulfill({ json: structuredClone(adminOffering) }); + } + if (path === "/admin/workspace") + return route.fulfill({ + json: { + brand, + installations: [], + fields: [], + offerings: [{ ...adminOffering, config: structuredClone(adminOffering.config) }], + forms: [], + templateContent, + }, + }); + if (path === "/admin/config/brand") return route.fulfill({ json: brand }); + if (path === "/admin/workspace/preview") + return route.fulfill({ json: structuredClone(runtimeWorkspace) }); + if (path === "/public/workspace") + return route.fulfill({ json: structuredClone(runtimeWorkspace) }); + return route.fulfill({ json: {} }); + }); + + await page.goto(`${adminOrigin}/admin/services`); + await page.getByLabel("账号").fill("admin"); + await page.getByLabel("密码").fill("fixture-password"); + await page.locator('button[type="submit"]').click(); + await page.getByRole("button", { name: "编辑详情" }).click(); + + const editor = page.locator(".service-offering-editor"); + const preview = editor.locator(".component-template-preview"); + await expect(preview.locator(".atelier-page")).toBeVisible(); + await expect(preview).toHaveAttribute( + "data-active-target", + "atelier-solopreneur.detail.projectHero", + ); + await expect(preview).toHaveAttribute("data-active-record-id", adminOffering.id); + + // 头图与标题:只出现名称、简介、封面和详情主图,不出现案例信息或正文区块字段。 + await preview.locator(".atelier-title").click(); + await expect(preview).toHaveAttribute( + "data-active-target", + "atelier-solopreneur.detail.projectHero", + ); + await expect(page.getByText("正在编辑「案例头图与标题」", { exact: true })).toBeVisible(); + await expect(page.getByLabel("名称", { exact: true })).toBeVisible(); + await expect(page.getByLabel("一句话说明", { exact: true })).toBeVisible(); + await expect(editor.locator('[data-presentation-binding="offering.coverUrl"]')).toBeVisible(); + await expect( + editor.locator('[data-presentation-binding="offering.config.detailHero"]'), + ).toBeVisible(); + await expect(page.getByLabel("价格展示", { exact: true })).toHaveCount(0); + await expect(page.getByLabel("项目背景", { exact: true })).toHaveCount(0); + await expect(page.getByLabel("交付要点", { exact: true })).toHaveCount(0); + + // 案例信息:只出现报价与事实字段,标题、封面、详情主图消失。 + await preview.locator(".atelier-detail-facts .atelier-detail-value").first().click(); + await expect(preview).toHaveAttribute( + "data-active-target", + "atelier-solopreneur.detail.projectFacts", + ); + await expect(page.getByText("正在编辑「案例信息」", { exact: true })).toBeVisible(); + await expect(page.getByLabel("价格展示", { exact: true })).toBeVisible(); + await expect(page.getByLabel("案例类别", { exact: true })).toBeVisible(); + await expect(page.getByLabel("项目地点", { exact: true })).toBeVisible(); + await expect(page.getByLabel("方案名称", { exact: true })).toBeVisible(); + await expect(page.getByLabel("适用场景", { exact: true })).toBeVisible(); + await expect( + editor.locator('[data-presentation-binding="offering.config.keywords"]'), + ).toBeVisible(); + await expect(page.getByLabel("名称", { exact: true })).toHaveCount(0); + await expect(page.getByLabel("一句话说明", { exact: true })).toHaveCount(0); + await expect(page.getByLabel("详情主图", { exact: true })).toHaveCount(0); + + // 背景、理念、交付要点、能力构成分别只保留一个区块字段。 + await preview.getByText("品牌已有稳定客群,但表达缺少统一线索。").click(); + await expect(preview).toHaveAttribute( + "data-active-target", + "atelier-solopreneur.detail.projectBackground", + ); + await expect( + editor.locator('[data-presentation-binding="offering.config.details.background"]'), + ).toBeVisible(); + await expect( + editor.locator('[data-presentation-binding="offering.config.details.designConcept"]'), + ).toHaveCount(0); + await expect(page.getByLabel("价格展示", { exact: true })).toHaveCount(0); + + await preview.getByText("以山野节气为线索,建立克制的视觉秩序。").click(); + await expect(preview).toHaveAttribute( + "data-active-target", + "atelier-solopreneur.detail.projectConcept", + ); + await expect( + editor.locator('[data-presentation-binding="offering.config.details.designConcept"]'), + ).toBeVisible(); + await expect( + editor.locator('[data-presentation-binding="offering.config.details.background"]'), + ).toHaveCount(0); + + await preview.getByText("品牌定位梳理").click(); + await expect(preview).toHaveAttribute( + "data-active-target", + "atelier-solopreneur.detail.projectCrafts", + ); + await expect( + editor.locator('[data-presentation-binding="offering.config.details.crafts"]'), + ).toBeVisible(); + await expect( + editor.locator('[data-presentation-binding="offering.config.details.materialsList"]'), + ).toHaveCount(0); + + await preview.getByText("品牌策略 定位、叙事与内容框架", { exact: true }).click(); + await expect(preview).toHaveAttribute( + "data-active-target", + "atelier-solopreneur.detail.projectMaterials", + ); + await expect( + editor.locator('[data-presentation-binding="offering.config.details.materialsList"]'), + ).toBeVisible(); + await expect( + editor.locator('[data-presentation-binding="offering.config.details.crafts"]'), + ).toHaveCount(0); + + await preview.getByText("品牌已有稳定客群,但表达缺少统一线索。").click(); + await page.getByLabel("项目背景", { exact: true }).fill("弹窗里更新后的项目背景"); + await expect(preview.getByText("弹窗里更新后的项目背景", { exact: true })).toBeVisible(); + + // “查看全部字段”恢复完整表单。 + await page.getByRole("button", { name: "查看全部字段" }).click(); + await expect(page.getByLabel("名称", { exact: true })).toBeVisible(); + await expect(page.getByLabel("价格展示", { exact: true })).toBeVisible(); + await expect(page.getByLabel("项目背景", { exact: true })).toBeVisible(); + + // 列表卡片来自真实首页案例区域;右侧只显示名称、简介和封面。 + await page.getByText("列表卡片", { exact: true }).click(); + await expect(preview).toHaveAttribute("data-active-target", "atelier.home.case"); + await expect(preview).toHaveAttribute("data-active-record-id", adminOffering.id); + await expect(editor.locator(".service-offering-editor__view")).toContainText("列表卡片"); + await expect(preview.locator(".atelier-case")).toContainText(adminOffering.name); + await preview.locator(".atelier-case .atelier-card-title").click(); + await expect(page.getByText("正在编辑「试点案例卡片」", { exact: true })).toBeVisible(); + await expect(page.getByLabel("名称", { exact: true })).toBeVisible(); + await expect(page.getByLabel("一句话说明", { exact: true })).toBeVisible(); + await expect(editor.locator('[data-presentation-binding="offering.coverUrl"]')).toBeVisible(); + await expect(page.getByLabel("价格展示", { exact: true })).toHaveCount(0); + await expect( + editor.locator('[data-presentation-binding="offering.config.detailHero"]'), + ).toHaveCount(0); + await expect(page.getByLabel("项目背景", { exact: true })).toHaveCount(0); + + await page + .locator(".ant-modal-footer") + .getByRole("button", { name: "确 定", exact: true }) + .click(); + await expect(page.getByText("业务提供项已保存")).toBeVisible(); + expect(savedBody.name).toBe(adminOffering.name); + expect(savedBody.config.details.background).toBe("弹窗里更新后的项目背景"); + expect(savedBody.config.details.designConcept).toBe("以山野节气为线索,建立克制的视觉秩序。"); + expect(savedBody.config.details.crafts).toEqual(["品牌定位梳理", "视觉系统交付", "落地陪跑"]); + expect(savedBody.config.details.materialsList).toEqual([ + { name: "品牌策略", spec: "定位、叙事与内容框架" }, + { name: "视觉系统", spec: "标志、字体、色彩与版式" }, + ]); +}); diff --git a/apps/taro/test/browser/brand-creation-and-page-scheme.spec.ts b/apps/taro/test/browser/brand-creation-and-page-scheme.spec.ts index f8ccd5d..8f1fa86 100644 --- a/apps/taro/test/browser/brand-creation-and-page-scheme.spec.ts +++ b/apps/taro/test/browser/brand-creation-and-page-scheme.spec.ts @@ -10,10 +10,10 @@ const businesses = [ const pageSchemes = [ { - templatePackageVersionId: "atelier-v132", + templatePackageVersionId: "atelier-v133", name: "独立创作者画册", description: "个人品牌页面方案", - version: "1.3.2", + version: "1.3.3", supportedBusinessTypes: ["personal"], isLatestForPackage: true, }, @@ -228,7 +228,7 @@ test("创建品牌成功后进入新品牌工作区", async ({ page }) => { name: "新的独立品牌", slug: "new-atelier", businessType: "personal", - templatePackageVersionId: "atelier-v132", + templatePackageVersionId: "atelier-v133", }); await page.waitForURL("**/admin/overview"); await expect(page.getByRole("heading", { name: "品牌概览" })).toBeVisible(); @@ -268,7 +268,7 @@ test("创建品牌按业务类型过滤页面方案,失败后保留输入", as name: "测试独立品牌", slug: "test-atelier", businessType: "personal", - templatePackageVersionId: "atelier-v132", + templatePackageVersionId: "atelier-v133", }); }); diff --git a/apps/taro/test/browser/services-editor.spec.ts b/apps/taro/test/browser/services-editor.spec.ts index 30f4fb7..3a07459 100644 --- a/apps/taro/test/browser/services-editor.spec.ts +++ b/apps/taro/test/browser/services-editor.spec.ts @@ -253,9 +253,14 @@ test("业务编辑弹窗预览列表与详情详情同一份内容", async ({ pa await page.getByRole("button", { name: "编辑详情" }).first().click(); await expect(page.locator(".component-template-preview")).toBeVisible(); + // 弹窗默认定位在详情页;跨入口编辑列表卡片前先切到列表并点选卡片, + // 确保“在小程序页面编辑”携带的是首页列表区域而不是详情区域。 + await page.getByText("列表卡片", { exact: true }).click(); + await preview.locator(".offering-card .dish-name").click(); + await expect(page.getByText("业务卡片对应字段", { exact: true })).toBeVisible(); await page.getByRole("button", { name: "在小程序页面编辑" }).click(); await expect(page.getByText("页面预览", { exact: true })).toBeVisible({ timeout: 15000 }); - await page.getByText("首页业务卡片", { exact: true }).click(); + // 跳转时已按 targetKey 自动选中列表卡片区域,无需再手动点选页面区域。 await expect( page.getByText("正在编辑业务提供项:列表实时预览餐品", { exact: true }), ).toBeVisible(); @@ -274,7 +279,7 @@ test("业务编辑弹窗预览列表与详情详情同一份内容", async ({ pa .locator(".ant-modal-footer") .getByRole("button", { name: "确 定", exact: true }) .click(); - await expect(page.getByText("业务提供项已保存")).toBeVisible(); + await expect(page.getByText("业务提供项已保存").last()).toBeVisible(); expect(savedBody.name).toBe("小程序页保存后的餐品"); expect(savedBody.summary).toBe("跨入口保存后的业务简介"); expect(savedBody.config.details.background).toBe("弹窗编辑后的餐品介绍"); diff --git a/config/template-build.json b/config/template-build.json index dd20af0..2392483 100644 --- a/config/template-build.json +++ b/config/template-build.json @@ -14,7 +14,7 @@ { "packageKey": "atelier-solopreneur", "packageName": "@personal-brand/template-atelier-solopreneur", - "version": "1.3.2" + "version": "1.3.3" } ] } diff --git a/docs/template-registry.md b/docs/template-registry.md index 8215684..05270c2 100644 --- a/docs/template-registry.md +++ b/docs/template-registry.md @@ -16,7 +16,7 @@ - acheng-campus-food@1.0.3:餐饮场景,使用 food 行业能力。 - linjing-editorial@1.0.7:林境建筑画册,仅适配 doors 业务类型。 -- atelier-solopreneur@1.3.2:独立工坊方向,适配 personal 行业。 +- atelier-solopreneur@1.3.3:独立工坊方向,适配 personal 行业。 以上是仓库盘点,不表示三个包都已经通过线上导入、预览、品牌安装和微信上传验收。生成目录当前位于 packages/config/src/generated-template-packages.ts,后续必须由导出和 conformance 流程生成并校验。 diff --git a/packages/config/src/generated-template-packages.ts b/packages/config/src/generated-template-packages.ts index 4525a97..84d2668 100644 --- a/packages/config/src/generated-template-packages.ts +++ b/packages/config/src/generated-template-packages.ts @@ -2086,7 +2086,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[ }, { "packageKey": "atelier-solopreneur", - "version": "1.3.2", + "version": "1.3.3", "displayName": "独立工坊 · 品牌小程序", "defaultBrandSlug": "atelier-studio", "runtimeContract": "1.0", @@ -2974,28 +2974,28 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[ "binding": "offering.name", "label": "案例名称", "input": "text", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectHero" }, { "key": "summary", "binding": "offering.summary", "label": "案例简介", "input": "textarea", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectHero" }, { "key": "priceText", "binding": "offering.priceText", "label": "合作方式 / 报价说明", "input": "text", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectFacts" }, { "key": "coverUrl", "binding": "offering.coverUrl", "label": "案例封面", "input": "image", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectHero" }, { "key": "categoryLabel", @@ -3020,49 +3020,49 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[ "label": "其他服务" } ], - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectFacts" }, { "key": "detailHero", "binding": "offering.config.detailHero", "label": "详情主图", "input": "image", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectHero" }, { "key": "area", "binding": "offering.config.area", "label": "项目地点", "input": "text", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectFacts" }, { "key": "series", "binding": "offering.config.series", "label": "方案名称", "input": "text", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectFacts" }, { "key": "spaceType", "binding": "offering.config.spaceType", "label": "适用场景", "input": "text", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectFacts" }, { "key": "background", "binding": "offering.config.details.background", "label": "项目背景", "input": "textarea", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectBackground" }, { "key": "designConcept", "binding": "offering.config.details.designConcept", "label": "设计理念", "input": "textarea", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectConcept" }, { "key": "keywords", @@ -3076,7 +3076,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[ "label": "关键词" } ], - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectFacts" }, { "key": "crafts", @@ -3090,7 +3090,7 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[ "label": "交付内容" } ], - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectCrafts" }, { "key": "materialsList", @@ -3107,13 +3107,33 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[ "label": "能力说明" } ], - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectMaterials" } ], "previewTargets": [ { - "key": "atelier-solopreneur.detail.projectDetail", - "label": "案例详情" + "key": "atelier-solopreneur.detail.projectHero", + "label": "案例头图与标题" + }, + { + "key": "atelier-solopreneur.detail.projectFacts", + "label": "案例信息" + }, + { + "key": "atelier-solopreneur.detail.projectBackground", + "label": "项目背景" + }, + { + "key": "atelier-solopreneur.detail.projectConcept", + "label": "设计理念" + }, + { + "key": "atelier-solopreneur.detail.projectCrafts", + "label": "交付要点" + }, + { + "key": "atelier-solopreneur.detail.projectMaterials", + "label": "能力构成" } ] }, @@ -6670,4 +6690,4 @@ export const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[ } ]; export const generatedTemplatePackageRegistryHash = - "06182e0005339404614b39e2051180d15bc6aa83f572194a7f4b7403650d3e8d"; + "866a8ce5f3d22f1712de73d8cae0480a38a71c1949f541ee8b9955695be38f11"; diff --git a/packages/template-atelier-solopreneur/package.json b/packages/template-atelier-solopreneur/package.json index c8082c9..e0ae8b7 100644 --- a/packages/template-atelier-solopreneur/package.json +++ b/packages/template-atelier-solopreneur/package.json @@ -1,6 +1,6 @@ { "name": "@personal-brand/template-atelier-solopreneur", - "version": "1.3.2", + "version": "1.3.3", "private": true, "type": "module", "files": [ diff --git a/packages/template-atelier-solopreneur/taro/index.tsx b/packages/template-atelier-solopreneur/taro/index.tsx index 3cc7782..6b88b68 100644 --- a/packages/template-atelier-solopreneur/taro/index.tsx +++ b/packages/template-atelier-solopreneur/taro/index.tsx @@ -304,7 +304,7 @@ function Detail({ workspace, id }: Props & { id?: string }) { return ( {item.image && ( @@ -314,7 +314,7 @@ function Detail({ workspace, id }: Props & { id?: string }) { {item.desc} @@ -347,16 +347,31 @@ function Detail({ workspace, id }: Props & { id?: string }) { {item.keywords.join(" · ")} + + {p.backgroundTitle} {item.details.background} + + {p.conceptTitle} {item.details.designConcept} + + {p.craftsTitle} @@ -365,6 +380,11 @@ function Detail({ workspace, id }: Props & { id?: string }) { {line} ))} + + {p.materialsTitle} diff --git a/packages/template-atelier-solopreneur/template.json b/packages/template-atelier-solopreneur/template.json index 12fa4c1..928c599 100644 --- a/packages/template-atelier-solopreneur/template.json +++ b/packages/template-atelier-solopreneur/template.json @@ -1,6 +1,6 @@ { "packageKey": "atelier-solopreneur", - "version": "1.3.2", + "version": "1.3.3", "displayName": "独立工坊 · 品牌小程序", "defaultBrandSlug": "atelier-studio", "runtimeContract": "1.0", @@ -883,28 +883,28 @@ "binding": "offering.name", "label": "案例名称", "input": "text", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectHero" }, { "key": "summary", "binding": "offering.summary", "label": "案例简介", "input": "textarea", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectHero" }, { "key": "priceText", "binding": "offering.priceText", "label": "合作方式 / 报价说明", "input": "text", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectFacts" }, { "key": "coverUrl", "binding": "offering.coverUrl", "label": "案例封面", "input": "image", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectHero" }, { "key": "categoryLabel", @@ -929,49 +929,49 @@ "label": "其他服务" } ], - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectFacts" }, { "key": "detailHero", "binding": "offering.config.detailHero", "label": "详情主图", "input": "image", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectHero" }, { "key": "area", "binding": "offering.config.area", "label": "项目地点", "input": "text", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectFacts" }, { "key": "series", "binding": "offering.config.series", "label": "方案名称", "input": "text", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectFacts" }, { "key": "spaceType", "binding": "offering.config.spaceType", "label": "适用场景", "input": "text", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectFacts" }, { "key": "background", "binding": "offering.config.details.background", "label": "项目背景", "input": "textarea", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectBackground" }, { "key": "designConcept", "binding": "offering.config.details.designConcept", "label": "设计理念", "input": "textarea", - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectConcept" }, { "key": "keywords", @@ -985,7 +985,7 @@ "label": "关键词" } ], - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectFacts" }, { "key": "crafts", @@ -999,7 +999,7 @@ "label": "交付内容" } ], - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectCrafts" }, { "key": "materialsList", @@ -1016,13 +1016,33 @@ "label": "能力说明" } ], - "previewTarget": "atelier-solopreneur.detail.projectDetail" + "previewTarget": "atelier-solopreneur.detail.projectMaterials" } ], "previewTargets": [ { - "key": "atelier-solopreneur.detail.projectDetail", - "label": "案例详情" + "key": "atelier-solopreneur.detail.projectHero", + "label": "案例头图与标题" + }, + { + "key": "atelier-solopreneur.detail.projectFacts", + "label": "案例信息" + }, + { + "key": "atelier-solopreneur.detail.projectBackground", + "label": "项目背景" + }, + { + "key": "atelier-solopreneur.detail.projectConcept", + "label": "设计理念" + }, + { + "key": "atelier-solopreneur.detail.projectCrafts", + "label": "交付要点" + }, + { + "key": "atelier-solopreneur.detail.projectMaterials", + "label": "能力构成" } ] },