From 7df1060370053a5a6729a841cf627ac2903eada5 Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Mon, 8 Sep 2025 20:58:40 +0800 Subject: [PATCH] fix(Navbar): some bugs in old ui for custom max/min/close menu (#10045) * feat(Navbar): add WindowControls for Windows and Linux, clean up NavbarCenter component * feat(Navbar): add NavbarRight component for improved layout in MinAppsPage * feat(Navbar): enhance layout and styling for WindowControls and Navbar components * lint err * fix new ui --- .../src/components/Tab/TabContainer.tsx | 2 +- .../WindowControls/WindowControls.styled.ts | 6 +- src/renderer/src/components/app/Navbar.tsx | 23 ++-- src/renderer/src/pages/home/Navbar.tsx | 123 ++++++++---------- .../src/pages/minapps/MinAppsPage.tsx | 13 +- .../settings/DataSettings/DataSettings.tsx | 2 +- 6 files changed, 78 insertions(+), 91 deletions(-) diff --git a/src/renderer/src/components/Tab/TabContainer.tsx b/src/renderer/src/components/Tab/TabContainer.tsx index ba5be5b1fd..9108014d53 100644 --- a/src/renderer/src/components/Tab/TabContainer.tsx +++ b/src/renderer/src/components/Tab/TabContainer.tsx @@ -269,8 +269,8 @@ const TabsContainer: React.FC = ({ children }) => { - + {children} diff --git a/src/renderer/src/components/WindowControls/WindowControls.styled.ts b/src/renderer/src/components/WindowControls/WindowControls.styled.ts index 61d208d925..c962e139e5 100644 --- a/src/renderer/src/components/WindowControls/WindowControls.styled.ts +++ b/src/renderer/src/components/WindowControls/WindowControls.styled.ts @@ -1,11 +1,15 @@ import styled from 'styled-components' export const WindowControlsContainer = styled.div` + position: fixed; + top: 0; + right: 0; display: flex; align-items: center; - height: 100%; + height: var(--navbar-height); -webkit-app-region: no-drag; user-select: none; + z-index: 9999; ` export const ControlButton = styled.button<{ $isClose?: boolean }>` diff --git a/src/renderer/src/components/app/Navbar.tsx b/src/renderer/src/components/app/Navbar.tsx index 5eabba9a1f..4f5d53a95f 100644 --- a/src/renderer/src/components/app/Navbar.tsx +++ b/src/renderer/src/components/app/Navbar.tsx @@ -19,9 +19,12 @@ export const Navbar: FC = ({ children, ...props }) => { } return ( - - {children} - + <> + + {children} + + {(isWin || isLinux) && } + ) } @@ -30,17 +33,7 @@ export const NavbarLeft: FC = ({ children, ...props }) => { } export const NavbarCenter: FC = ({ children, ...props }) => { - return ( - - {children} - {/* Add WindowControls for Windows and Linux in NavbarCenter */} - {(isWin || isLinux) && ( -
- -
- )} -
- ) + return {children} } export const NavbarRight: FC = ({ children, ...props }) => { @@ -101,8 +94,8 @@ const NavbarRightContainer = styled.div<{ $isFullscreen: boolean }>` display: flex; align-items: center; padding: 0 12px; - padding-right: ${({ $isFullscreen }) => ($isFullscreen ? '12px' : isWin ? '140px' : isLinux ? '120px' : '12px')}; justify-content: flex-end; + flex: 1; ` const NavbarMainContainer = styled.div<{ $isFullscreen: boolean }>` diff --git a/src/renderer/src/pages/home/Navbar.tsx b/src/renderer/src/pages/home/Navbar.tsx index ec2998663f..20536e9321 100644 --- a/src/renderer/src/pages/home/Navbar.tsx +++ b/src/renderer/src/pages/home/Navbar.tsx @@ -1,7 +1,6 @@ import { Navbar, NavbarLeft, NavbarRight } from '@renderer/components/app/Navbar' import { HStack } from '@renderer/components/Layout' import SearchPopup from '@renderer/components/Popups/SearchPopup' -import WindowControls from '@renderer/components/WindowControls' import { isLinux, isWin } from '@renderer/config/constant' import { useAssistant } from '@renderer/hooks/useAssistant' import { modelGenerating } from '@renderer/hooks/useRuntime' @@ -66,36 +65,6 @@ const HeaderNavbar: FC = ({ activeAssistant, setActiveAssistant, activeTo }) } - const ControlButtons: FC<{ IconComponent: typeof NavbarIcon }> = ({ IconComponent }) => ( - <> - - SearchPopup.show()}> - - - - - - - - - - {topicPosition === 'right' && !showTopics && ( - - - - - - )} - {topicPosition === 'right' && showTopics && ( - - - - - - )} - - ) - return ( @@ -116,53 +85,65 @@ const HeaderNavbar: FC = ({ activeAssistant, setActiveAssistant, activeTo )} + {!showAssistants && ( + + toggleShowAssistants()} style={{ marginRight: 8, marginLeft: -12 }}> + + + + )} + + {!showAssistants && ( + + + + + + )} + + + + - - {!showAssistants && ( - - toggleShowAssistants()} style={{ marginRight: 8, marginLeft: -12 }}> + + + SearchPopup.show()}> + + + + + + + + + + {topicPosition === 'right' && !showTopics && ( + + + + + + )} + {topicPosition === 'right' && showTopics && ( + + )} - - {!showAssistants && ( - - - - - - )} - - - - {/* For Mac, show search and expand without WindowControls */} - {!isWin && !isLinux && } - - {/* Search, Expand and WindowControls positioned at the right edge */} - {(isWin || isLinux) && ( -
- - -
- )} ) diff --git a/src/renderer/src/pages/minapps/MinAppsPage.tsx b/src/renderer/src/pages/minapps/MinAppsPage.tsx index db82bf43a3..b824926ca7 100644 --- a/src/renderer/src/pages/minapps/MinAppsPage.tsx +++ b/src/renderer/src/pages/minapps/MinAppsPage.tsx @@ -1,6 +1,7 @@ -import { Navbar, NavbarMain } from '@renderer/components/app/Navbar' +import { Navbar, NavbarMain, NavbarRight } from '@renderer/components/app/Navbar' import App from '@renderer/components/MinApp/MinApp' import Scrollbar from '@renderer/components/Scrollbar' +import { isLinux, isWin } from '@renderer/config/constant' import { useMinapps } from '@renderer/hooks/useMinapps' import { useNavbarPosition } from '@renderer/hooks/useSettings' import { Button, Input } from 'antd' @@ -57,13 +58,21 @@ const AppsPage: FC = () => { value={search} onChange={(e) => setSearch(e.target.value)} /> + +