From 362b13ac43a1c54aafa46b8028746d77f53da0b1 Mon Sep 17 00:00:00 2001 From: xianyi Date: Tue, 27 Jan 2026 15:58:46 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E5=87=BA=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/layout/TopBar.tsx | 87 ++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 26 deletions(-) diff --git a/src/components/layout/TopBar.tsx b/src/components/layout/TopBar.tsx index d752960..98f6662 100644 --- a/src/components/layout/TopBar.tsx +++ b/src/components/layout/TopBar.tsx @@ -1,37 +1,72 @@ +import { useEffect, useState } from 'react'; + interface TopBarProps { search: string; onSearch: (value: string) => void; enableSearch?: boolean; operatorName?: string; onLoginClick?: () => void; + onLogout?: () => void; } -export const TopBar = ({ enableSearch = true, operatorName, onLoginClick }: TopBarProps) => ( -
-
- {enableSearch ? ( -
- {/* onSearch(e.target.value)} - className='text-sm' - /> */} -
- ) : ( -
圆和医疗 · 体检驾驶舱
- )} -
-
- -
-
-); +export const TopBar = ({ enableSearch = true, operatorName, onLoginClick, onLogout }: TopBarProps) => { + const [showMenu, setShowMenu] = useState(false); + const [displayName, setDisplayName] = useState(operatorName || ''); + + useEffect(() => { + setDisplayName(operatorName || ''); + }, [operatorName]); + + const handleLogout = () => { + localStorage.clear(); + setDisplayName(''); + setShowMenu(false); + onLogout?.(); + }; + + return ( +
+
+ {enableSearch ? ( +
+ {/* onSearch(e.target.value)} + className='text-sm' + /> */} +
+ ) : ( +
圆和医疗 · 体检驾驶舱
+ )} +
+
+ + {displayName && showMenu && ( +
+ +
+ )} +
+
+ ); +};