From 20eb160abf244d762bd186ef3d126463377fc465 Mon Sep 17 00:00:00 2001 From: que01 Date: Sat, 10 Oct 2026 17:08:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=93=E9=80=9A=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E4=B8=8E=E9=A1=B5=E9=9D=A2=E7=BC=96=E8=BE=91=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/RecordContentEditor.tsx | 27 ++++++++++++++++--- apps/admin/src/features/brand/BrandPage.tsx | 6 ++++- .../src/features/brand/PresentationEditor.tsx | 4 ++- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/apps/admin/src/components/RecordContentEditor.tsx b/apps/admin/src/components/RecordContentEditor.tsx index c430845..ca8e85b 100644 --- a/apps/admin/src/components/RecordContentEditor.tsx +++ b/apps/admin/src/components/RecordContentEditor.tsx @@ -14,6 +14,7 @@ import { } from "antd"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useEffect, useMemo } from "react"; +import { useNavigate } from "react-router-dom"; import type { Offering, TemplateAdminField, @@ -41,6 +42,7 @@ export interface RecordContentEditorProps { context: "visual" | "services"; onDraft?: (values: PresentationValues) => void; onSaved?: () => void; + visualSelection?: { targetKey: string; page: string }; } function renderField(field: TemplateAdminField) { @@ -103,7 +105,9 @@ export function RecordContentEditor({ context, onDraft, onSaved, + visualSelection, }: RecordContentEditorProps) { + const navigate = useNavigate(); const [form] = Form.useForm(); const queryClient = useQueryClient(); const recordName = "name" in record ? record.name : record.title; @@ -183,9 +187,26 @@ export function RecordContentEditor({ - + + + {source === "offering" ? ( + + ) : null} + ); diff --git a/apps/admin/src/features/brand/BrandPage.tsx b/apps/admin/src/features/brand/BrandPage.tsx index f3c2db8..a4e9ddb 100644 --- a/apps/admin/src/features/brand/BrandPage.tsx +++ b/apps/admin/src/features/brand/BrandPage.tsx @@ -14,17 +14,20 @@ import { } from "antd"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { useState } from "react"; -import { Link } from "react-router-dom"; +import { Link, useLocation } from "react-router-dom"; import type { BrandProfile } from "@personal-brand/api-client"; import { createApiClient } from "../../lib/api.js"; 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 type { PreviewSelection } from "./preview-selection.js"; import "./BrandPage.css"; import { useEditorDraft } from "./use-editor-draft.js"; export function BrandPage() { + const location = useLocation(); + const initialSelection = location.state as PreviewSelection | undefined; const [panel, setPanel] = useState("pages"); const [dirty, setDirty] = useState(false); useEditorDraft(dirty); @@ -236,6 +239,7 @@ export function BrandPage() { brand={brand.data} loading={workspace.isLoading} error={workspace.error} + {...(initialSelection ? { initialSelection } : {})} /> diff --git a/apps/admin/src/features/brand/PresentationEditor.tsx b/apps/admin/src/features/brand/PresentationEditor.tsx index 9cade3d..2609a1a 100644 --- a/apps/admin/src/features/brand/PresentationEditor.tsx +++ b/apps/admin/src/features/brand/PresentationEditor.tsx @@ -59,6 +59,7 @@ interface PresentationEditorProps { brand: BrandProfile; loading?: boolean; error?: unknown; + initialSelection?: PreviewSelection; } function trustSection( @@ -174,13 +175,14 @@ export function PresentationEditor({ brand, loading, error, + initialSelection, }: PresentationEditorProps) { const [form] = Form.useForm(); const queryClient = useQueryClient(); const navigate = useNavigate(); const breakpoints = Grid.useBreakpoint(); const [activePage, setActivePage] = useState(); - const [selection, setSelection] = useState(); + const [selection, setSelection] = useState(initialSelection); const [detailOfferingId, setDetailOfferingId] = useState(); const [recordDraft, setRecordDraft] = useState<{ source: "offering" | "trust";