feat: 构建品牌视图与三栏页面编辑工作台
This commit is contained in:
1 parent
a2932b1134
commit
860d9266fe
7 files changed
+128
-20
No files matched your search
@@ -2,6 +2,24 @@
|
||||
max-width: 960px;
|
||||
}
|
||||
|
||||
.brand-page__content[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.brand-page__toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding: 16px 0;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
@media (max-width: 575px) {
|
||||
.brand-page__toolbar {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
|
||||
.brand-page__settings {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@@ -6,12 +6,15 @@ import {
|
||||
Input,
|
||||
Row,
|
||||
Select,
|
||||
Segmented,
|
||||
Space,
|
||||
Tag,
|
||||
Typography,
|
||||
message,
|
||||
} from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import type { BrandProfile } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
@@ -21,6 +24,7 @@ import { PresentationEditor } from "./PresentationEditor.js";
|
||||
import "./BrandPage.css";
|
||||
|
||||
export function BrandPage() {
|
||||
const [panel, setPanel] = useState("pages");
|
||||
const client = createApiClient();
|
||||
const queryClient = useQueryClient();
|
||||
const [form] = Form.useForm<BrandProfile>();
|
||||
@@ -50,7 +54,7 @@ export function BrandPage() {
|
||||
{!brand.data ? null : (
|
||||
<>
|
||||
<AdminPageHeader
|
||||
title="品牌资料"
|
||||
title="小程序工作台"
|
||||
description={
|
||||
template.data?.description
|
||||
? `先让访客理解你是谁、服务谁,以及为什么值得信任。${template.data.description}`
|
||||
@@ -58,7 +62,22 @@ export function BrandPage() {
|
||||
}
|
||||
extra={<Tag color="blue">{template.data?.name ?? "当前模板"}</Tag>}
|
||||
/>
|
||||
<div className="brand-page__content">
|
||||
<div className="brand-page__toolbar">
|
||||
<Segmented
|
||||
aria-label="工作台视图"
|
||||
value={panel}
|
||||
onChange={(value) => setPanel(String(value))}
|
||||
options={[
|
||||
{ value: "pages", label: "页面编辑" },
|
||||
{ value: "brand", label: "品牌资料" },
|
||||
]}
|
||||
/>
|
||||
<Space>
|
||||
<Tag>草稿工作区</Tag>
|
||||
<Link to="/admin/publication">检查与发布 →</Link>
|
||||
</Space>
|
||||
</div>
|
||||
<div className="brand-page__content" hidden={panel !== "brand"}>
|
||||
<div className="brand-page__settings">
|
||||
<Form
|
||||
form={form}
|
||||
@@ -201,14 +220,16 @@ export function BrandPage() {
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
<PresentationEditor
|
||||
templateContent={workspace.data?.templateContent}
|
||||
previewWorkspace={previewWorkspace.data}
|
||||
config={brand.data.config}
|
||||
brand={brand.data}
|
||||
loading={workspace.isLoading}
|
||||
error={workspace.error}
|
||||
/>
|
||||
<div hidden={panel !== "pages"}>
|
||||
<PresentationEditor
|
||||
templateContent={workspace.data?.templateContent}
|
||||
previewWorkspace={previewWorkspace.data}
|
||||
config={brand.data.config}
|
||||
brand={brand.data}
|
||||
loading={workspace.isLoading}
|
||||
error={workspace.error}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</QueryState>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
.presentation-editor {
|
||||
margin-top: 40px;
|
||||
padding-top: 28px;
|
||||
border-top: 1px solid #e8e8e8;
|
||||
margin-top: 0;
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.presentation-editor__header {
|
||||
@@ -42,6 +41,9 @@
|
||||
}
|
||||
|
||||
.presentation-editor__workspace {
|
||||
display: grid;
|
||||
grid-template-columns: 200px minmax(300px, 1fr) minmax(280px, 360px);
|
||||
grid-template-areas: "outline preview inspector";
|
||||
margin: 0 !important;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
@@ -50,17 +52,49 @@
|
||||
}
|
||||
|
||||
.presentation-editor__preview {
|
||||
grid-area: preview;
|
||||
padding: 20px !important;
|
||||
background: #f8fafc;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.presentation-editor__inspector {
|
||||
grid-area: inspector;
|
||||
padding: 24px !important;
|
||||
min-width: 0;
|
||||
border-left: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.presentation-editor__outline {
|
||||
grid-area: outline;
|
||||
padding: 20px 12px;
|
||||
border-right: 1px solid #e5e7eb;
|
||||
}
|
||||
.presentation-editor__regions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
}
|
||||
.presentation-editor__regions .ant-space-item {
|
||||
width: 100%;
|
||||
}
|
||||
.presentation-editor__regions .ant-btn {
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
.presentation-editor__regions .is-child-region {
|
||||
padding-left: 24px;
|
||||
}
|
||||
.presentation-editor__regions .ant-btn[aria-pressed="true"] {
|
||||
background: #e6f4ff;
|
||||
color: #0958d9;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.presentation-editor__preview .template-preview {
|
||||
height: 680px;
|
||||
min-height: 0;
|
||||
@@ -83,7 +117,15 @@
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
@media (max-width: 991px) {
|
||||
@media (max-width: 1199px) {
|
||||
.presentation-editor__workspace {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
grid-template-areas: "outline" "preview" "inspector";
|
||||
}
|
||||
.presentation-editor__outline {
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
}
|
||||
.presentation-editor__inspector {
|
||||
border-left: 0;
|
||||
border-top: 1px solid #e5e7eb;
|
||||
|
||||
@@ -570,8 +570,8 @@ export function PresentationEditor({
|
||||
/>
|
||||
)}
|
||||
</Space>
|
||||
<Row className="presentation-editor__workspace" gutter={[24, 24]} align="top">
|
||||
<Col className="presentation-editor__preview" xs={24} lg={12}>
|
||||
<div className="presentation-editor__workspace">
|
||||
<div className="presentation-editor__preview">
|
||||
<Typography.Title level={5}>页面预览</Typography.Title>
|
||||
{selectedPage === "detail" && draftWorkspace?.offerings.length ? (
|
||||
<Select
|
||||
@@ -600,11 +600,21 @@ export function PresentationEditor({
|
||||
targets={visibleTargets}
|
||||
onTargetSelected={handleTargetSelected}
|
||||
/>
|
||||
</div>
|
||||
<aside className="presentation-editor__outline" aria-label="页面区域">
|
||||
<Typography.Title level={5}>页面区域</Typography.Title>
|
||||
<Typography.Paragraph type="secondary">选择区域,编辑对应内容</Typography.Paragraph>
|
||||
{visibleTargets.length ? (
|
||||
<Space className="presentation-editor__regions" wrap style={{ marginTop: 16 }}>
|
||||
{visibleTargets.map((target) => (
|
||||
<Button
|
||||
key={target.key}
|
||||
className={
|
||||
visibleTargets.some((parent) => parent.children?.includes(target.key))
|
||||
? "is-child-region"
|
||||
: ""
|
||||
}
|
||||
aria-pressed={activeTarget === target.key}
|
||||
type={activeTarget === target.key ? "primary" : "default"}
|
||||
onClick={() => {
|
||||
const recordId =
|
||||
@@ -628,8 +638,11 @@ export function PresentationEditor({
|
||||
))}
|
||||
</Space>
|
||||
) : null}
|
||||
</Col>
|
||||
<Col className="presentation-editor__inspector" xs={24} lg={12}>
|
||||
{!visibleTargets.length ? (
|
||||
<Typography.Text type="secondary">此页为动态预览</Typography.Text>
|
||||
) : null}
|
||||
</aside>
|
||||
<div className="presentation-editor__inspector">
|
||||
<Typography.Title level={5}>
|
||||
{selectedTarget?.label ?? pageTitle(selectedPage ?? "home")}
|
||||
</Typography.Title>
|
||||
@@ -865,8 +878,8 @@ export function PresentationEditor({
|
||||
</Space>
|
||||
</Form>
|
||||
)}
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
) : null}
|
||||
</section>
|
||||
|
||||
Reference in new issue
Block a user