From f9e88fb6eecdf47a16036765702896e0f8f4e965 Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Wed, 9 Jul 2025 19:28:45 +0800 Subject: [PATCH] refactor(Navbar): remove MinAppsPopover component - Deleted the MinAppsPopover component to streamline the Navbar. - Updated Navbar to remove references to MinAppsPopover, enhancing code maintainability. --- .../src/components/Popups/MinAppsPopover.tsx | 82 ------------------- src/renderer/src/pages/home/Navbar.tsx | 14 +--- 2 files changed, 2 insertions(+), 94 deletions(-) delete mode 100644 src/renderer/src/components/Popups/MinAppsPopover.tsx diff --git a/src/renderer/src/components/Popups/MinAppsPopover.tsx b/src/renderer/src/components/Popups/MinAppsPopover.tsx deleted file mode 100644 index 28a9621bc9..0000000000 --- a/src/renderer/src/components/Popups/MinAppsPopover.tsx +++ /dev/null @@ -1,82 +0,0 @@ -import { Center } from '@renderer/components/Layout' -import { useMinapps } from '@renderer/hooks/useMinapps' -import App from '@renderer/pages/apps/App' -import { Popover } from 'antd' -import { Empty } from 'antd' -import { isEmpty } from 'lodash' -import { FC, useEffect, useState } from 'react' -import { useHotkeys } from 'react-hotkeys-hook' -import styled from 'styled-components' - -import Scrollbar from '../Scrollbar' - -interface Props { - children: React.ReactNode -} - -const MinAppsPopover: FC = ({ children }) => { - const [open, setOpen] = useState(false) - const { minapps } = useMinapps() - - useHotkeys('esc', () => { - setOpen(false) - }) - - const handleClose = () => { - setOpen(false) - } - - const [maxHeight, setMaxHeight] = useState(window.innerHeight - 100) - - useEffect(() => { - const handleResize = () => { - setMaxHeight(window.innerHeight - 100) - } - - window.addEventListener('resize', handleResize) - - return () => { - window.removeEventListener('resize', handleResize) - } - }, []) - - const content = ( - - - {minapps.map((app) => ( - - ))} - {isEmpty(minapps) && ( -
- -
- )} -
-
- ) - - return ( - - {children} - - ) -} - -const PopoverContent = styled(Scrollbar)<{ maxHeight: number }>` - max-height: ${(props) => props.maxHeight}px; - overflow-y: auto; -` - -const AppsContainer = styled.div` - display: grid; - grid-template-columns: repeat(8, minmax(90px, 1fr)); - gap: 18px; -` - -export default MinAppsPopover diff --git a/src/renderer/src/pages/home/Navbar.tsx b/src/renderer/src/pages/home/Navbar.tsx index c9e2797a8b..4ef2c7e673 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 FloatingSidebar from '@renderer/components/Popups/FloatingSidebar' -import MinAppsPopover from '@renderer/components/Popups/MinAppsPopover' import SearchPopup from '@renderer/components/Popups/SearchPopup' import { isMac } from '@renderer/config/constant' import { useAssistant } from '@renderer/hooks/useAssistant' @@ -16,7 +15,7 @@ import { setNarrowMode } from '@renderer/store/settings' import { Assistant, Topic } from '@renderer/types' import { Tooltip } from 'antd' import { t } from 'i18next' -import { LayoutGrid, MessageSquareDiff, PanelLeftClose, PanelRightClose, Search } from 'lucide-react' +import { MessageSquareDiff, PanelLeftClose, PanelRightClose, Search } from 'lucide-react' import { FC, useCallback, useState } from 'react' import styled from 'styled-components' @@ -35,7 +34,7 @@ const HeaderNavbar: FC = ({ activeAssistant, setActiveAssistant, activeTo const { assistant } = useAssistant(activeAssistant.id) const { showAssistants, toggleShowAssistants } = useShowAssistants() const isFullscreen = useFullscreen() - const { topicPosition, sidebarIcons, narrowMode } = useSettings() + const { topicPosition, narrowMode } = useSettings() const { showTopics, toggleShowTopics } = useShowTopics() const dispatch = useAppDispatch() const [sidebarHideCooldown, setSidebarHideCooldown] = useState(false) @@ -145,15 +144,6 @@ const HeaderNavbar: FC = ({ activeAssistant, setActiveAssistant, activeTo - {sidebarIcons.visible.includes('minapp') && ( - - - - - - - - )} {topicPosition === 'right' && !showTopics && !sidebarHideCooldown && (