From cd132c670e99ff5fd4225e97798bb99f40b52122 Mon Sep 17 00:00:00 2001 From: moux1024 <403053463@qq.com> Date: Tue, 21 Oct 2025 21:50:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20sticky=20banner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/FamousTemplate.tsx | 7 +++-- components/HomeBanner.tsx | 6 ++-- .../CreateInput/VideoCreationForm.tsx | 16 +++++++++- lib/store/creationTemplateSlice.ts | 29 +++++++++++++++++++ lib/store/store.ts | 2 ++ tailwind.config.js | 5 ++++ 6 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 lib/store/creationTemplateSlice.ts diff --git a/components/FamousTemplate.tsx b/components/FamousTemplate.tsx index 3cb3b15..b96e2c8 100644 --- a/components/FamousTemplate.tsx +++ b/components/FamousTemplate.tsx @@ -6,6 +6,8 @@ import { X } from "lucide-react" import TemplatePreviewModal from "@/components/common/TemplatePreviewModal" import { PcTemplateModal } from "@/components/ChatInputBox/PcTemplateModal" import { useTemplateStoryServiceHook } from "@/app/service/Interaction/templateStoryService" +import { useAppDispatch } from "@/lib/store/hooks" +import { selectTemplateById } from "@/lib/store/creationTemplateSlice" /** * A compact template showcase with a header and link to all templates. @@ -14,6 +16,7 @@ import { useTemplateStoryServiceHook } from "@/app/service/Interaction/templateS */ const FamousTemplate: React.FC = () => { const { templateStoryList, getTemplateStoryList, isLoading } = useTemplateStoryServiceHook() + const dispatch = useAppDispatch() const [isModalOpen, setIsModalOpen] = useState(false) const [initialTemplateId, setInitialTemplateId] = useState(undefined) @@ -127,8 +130,8 @@ const FamousTemplate: React.FC = () => { title={active.name} description={active.generateText || active.name} onPrimaryAction={() => { - setInitialTemplateId(active.id || active.template_id) - setIsModalOpen(true) + const id = active.id || active.template_id + dispatch(selectTemplateById(id)) setActiveTemplateId(null) }} primaryLabel="Try it Free" diff --git a/components/HomeBanner.tsx b/components/HomeBanner.tsx index 7a6e41f..bdc998b 100644 --- a/components/HomeBanner.tsx +++ b/components/HomeBanner.tsx @@ -159,11 +159,13 @@ export default function HomeBanner() { } return ( -
+
{/* Banner overlay - stacked above */}
([]); @@ -83,6 +85,8 @@ export default function VideoCreationForm() { const propInputRef = useRef(null); const mainTextInputRef = useRef(null); const { uploadFile } = useUploadFile(); + const dispatch = useAppDispatch(); + const selectedTemplateId = useAppSelector(state => state.creationTemplate.selectedTemplateId); /** Clear current template related states */ const clearTemplateSelection = () => { @@ -111,6 +115,16 @@ export default function VideoCreationForm() { }, 0); }; + /** Apply template selected from global store (e.g., FamousTemplate) */ + useEffect(() => { + if (!selectedTemplateId) return; + const selected = templateStoryList.find(t => (t.id || t.template_id) === selectedTemplateId); + if (!selected) return; + clearTemplateSelection(); + applyTemplateSelection(selected as StoryTemplateEntity); + dispatch(clearSelection()); + }, [selectedTemplateId, templateStoryList]); + /** Handle file upload */ const handleFileUpload = (event: React.ChangeEvent, type: PhotoType) => { const files = event.target.files; @@ -387,7 +401,7 @@ export default function VideoCreationForm() { {shouldShowInput && (
{isTemplateSelected?.freeInput[0].input_name && ( -
{isTemplateSelected?.freeInput[0].input_name}
+
{isTemplateSelected?.freeInput[0].input_name}
)}