From 9f77815ab5904739e80b4d9a066d68a4744d7f61 Mon Sep 17 00:00:00 2001 From: moux1024 <403053463@qq.com> Date: Wed, 22 Oct 2025 04:57:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20input=20focus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/FamousTemplate.tsx | 29 ++++++++++++++++++- .../CreateInput/VideoCreationForm.tsx | 15 +++++----- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/components/FamousTemplate.tsx b/components/FamousTemplate.tsx index 3ac7f70..1387091 100644 --- a/components/FamousTemplate.tsx +++ b/components/FamousTemplate.tsx @@ -80,7 +80,25 @@ const FamousTemplate: React.FC = ({ showTabs = true }) => { {topTemplates.map((t) => { return ( -
+
{ + const v = e.currentTarget.querySelector('video') as HTMLVideoElement | null + // @ts-ignore + v?.play?.() + }} + onMouseLeave={(e) => { + const v = e.currentTarget.querySelector('video') as HTMLVideoElement | null + // @ts-ignore + v?.pause?.() + if (v) { + // @ts-ignore + v.currentTime = 0 + } + }} + >
= ({ showTabs = true }) => {
{t.name}
+
+
{ if (!isTemplateSelected) { @@ -88,6 +87,11 @@ export default function VideoCreationForm() { const dispatch = useAppDispatch(); const selectedTemplateId = useAppSelector(state => state.creationTemplate.selectedTemplateId); + useEffect(() => { + setTimeout(() => { + mainTextInputRef.current?.focus(); + }, 0); + }, [mainTextInputRef]); /** Clear current template related states */ const clearTemplateSelection = () => { handleConfigChange('pcode', ''); @@ -393,20 +397,17 @@ export default function VideoCreationForm() { )} {/* Template Description */} {inputPlaceholder && ( -
-
{inputPlaceholder}
+
+
{inputPlaceholder}
)} {/* Text Input Area - Middle */} {shouldShowInput && (
- {isTemplateSelected?.freeInput[0].input_name && ( -
{`${isTemplateSelected?.freeInput[0].input_name}:`}
- )}