refactor: 整理品牌配置与小程序编辑工作区
This commit is contained in:
1 parent
849ae5df05
commit
a2932b1134
13 files changed
+416
-63
No files matched your search
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user