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) {