From 821438cfe4475fae6f57725822407aa04463cb24 Mon Sep 17 00:00:00 2001 From: qyyfw Date: Fri, 10 Jul 2026 21:01:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BD=91=E7=AB=99=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86=E8=BE=93=E5=85=A51=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=A2=E5=A4=B1=E7=84=A6=E7=82=B9=20-=20=E5=B0=86?= =?UTF-8?q?=20FormGroup/FormRow/FormActions=20=E6=8F=90=E5=8D=87=E5=88=B0?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E4=BD=9C=E7=94=A8=E5=9F=9F=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E6=AF=8F=E6=AC=A1=E9=87=8D=E6=B8=B2=E6=9F=93=E9=87=8D=E5=BB=BA?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/admin/SiteSettings.tsx | 38 ++++++++++++----------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/frontend/src/pages/admin/SiteSettings.tsx b/frontend/src/pages/admin/SiteSettings.tsx index 8ab1b30..3663132 100644 --- a/frontend/src/pages/admin/SiteSettings.tsx +++ b/frontend/src/pages/admin/SiteSettings.tsx @@ -7,6 +7,26 @@ const SVGIcon: React.FC<{ children: React.ReactNode; size?: number }> = ({ child ); +// 以下组件定义在模块作用域(不可放在 SiteSettings 内部),否则每次重渲染都会生成新的组件类型, +// 导致内部 input 被反复卸载/重建,输入时光标丢失、无法连续输入。 +const FormGroup: React.FC<{ label: string; required?: boolean; children: React.ReactNode }> = ({ label, required, children }) => ( +
+ + {children} +
+); + +const FormRow: React.FC<{ children: React.ReactNode }> = ({ children }) => ( +
{children}
+); + +const FormActions: React.FC<{ children: React.ReactNode }> = ({ children }) => ( +
{children}
+); + type TabKey = 'basic' | 'logo' | 'email' | 'sms' | 'registration'; const TABS: { key: TabKey; label: string; icon: React.ReactNode }[] = [ @@ -308,24 +328,6 @@ const SiteSettings: React.FC = () => { return
加载中...
; } - const FormGroup = ({ label, required, children }: { label: string; required?: boolean; children: React.ReactNode }) => ( -
- - {children} -
- ); - - const FormRow = ({ children }: { children: React.ReactNode }) => ( -
{children}
- ); - - const FormActions = ({ children }: { children: React.ReactNode }) => ( -
{children}
- ); - // ========== Render Tab Content ========== const renderTabContent = () => { switch (activeTab) {