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 && ( +
+ +
+ )} +
+
+ ); +};