From 541304a763aba0e5dc59ed5a8aff9fd4ba183644 Mon Sep 17 00:00:00 2001 From: que01 Date: Fri, 9 Oct 2026 15:24:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E9=A1=B5=E4=B8=8E=E8=AE=B0=E5=BD=95=E9=A1=B5?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=97=B6=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/features/brand/component-renderers.jsx | 4 ++-- apps/taro/src/components/Records.tsx | 13 ++++++++++--- apps/taro/src/components/Success.tsx | 14 +++++++++++--- apps/taro/test/browser/admin-editor.spec.ts | 8 ++++++++ 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/apps/admin/src/features/brand/component-renderers.jsx b/apps/admin/src/features/brand/component-renderers.jsx index 7500eed..42b4695 100644 --- a/apps/admin/src/features/brand/component-renderers.jsx +++ b/apps/admin/src/features/brand/component-renderers.jsx @@ -8,8 +8,8 @@ import { TemplateAssetContext } from "./taro-web-components.jsx"; function pageContent({ workspace, page }) { if (page === "inquiry") return ; - if (page === "records") return ; - if (page === "success") return ; + if (page === "records") return ; + if (page === "success") return ; return null; } diff --git a/apps/taro/src/components/Records.tsx b/apps/taro/src/components/Records.tsx index 5b9e85e..8cd2bd6 100644 --- a/apps/taro/src/components/Records.tsx +++ b/apps/taro/src/components/Records.tsx @@ -25,13 +25,20 @@ const labels: Record = { converted: "已转化", closed: "已关闭", }; -export function Records({ workspace }: { workspace: RuntimeWorkspace }) { +export function Records({ + workspace, + preview = false, +}: { + workspace: RuntimeWorkspace; + preview?: boolean; +}) { const [records, setRecords] = useState([]); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); - const [authenticated, setAuthenticated] = useState(hasSession()); + const [authenticated, setAuthenticated] = useState(preview ? false : hasSession()); const p = presentation(workspace, "records"); const load = useCallback(() => { + if (preview) return; if (!hasSession()) { setAuthenticated(false); setRecords([]); @@ -46,7 +53,7 @@ export function Records({ workspace }: { workspace: RuntimeWorkspace }) { setAuthenticated(hasSession()); }) .finally(() => setLoading(false)); - }, []); + }, [preview]); useDidShow(load); return ( diff --git a/apps/taro/src/components/Success.tsx b/apps/taro/src/components/Success.tsx index 326555e..9147e62 100644 --- a/apps/taro/src/components/Success.tsx +++ b/apps/taro/src/components/Success.tsx @@ -4,10 +4,18 @@ import type { RuntimeWorkspace } from "@personal-brand/types"; import { presentation, object, text } from "../runtime/content"; import { brandSlug } from "../runtime/api"; import { navigate } from "../runtime/navigation"; -export function Success({ workspace }: { workspace: RuntimeWorkspace }) { +export function Success({ + workspace, + preview = false, +}: { + workspace: RuntimeWorkspace; + preview?: boolean; +}) { const p = presentation(workspace, "success"); - const result = object(Taro.getStorageSync(`latestInquiry:${brandSlug()}`)); - if (!text(result.id)) + const submitted = + preview || + Boolean(text(object(Taro.getStorageSync(`latestInquiry:${brandSlug()}`)).id)); + if (!submitted) return ( 尚未提交咨询 diff --git a/apps/taro/test/browser/admin-editor.spec.ts b/apps/taro/test/browser/admin-editor.spec.ts index 6c5fe2e..1e4a13f 100644 --- a/apps/taro/test/browser/admin-editor.spec.ts +++ b/apps/taro/test/browser/admin-editor.spec.ts @@ -102,6 +102,8 @@ const templateContent = { { key: "service", page: "service", label: "出摊服务" }, { key: "detail", page: "detail", label: "详情页" }, { key: "inquiry", page: "inquiry", label: "定制/咨询" }, + { key: "success", page: "success", label: "提交成功页" }, + { key: "records", page: "records", label: "记录页" }, ], assetSlots: [], trustContentTypes: [ @@ -413,6 +415,12 @@ test("Admin 按通用预览目标筛选字段并同步品牌草稿", async ({ pa await page.getByRole("button", { name: "浏览页面" }).click(); await preview.locator(".inquiry-form input").first().fill("预览访客"); await expect(preview.locator(".inquiry-form input").first()).toHaveValue("预览访客"); + await page.getByText("提交成功页", { exact: true }).click(); + await expect(preview.locator(".success-page")).toBeVisible(); + await expect(preview.locator(".success-page")).toContainText("已收到你的需求"); + await page.getByText("记录页", { exact: true }).click(); + await expect(preview.locator(".records-page")).toBeVisible(); + await expect(preview.locator(".records-page")).toContainText("请在微信小程序内登录查看"); await page.getByRole("button", { name: "点选编辑" }).click(); await page.getByText("套餐餐品", { exact: true }).click(); await expect