From 1900a9d1e60eae7db035af78f38e499c251ed6b4 Mon Sep 17 00:00:00 2001 From: DIKER0K Date: Sat, 13 Dec 2025 22:32:12 +0500 Subject: [PATCH] fix TopBar --- src/renderer/components/TopBar.tsx | 53 ++++++++++++++++++------------ 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/src/renderer/components/TopBar.tsx b/src/renderer/components/TopBar.tsx index f7f940f..a90b56b 100644 --- a/src/renderer/components/TopBar.tsx +++ b/src/renderer/components/TopBar.tsx @@ -1,4 +1,13 @@ -import { Box, Button, Tab, Tabs, Typography, Menu, MenuItem, Divider } from '@mui/material'; +import { + Box, + Button, + Tab, + Tabs, + Typography, + Menu, + MenuItem, + Divider, +} from '@mui/material'; import CloseRoundedIcon from '@mui/icons-material/CloseRounded'; import { useLocation, useNavigate } from 'react-router-dom'; import ArrowBackRoundedIcon from '@mui/icons-material/ArrowBackRounded'; @@ -8,7 +17,7 @@ import { fetchCoins } from '../api'; import CustomTooltip from './Notifications/CustomTooltip'; import CoinsDisplay from './CoinsDisplay'; import { HeadAvatar } from './HeadAvatar'; -import { fetchPlayer } from './../api' +import { fetchPlayer } from './../api'; import CalendarMonthIcon from '@mui/icons-material/CalendarMonth'; import EmojiEventsIcon from '@mui/icons-material/EmojiEvents'; import PersonIcon from '@mui/icons-material/Person'; @@ -39,12 +48,13 @@ export default function TopBar({ onRegister, username }: TopBarProps) { const isVersionsExplorerPage = location.pathname.startsWith('/'); const isRegistrationPage = location.pathname === '/registration'; const navigate = useNavigate(); - const [value, setValue] = useState(1); + const [value, setValue] = useState(false); const [activePage, setActivePage] = useState('versions'); const tabsWrapperRef = useRef(null); const [skinUrl, setSkinUrl] = useState(''); - const [avatarAnchorEl, setAvatarAnchorEl] = - useState(null); + const [avatarAnchorEl, setAvatarAnchorEl] = useState( + null, + ); const [menuOpen, setMenuOpen] = useState(false); useEffect(() => { @@ -89,15 +99,16 @@ export default function TopBar({ onRegister, username }: TopBarProps) { } else if (location.pathname === '/') { setValue(1); setActivePage('versions'); - } else if (location.pathname.startsWith('/profile')) { - setValue(2); - setActivePage('profile'); } else if (location.pathname.startsWith('/shop')) { setValue(3); setActivePage('shop'); } else if (location.pathname.startsWith('/marketplace')) { setValue(4); setActivePage('marketplace'); + } else { + // любые страницы не из TopBar: /profile, /daily, /dailyquests, и т.д. + setValue(false); + setActivePage(''); } }, [location.pathname]); @@ -380,17 +391,17 @@ export default function TopBar({ onRegister, username }: TopBarProps) { }} > {!isLoginPage && !isRegistrationPage && username && ( - - - + + + )} {/* Кнопка регистрации, если на странице логина */} {!isLoginPage && !isRegistrationPage && username && ( @@ -524,7 +535,7 @@ export default function TopBar({ onRegister, username }: TopBarProps) { }, }} > - Профиль + Профиль {/* ===== 2 строка: ежедневные задания ===== */} @@ -592,7 +603,7 @@ export default function TopBar({ onRegister, username }: TopBarProps) { boxShadow: '0 4px 15px rgba(242, 113, 33, 0.4)', }, boxShadow: '0 2px 8px rgba(0, 0, 0, 0.3)', - m: '0 0 0 18vw' + m: '0 0 0 18vw', }} > Выйти