refactor: 整理品牌配置与小程序编辑工作区

This commit is contained in:
que01 committed 2026-10-10 10:20:14 +08:00
1 parent 849ae5df05
commit a2932b1134
13 files changed
+416 -63

No files matched your search

@@ -0,0 +1,30 @@
# Admin 编辑工作区重构
## 目标
把 Admin 的品牌配置与小程序页面编辑整理成一个层级清晰、可持续扩展的工作区。用户能够明确区分品牌基础资料、模板内容、业务记录和页面预览;页面预览、区域选择和字段编辑保持统一行为。
## 交付边界
- 品牌资料页面减少 Card 堆叠,形成连续的配置分组。
- 小程序页面配置成为主要编辑工作区,使用页面导航、预览画布和编辑面板的稳定布局。
- 详情页只提供业务记录选择和动态预览,不出现品牌级详情编辑表单。
- 预览选区、高亮、编辑状态、空状态和错误状态保持一致。
- 不改变后端数据模型和小程序业务语义;模板仍通过 manifest 声明页面、区域和字段。
## 设计原则
- 基础品牌事实只提供一个编辑入口。
- 模板专属字段由模板 manifest 驱动,不在共享页面中写行业逻辑。
- 预览是编辑上下文的一部分,不单独启动每个模板服务。
- 详情页数据来自选中的业务记录,视觉文案只能作为模板配置存在。
- 页面区块使用平面分组和分隔线,只有真正需要独立操作的区域使用 Card。
## 验收标准
- 1920、1280、1024、768 和 390 宽度下布局无横向溢出。
- 品牌资料、页面配置和发布状态的层级可以在首屏理解。
- 首页、业务、服务、详情、咨询、成功和记录页面均可切换并保持稳定高度。
- 点击模板区域后,选区高亮和右侧编辑面板始终同步。
- 详情页只能选择业务记录并预览,不能出现品牌级详情字段编辑。
- 通过 Admin/Taro typecheck、模板契约测试、生产构建和关键浏览器交互测试。
@@ -0,0 +1,20 @@
# Progress
## 2026-10-10
- 建立 Admin 编辑工作区重构 Epic。
- 当前已知问题:品牌资料上方存在多个连续 Card;小程序页面配置仍是普通 Card;预览区和编辑面板层级不够明确;详情页需要保持动态只读预览;选区高亮需要继续验证真实鼠标路径。
- 当前基线能力:模板 manifest、Taro renderer、RuntimeWorkspace 和 Admin 字段绑定已经形成契约;本 Epic 主要调整 Admin 信息架构与视觉层。
- 第 1 项已完成:确认 `BrandPage` 的两列 Card 结构、页面配置固定最小高度、模板说明右栏和编辑器内部重复导航。
- 第 2 项开始:先整理品牌资料页面层级,减少 Card 作为页面区块容器的使用。
- 第 2 项阶段性完成:`BrandPage` 已将品牌身份、联系合作、模板视觉改为连续分组,模板说明改为右侧辅助 `Alert`,并增加移动端断点。
- 验证:Admin typecheck 通过,`admin-editor.spec.ts` 2 项通过。
- 第 2 项完成,第 3 项开始:`PresentationEditor` 已移除外层 Card 和固定最小高度,改为独立工作区标题区;下一步处理工作区内部布局和视觉状态。
- 工作区完成:品牌配置使用连续分组;模板辅助信息移入基础资料尾部;编辑器使用完整宽度两栏布局,窄屏上下排列。
- 未选中时显示引导,详情页目标列表为空且不显示点选工具。
- 新增 1920/1280/1024/768/390 宽度无溢出断言和截图,已人工查看 1280 与 390 截图。
- 验证通过:Admin/Taro typecheck、Admin lint、全仓 format:check、19 项模板契约测试、Admin build、2 项浏览器测试。
- lint 暴露已有 InquiryPreviewEditor 类型问题,已通过 Form 泛型和普通对象传入修复。
- 保留已知构建 api chunk 超过 500 kB 提示,后续由 Admin 前端打包优化任务负责;记录在 ADR 0021。
- 本轮不涉及新增 API 或数据迁移。
@@ -0,0 +1,6 @@
id,title,status,task_type,depends_on,acceptance_criteria,validation_command,task_dir,notes
1,建立现状基线与页面覆盖清单,DONE,single-full,,记录当前布局层级、Card 使用、响应式问题和关键交互,测试基线截图与 DOM 检查,.codex-tasks/admin-editor-workspace/tasks/01-baseline/,已完成代码结构基线与验证记录
2,重构品牌配置的信息架构,DONE,single-full,1,品牌资料按身份联系模板视觉分组且减少卡片嵌套,Admin typecheck; browser brand page test,.codex-tasks/admin-editor-workspace/tasks/02-information-architecture/,已完成分组与模板说明层级调整
3,重构小程序页面编辑工作区,DONE,single-full,1;2,页面导航预览画布编辑面板形成稳定三栏或响应式两栏布局,Admin build; browser editor test,.codex-tasks/admin-editor-workspace/tasks/03-workspace-ui/,完整宽度两栏工作区,窄屏堆叠;详情页只读;未选中显示引导
4,统一编辑器视觉系统与状态样式,DONE,single-full,3,间距层级按钮选区空状态错误状态统一且无 Card 堆叠,Prettier; Admin build; screenshot review,.codex-tasks/admin-editor-workspace/tasks/04-visual-system/,统一导航工具条、画布边界、区域按钮和面板间距;已检查 1280 与 390 截图
5,全页面回归与交付验收,DONE,single-full,2;3;4,关键页面交互和响应式检查通过并记录残余风险,validate:templates; typecheck; build; browser tests,.codex-tasks/admin-editor-workspace/tasks/05-regression/,5 种宽度无溢出;浏览器 2 项、契约 19 项、格式、lint、类型和构建通过
1 id title status task_type depends_on acceptance_criteria validation_command task_dir notes
2 1 建立现状基线与页面覆盖清单 DONE single-full 记录当前布局层级、Card 使用、响应式问题和关键交互 测试基线截图与 DOM 检查 .codex-tasks/admin-editor-workspace/tasks/01-baseline/ 已完成代码结构基线与验证记录
3 2 重构品牌配置的信息架构 DONE single-full 1 品牌资料按身份联系模板视觉分组且减少卡片嵌套 Admin typecheck; browser brand page test .codex-tasks/admin-editor-workspace/tasks/02-information-architecture/ 已完成分组与模板说明层级调整
4 3 重构小程序页面编辑工作区 DONE single-full 1;2 页面导航预览画布编辑面板形成稳定三栏或响应式两栏布局 Admin build; browser editor test .codex-tasks/admin-editor-workspace/tasks/03-workspace-ui/ 完整宽度两栏工作区,窄屏堆叠;详情页只读;未选中显示引导
5 4 统一编辑器视觉系统与状态样式 DONE single-full 3 间距层级按钮选区空状态错误状态统一且无 Card 堆叠 Prettier; Admin build; screenshot review .codex-tasks/admin-editor-workspace/tasks/04-visual-system/ 统一导航工具条、画布边界、区域按钮和面板间距;已检查 1280 与 390 截图
6 5 全页面回归与交付验收 DONE single-full 2;3;4 关键页面交互和响应式检查通过并记录残余风险 validate:templates; typecheck; build; browser tests .codex-tasks/admin-editor-workspace/tasks/05-regression/ 5 种宽度无溢出;浏览器 2 项、契约 19 项、格式、lint、类型和构建通过
@@ -0,0 +1,32 @@
# 当前基线
## 页面结构
- `BrandPage` 使用两列布局:左侧 `xl=16`,右侧 `xl=8`。
- 左侧依次渲染“我是谁”“如何联系与合作”“模板与品牌视觉”三个 `Card`。
- 左侧表单之后渲染“小程序页面配置” `Card`。
- 右侧单独渲染“模板说明” `Card`。
- 页面配置内部还有页面导航、页面预览、详情业务选择器、预览目标按钮和右侧编辑表单。
## 已确认问题
- 配置 Card 与页面编辑 Card 在视觉上处于同一层级,用户难以判断基础资料和页面编辑的关系。
- “模板说明”占据右侧固定列,但对编辑流程帮助有限,造成首屏空间浪费。
- 页面配置使用 `minHeight: 760/620`,内容较少的页面会出现大面积空白。
- 页面配置内部的预览目标按钮与画布选区重复表达同一件事。
- 详情页已经改为动态预览提示,但页面整体仍沿用通用编辑器的表单布局。
- 品牌资料表单保存按钮位于所有配置分组之后,长页面中不够容易发现。
## 现有可复用能力
- 模板 manifest 声明页面、区域、字段和 preview target。
- `RuntimeWorkspace` 为组件预览提供品牌、业务记录、信任内容和咨询表单数据。
- `ComponentTemplatePreview` 支持点选、高亮、组合区域和浏览模式。
- `PresentationEditor` 已支持业务记录编辑、信任内容编辑和咨询字段编辑。
## 基线验证
- `pnpm --filter @personal-brand/admin typecheck`:通过。
- `pnpm --filter @personal-brand/taro typecheck`:通过。
- `pnpm validate:templates`:19 项模板契约测试通过。
- 已有 `admin-editor.spec.ts` 覆盖页面切换、预览选区、业务记录、信任内容、咨询表单和详情页动态预览。
@@ -0,0 +1,60 @@
.brand-page__content {
max-width: 960px;
}
.brand-page__settings {
min-width: 0;
}
.brand-settings-section {
padding: 24px 0;
border-top: 1px solid #f0f0f0;
}
.brand-settings-section:first-child {
padding-top: 8px;
border-top: 0;
}
.brand-settings-section__header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
margin-bottom: 20px;
}
.brand-settings-section__header .ant-typography {
margin: 0;
}
.brand-settings-section__header .ant-typography + .ant-typography {
display: block;
margin-top: 4px;
}
.brand-page__template-note {
margin-top: 24px;
}
@media (max-width: 1199px) {
.brand-page__content {
display: block;
}
.brand-page__template-note {
position: static;
margin-top: 24px;
}
}
@media (max-width: 575px) {
.brand-settings-section__header {
display: block;
}
.brand-settings-section__header .ant-tag {
display: inline-block;
margin-top: 10px;
}
}
+74 -32
View File
@@ -1,4 +1,16 @@
import { Button, Card, Col, Form, Input, Row, Select, Space, Tag, Typography, message } from "antd";
import {
Alert,
Button,
Col,
Form,
Input,
Row,
Select,
Space,
Tag,
Typography,
message,
} from "antd";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import type { BrandProfile } from "@personal-brand/api-client";
import { createApiClient } from "../../lib/api.js";
@@ -6,6 +18,7 @@ import { AdminPageHeader } from "../../components/AdminPageHeader.js";
import { ImageUrlField } from "../../components/ImageUrlField.js";
import { MutationError, QueryState } from "../../components/QueryState.js";
import { PresentationEditor } from "./PresentationEditor.js";
import "./BrandPage.css";
export function BrandPage() {
const client = createApiClient();
@@ -38,21 +51,31 @@ export function BrandPage() {
<>
<AdminPageHeader
title="品牌资料"
description="先让访客理解你是谁、服务谁,以及为什么值得信任。"
description={
template.data?.description
? `先让访客理解你是谁、服务谁,以及为什么值得信任。${template.data.description}`
: "先让访客理解你是谁、服务谁,以及为什么值得信任。"
}
extra={<Tag color="blue">{template.data?.name ?? "当前模板"}</Tag>}
/>
<Row gutter={[24, 24]} align="top">
<Col xs={24} xl={16}>
<div className="brand-page__content">
<div className="brand-page__settings">
<Form
form={form}
layout="vertical"
initialValues={brand.data}
onFinish={(values) => save.mutate(values)}
>
<Card
title="我是谁"
extra={<Typography.Text type="secondary">公开展示</Typography.Text>}
>
<section className="brand-settings-section" aria-labelledby="brand-identity-title">
<div className="brand-settings-section__header">
<div>
<Typography.Title id="brand-identity-title" level={4}>
我是谁
</Typography.Title>
<Typography.Text type="secondary">公开展示的品牌身份和定位。</Typography.Text>
</div>
<Tag>品牌基础信息</Tag>
</div>
<Form.Item
name="name"
label="品牌名称"
@@ -77,8 +100,18 @@ export function BrandPage() {
placeholder="让第一次认识你的人快速建立基本信任。"
/>
</Form.Item>
</Card>
<Card title="如何联系与合作" style={{ marginTop: 24 }}>
</section>
<section className="brand-settings-section" aria-labelledby="brand-contact-title">
<div className="brand-settings-section__header">
<div>
<Typography.Title id="brand-contact-title" level={4}>
如何联系与合作
</Typography.Title>
<Typography.Text type="secondary">
让访客知道联系渠道、服务范围和响应预期。
</Typography.Text>
</div>
</div>
<Row gutter={16}>
<Col xs={24} md={12}>
<Form.Item name="hours" label="可联系时间">
@@ -108,8 +141,18 @@ export function BrandPage() {
>
<Input.TextArea rows={3} placeholder="例如:收到咨询后 1 个工作日内回复。" />
</Form.Item>
</Card>
<Card title="模板与品牌视觉" style={{ marginTop: 24 }}>
</section>
<section className="brand-settings-section" aria-labelledby="brand-visual-title">
<div className="brand-settings-section__header">
<div>
<Typography.Title id="brand-visual-title" level={4}>
模板与品牌视觉
</Typography.Title>
<Typography.Text type="secondary">
模板负责业务表达,品牌信息仍由你统一维护。
</Typography.Text>
</div>
</div>
<Form.Item
name="templateKey"
label="业务表达模板"
@@ -139,7 +182,7 @@ export function BrandPage() {
</Form.Item>
</Col>
</Row>
</Card>
</section>
<Space direction="vertical" style={{ width: "100%", marginTop: 24 }}>
<MutationError error={save.error} />
<Button type="primary" htmlType="submit" loading={save.isPending} size="large">
@@ -147,26 +190,25 @@ export function BrandPage() {
</Button>
</Space>
</Form>
<PresentationEditor
templateContent={workspace.data?.templateContent}
previewWorkspace={previewWorkspace.data}
config={brand.data.config}
brand={brand.data}
loading={workspace.isLoading}
error={workspace.error}
</div>
{template.data ? (
<Alert
className="brand-page__template-note"
type="info"
showIcon
message={`当前使用:${template.data.name}`}
description={`适用场景:${template.data.serviceCategories.join("、") || "通用品牌展示"}`}
/>
</Col>
<Col xs={24} xl={8}>
{template.data && (
<Card title="模板说明" style={{ marginTop: 24 }}>
<Typography.Paragraph>{template.data.description}</Typography.Paragraph>
<Typography.Text type="secondary">
服务分类:{template.data.serviceCategories.join("、")}
</Typography.Text>
</Card>
)}
</Col>
</Row>
) : null}
</div>
<PresentationEditor
templateContent={workspace.data?.templateContent}
previewWorkspace={previewWorkspace.data}
config={brand.data.config}
brand={brand.data}
loading={workspace.isLoading}
error={workspace.error}
/>
</>
)}
</QueryState>
@@ -133,3 +133,12 @@
text-overflow: ellipsis;
white-space: nowrap;
}
.component-template-preview__tools[hidden] {
display: none;
}
.component-template-preview-shell:has(.component-template-preview__tools[hidden])
.component-template-preview {
height: 100%;
}
@@ -129,7 +129,11 @@ export function ComponentTemplatePreview({
return <Alert type="warning" showIcon message="此模板尚无组件预览,请使用页面预览" />;
return (
<div className="component-template-preview-shell">
<div className="component-template-preview__tools" aria-label="预览操作模式">
<div
className="component-template-preview__tools"
aria-label="预览操作模式"
hidden={!targets.length}
>
<button type="button" aria-pressed={mode === "edit"} onClick={() => setMode("edit")}>
点选编辑
</button>
@@ -144,13 +148,13 @@ export function ComponentTemplatePreview({
data-active-record-id={selection?.recordId}
data-editor-mode={mode}
onPointerMoveCapture={(event) => {
if (mode !== "edit") return;
if (mode !== "edit" || !targets.length) return;
const next = targetFor(event.target instanceof Element ? event.target : null);
if (next !== hovered) setHovered(next);
}}
onPointerLeave={() => setHovered(null)}
onClickCapture={(event) => {
if (mode !== "edit") return;
if (mode !== "edit" || !targets.length) return;
const canvas = root.current?.querySelector(".component-template-preview__canvas");
if (!event.target || !(event.target instanceof Node) || !canvas?.contains(event.target))
return;
@@ -16,7 +16,7 @@ export function InquiryPreviewEditor({
fieldKey: string;
onDraft: (fields: RuntimeInquiryForm["fields"]) => void;
}) {
const [form] = Form.useForm();
const [form] = Form.useForm<Record<string, unknown>>();
const cache = useQueryClient();
const query = useQuery({
queryKey: ["admin-inquiry-forms"],
@@ -25,12 +25,10 @@ export function InquiryPreviewEditor({
const record = query.data?.find((item) => item.id === runtime.key);
const field = runtime.fields.find((item) => item.key === fieldKey);
useEffect(() => {
if (field) form.setFieldsValue(field);
if (field) form.setFieldsValue({ ...field });
}, [fieldKey, runtime.key, form]);
const update = (values: Record<string, unknown>) =>
runtime.fields.map((item) =>
item.key === fieldKey ? ({ ...item, ...values } as typeof item) : item,
);
runtime.fields.map((item) => (item.key === fieldKey ? { ...item, ...values } : item));
const save = useMutation({
mutationFn: async (values: Record<string, unknown>) => {
if (!record || !field) throw new Error("表单已不存在,请刷新后重试");
@@ -71,7 +69,7 @@ export function InquiryPreviewEditor({
);
if (!field) return <Alert type="warning" message="字段已不存在" />;
return (
<Form
<Form<Record<string, unknown>>
form={form}
layout="vertical"
initialValues={field}
@@ -0,0 +1,104 @@
.presentation-editor {
margin-top: 40px;
padding-top: 28px;
border-top: 1px solid #e8e8e8;
}
.presentation-editor__header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
margin-bottom: 24px;
}
.presentation-editor__header .ant-typography {
margin-top: 0;
}
.presentation-editor__header .ant-typography + .ant-typography {
margin-bottom: 0;
}
.presentation-editor > .ant-space {
display: flex;
width: 100%;
margin-bottom: 24px !important;
padding: 6px;
border: 1px solid #e8e8e8;
border-radius: 10px;
background: #fafafa;
}
@media (max-width: 575px) {
.presentation-editor__header {
display: block;
}
.presentation-editor__header .ant-tag {
display: inline-block;
margin-top: 8px;
}
}
.presentation-editor__workspace {
margin: 0 !important;
border: 1px solid #e5e7eb;
border-radius: 12px;
overflow: hidden;
background: #fff;
}
.presentation-editor__preview {
padding: 20px !important;
background: #f8fafc;
min-width: 0;
}
.presentation-editor__inspector {
padding: 24px !important;
min-width: 0;
border-left: 1px solid #e5e7eb;
}
.presentation-editor__preview .template-preview {
height: 680px;
min-height: 0;
border-radius: 10px;
}
.presentation-editor__regions .ant-btn {
height: auto;
padding: 5px 10px;
font-size: 12px;
white-space: normal;
}
.presentation-editor__empty {
padding: 56px 16px;
text-align: center;
}
.presentation-editor__inspector .ant-form-item {
margin-bottom: 24px;
}
@media (max-width: 991px) {
.presentation-editor__inspector {
border-left: 0;
border-top: 1px solid #e5e7eb;
}
}
@media (max-width: 575px) {
.presentation-editor__preview,
.presentation-editor__inspector {
padding: 12px !important;
}
.presentation-editor__preview .template-preview {
height: 600px;
}
.presentation-editor__navigation {
max-width: 100%;
}
}
@@ -1,7 +1,6 @@
import {
Alert,
Button,
Card,
Divider,
Col,
Form,
@@ -50,6 +49,7 @@ import {
readPresentationValue,
type PresentationValues,
} from "./presentation-bindings.js";
import "./PresentationEditor.css";
interface PresentationEditorProps {
templateContent: AdminTemplateContent | null | undefined;
@@ -239,11 +239,7 @@ export function PresentationEditor({
const visibleTargets = useMemo<PreviewTarget[]>(
() =>
[...(templateContent?.admin.sections ?? []), ...recordSections]
.filter(
(section) =>
section.page === selectedPage &&
!(selectedPage === "detail" && section.target === "brand"),
)
.filter((section) => section.page === selectedPage && selectedPage !== "detail")
.flatMap((section) =>
(section.previewTargets ?? []).map((target) => ({
...target,
@@ -536,15 +532,18 @@ export function PresentationEditor({
: draftWorkspace?.offerings[0]?.id;
return (
<Card
title="小程序页面配置"
extra={templateContent ? <Tag color="blue">{templateContent.displayName}</Tag> : null}
style={{ marginTop: 32 }}
styles={{ body: { minHeight: breakpoints.md ? 760 : 620 } }}
>
<Typography.Paragraph type="secondary">
按小程序页面查找内容。这里修改的是草稿,发布后访客才会看到更新。
</Typography.Paragraph>
<section className="presentation-editor" aria-labelledby="presentation-editor-title">
<div className="presentation-editor__header">
<div>
<Typography.Title id="presentation-editor-title" level={3}>
小程序页面配置
</Typography.Title>
<Typography.Paragraph type="secondary">
按页面查找内容。这里修改的是草稿,发布后访客才会看到更新。
</Typography.Paragraph>
</div>
{templateContent ? <Tag color="blue">{templateContent.displayName}</Tag> : null}
</div>
{loading ? <Alert type="info" showIcon message="正在读取当前模板的编辑项目" /> : null}
{error ? (
<Alert type="warning" showIcon message="模板编辑项目读取失败,请刷新后重试。" />
@@ -554,7 +553,7 @@ export function PresentationEditor({
) : null}
{templateContent ? (
<>
<Space wrap style={{ marginBottom: 24 }}>
<Space className="presentation-editor__navigation" wrap>
{breakpoints.xs ? (
<Select
aria-label="选择小程序页面"
@@ -571,8 +570,8 @@ export function PresentationEditor({
/>
)}
</Space>
<Row gutter={[24, 24]} align="top">
<Col xs={24} xl={12}>
<Row className="presentation-editor__workspace" gutter={[24, 24]} align="top">
<Col className="presentation-editor__preview" xs={24} lg={12}>
<Typography.Title level={5}>页面预览</Typography.Title>
{selectedPage === "detail" && draftWorkspace?.offerings.length ? (
<Select
@@ -602,7 +601,7 @@ export function PresentationEditor({
onTargetSelected={handleTargetSelected}
/>
{visibleTargets.length ? (
<Space wrap style={{ marginTop: 16 }}>
<Space className="presentation-editor__regions" wrap style={{ marginTop: 16 }}>
{visibleTargets.map((target) => (
<Button
key={target.key}
@@ -630,7 +629,7 @@ export function PresentationEditor({
</Space>
) : null}
</Col>
<Col xs={24} xl={12}>
<Col className="presentation-editor__inspector" xs={24} lg={12}>
<Typography.Title level={5}>
{selectedTarget?.label ?? pageTitle(selectedPage ?? "home")}
</Typography.Title>
@@ -751,6 +750,13 @@ export function PresentationEditor({
: {})}
/>
)
) : !selectedTarget ? (
<div className="presentation-editor__empty">
<Typography.Title level={5}>选择要编辑的区域</Typography.Title>
<Typography.Paragraph type="secondary">
点击预览中的内容,或使用区域列表,查看并修改对应字段。
</Typography.Paragraph>
</div>
) : (
<Form
form={form}
@@ -863,7 +869,7 @@ export function PresentationEditor({
</Row>
</>
) : null}
</Card>
</section>
);
}
+16 -1
View File
@@ -332,6 +332,20 @@ 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 expect(page.getByText("选择要编辑的区域", { exact: true })).toBeVisible();
for (const width of [1920, 1280, 1024, 768, 390]) {
await page.setViewportSize({ width, height: 1000 });
const editor = page.locator(".presentation-editor");
await editor.scrollIntoViewIfNeeded();
await expect
.poll(() => editor.evaluate((element) => element.scrollWidth - element.clientWidth))
.toBeLessThanOrEqual(1);
await editor.screenshot({
path: "../../.codex-tasks/admin-editor-workspace/raw/editor-" + width + ".png",
});
}
await page.setViewportSize({ width: 1920, height: 1000 });
await page.getByRole("button", { name: "选择品牌信息区" }).click();
await expect(preview.locator(".component-template-preview__outline.is-selected")).toHaveAttribute(
"data-selected-target",
@@ -455,6 +469,7 @@ test("Admin 按通用预览目标筛选字段并同步品牌草稿", async ({ pa
await expect(preview.locator(".food-detail .bar button")).toBeVisible();
await preview.screenshot({ path: "../../.codex-tasks/preview-proportion/detail.png" });
await expect(page.getByText("详情页由所选业务内容动态生成")).toBeVisible();
await expect(page.getByRole("button", { name: "点选编辑" })).toHaveCount(0);
await expect(page.getByLabel("价格标题")).toHaveCount(0);
await expect(page.getByLabel("餐品介绍")).toHaveCount(0);
await page.getByText("定制/咨询", { exact: true }).click();
@@ -478,8 +493,8 @@ test("Admin 按通用预览目标筛选字段并同步品牌草稿", async ({ pa
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 page.getByRole("button", { name: "点选编辑" }).click();
await expect
.poll(() =>
preview.locator(".dish-media img").evaluate((image: HTMLImageElement) => image.naturalWidth),
+27
View File
@@ -0,0 +1,27 @@
# 0021 Admin 品牌配置与页面编辑工作区
## 背景
品牌基础资料、模板说明和可视化编辑被多个 Card 包裹,预览仅占页面的一部分。用户难以理解编辑入口与实际展示之间的关系。
## 决策
品牌基础资料使用连续的身份、联系合作和视觉分组。模板说明作为基础配置的辅助信息。页面编辑工作区使用完整页面宽度,页面导航位于顶部,预览与选区面板并列,窄屏上下排列。未选择区域时提供明确的点选引导,避免展示整页字段。
详情页只提供业务记录选择和动态预览,隐藏区域列表和点选工具;业务记录在业务提供项中维护。模板 manifest 的字段声明继续供业务内容编辑器和模板校验使用。
## 替代方案
继续嵌套 Card 会保留视觉层级混乱。单独建立第二套预览页面会造成 renderer 与模板实际展示分离。采用现有 renderer 和表单机制可以复用既有契约。
## 后果
配置与预览的空间更明确,区域编辑仍由模板声明驱动。基础品牌信息与模板区域保存仍分别执行,保存后的内容是草稿,需要发布才能公开展示。没有可编辑区域的页面不显示点选工具。
## 迁移计划
仅调整 Admin 布局与详情页编辑入口,不迁移数据库。使用已有字段绑定和 API,并通过多宽度截图、真实鼠标交互、类型检查、lint 和生产构建验收。
## 已知后续项
Admin 生产构建的共享 api chunk 超过 500 kB。由 Admin 前端后续打包优化任务负责拆分,当前构建成功。