cherry-studio/src/renderer/src/components/app/Navbar.tsx
亢奋猫 75b8a5a6a7 feat: new ui (#8322)
* feat: ui switch

* chore: update migration version to 122 and adjust settings topic position

* refactor: replace PinnedApps component with SidebarPinnedApps and SidebarOpenedMinappTabs for improved structure

* feat(i18n): add launchpad apps and minapps translations for multiple languages

* style: update MinAppIcon and IconContainer dimensions for improved UI consistency

* refactor: remove unused SidebarContainer component from AppsPage

* refactor: adjust Navbar padding and enhance search functionality in AgentsPage

* feat(minapps): implement MinApps page and enhance mini app management features

- Added MinAppsPage for managing mini applications.
- Introduced NewAppButton for adding custom mini apps.
- Created MiniAppSettings for configuring mini app settings.
- Enhanced mini app icon management with MiniAppIconsManager.
- Updated Router to include MinAppsPage and replaced AppsPage with MinAppsPage.
- Added translations for new mini app features in multiple languages.

* wip

* refactor: rename App component to MinApp and streamline LaunchpadPage logic

- Renamed App component to MinApp for clarity.
- Removed unnecessary state management in LaunchpadPage.
- Simplified minapp sorting logic by directly using openedKeepAliveMinapps.

* feat(i18n): update translations for multiple languages and restructure title entries

- Added missing title entries for various sections in English, Japanese, Russian, Chinese (Simplified and Traditional).
- Restructured the launchpad and minapp translations for better organization.
- Enhanced navbar display settings translations across all supported languages.

* feat: add header prop to DraggableVirtualList and implement Add Topic button in TopicsTab

- Introduced a new `header` prop in the DraggableVirtualList component to allow custom header content.
- Added an Add Topic button in the TopicsTab with a corresponding styled component and translation support for multiple languages.
- Updated styles in AssistantsTab and adjusted overflow behavior in Tabs index for better UI experience.

* style: adjust margins and max-width for improved layout in various components

- Updated margin-top in HtmlArtifactsCard for consistent spacing.
- Set max-width in MessageGroup to enhance responsiveness based on navbar position.
- Modified Add Topic button in TopicsTab to emit an event for better functionality.

* fix: correct state property name in migration for navbar position

- Updated the migration logic to set the correct state property from `topicPosition` to `navbarPosition` for proper configuration handling.

* fix: adjust traffic light position and navbar height for improved UI consistency

- Updated traffic light position in WindowService to enhance layout.
- Adjusted navbar height in color.scss for better alignment across components.
- Modified TabContainer to track last settings path and improve navigation handling.

* style: update AddTopicButton styling for improved hover effect in TopicsTab

- Changed AddTopicButton from a button to a div for better styling flexibility.
- Removed dashed border and added background color on hover for enhanced user experience.
- Retained border-radius for consistent design across components.

* feat: add TextBadge component and integrate into Display and Memory settings

- Introduced a new TextBadge component for displaying styled badges.
- Integrated TextBadge into DisplaySettings to highlight the navbar title as "New".
- Replaced inline badge implementation in MemorySettings with the new TextBadge component for consistency and improved maintainability.

* fix: adjust tab and navbar styling for improved UI consistency

- Increased height of title bar overlays for better visual balance.
- Updated tab creation logic to prevent duplicate tabs for specific paths.
- Modified tab icon and close button sizes for a more compact design.
- Enhanced tab spacing and padding for improved layout across components.

* style: update PinnedMinapps component for improved UI consistency

- Increased icon size and adjusted border radius for better visual appeal.
- Modified TopNavContainer padding and margin for enhanced layout.
- Reduced dimensions of TopNavIcon for a more compact design.

* refactor: enhance TabsContainer logic and styling for improved tab management

- Introduced a new `removeSpecialTabs` function to manage special tab removal more effectively.
- Updated tab filtering logic to utilize a dedicated `specialTabs` array for better maintainability.
- Adjusted styling in PinnedMinapps for consistent icon sizing and background color improvements.

* style: adjust layout and padding for improved UI consistency in Chat and Inputbar components

- Updated main height calculation in Chat component to account for additional spacing.
- Modified padding in Inputbar component for better alignment when navbar is positioned at the top.
- Ensured consistent minimum height in Tabs component to match updated navbar height calculations.

* refactor: update app menu item text keys for improved localization

- Changed text keys in the app menu items from specific titles to a more generalized 'title' namespace for better consistency and maintainability.
- Ensured that the visual representation of the menu items remains unchanged while enhancing the localization structure.

* refactor: simplify sidebar toggle logic in ChatNavbar and Navbar components

- Removed unnecessary cooldown logic when toggling the visibility of assistants and topics.
- Updated HomePage to conditionally render the Navbar based on the sidebar state for improved UI responsiveness.

* refactor: streamline Chat component and introduce useChatMaxWidth hook

- Consolidated max width calculation logic into a new `useChatMaxWidth` hook for better reusability.
- Removed unused variables and simplified state management in the Chat component.
- Updated MessageGroup to utilize the new `useChatMaxWidth` hook for consistent layout handling.

* refactor: remove FloatingSidebar component and integrate AssistantsDrawer for improved UI management

- Deleted the FloatingSidebar component to streamline the codebase.
- Introduced AssistantsDrawer for managing assistant interactions, enhancing user experience.
- Updated Navbar and ChatNavbar components to utilize AssistantsDrawer instead of FloatingSidebar for better responsiveness and maintainability.

* refactor: implement TabsService for improved tab management functionality

- Introduced TabsService to centralize tab operations, including closing and setting active tabs.
- Updated TabsContainer and LaunchpadPage components to utilize TabsService for closing tabs, enhancing code maintainability.
- Made minor UI adjustments in PinnedMinapps for consistent icon sizing and layout improvements.

* fix: prevent default event behavior when not in fullscreen mode

- Updated WindowService to conditionally call event.preventDefault() only when the main window is not in fullscreen, improving event handling logic.
2025-07-23 14:36:39 +08:00

117 lines
3.3 KiB
TypeScript

import { isLinux, isMac, isWin } from '@renderer/config/constant'
import { useFullscreen } from '@renderer/hooks/useFullscreen'
import useNavBackgroundColor from '@renderer/hooks/useNavBackgroundColor'
import { useNavbarPosition } from '@renderer/hooks/useSettings'
import type { FC, PropsWithChildren } from 'react'
import type { HTMLAttributes } from 'react'
import styled from 'styled-components'
type Props = PropsWithChildren & HTMLAttributes<HTMLDivElement>
export const Navbar: FC<Props> = ({ children, ...props }) => {
const backgroundColor = useNavBackgroundColor()
const { isTopNavbar } = useNavbarPosition()
if (isTopNavbar) {
return null
}
return (
<NavbarContainer {...props} style={{ backgroundColor }}>
{children}
</NavbarContainer>
)
}
export const NavbarLeft: FC<Props> = ({ children, ...props }) => {
return <NavbarLeftContainer {...props}>{children}</NavbarLeftContainer>
}
export const NavbarCenter: FC<Props> = ({ children, ...props }) => {
return <NavbarCenterContainer {...props}>{children}</NavbarCenterContainer>
}
export const NavbarRight: FC<Props> = ({ children, ...props }) => {
const isFullscreen = useFullscreen()
return (
<NavbarRightContainer {...props} $isFullscreen={isFullscreen}>
{children}
</NavbarRightContainer>
)
}
export const NavbarMain: FC<Props> = ({ children, ...props }) => {
const isFullscreen = useFullscreen()
return (
<NavbarMainContainer {...props} $isFullscreen={isFullscreen}>
{children}
</NavbarMainContainer>
)
}
export const NavbarHeader: FC<Props> = ({ children, ...props }) => {
return <NavbarHeaderContent {...props}>{children}</NavbarHeaderContent>
}
const NavbarContainer = styled.div`
min-width: 100%;
display: flex;
flex-direction: row;
min-height: var(--navbar-height);
max-height: var(--navbar-height);
margin-left: ${isMac ? 'calc(var(--sidebar-width) * -1)' : 0};
padding-left: ${isMac ? 'var(--sidebar-width)' : 0};
-webkit-app-region: drag;
`
const NavbarLeftContainer = styled.div`
min-width: var(--assistants-width);
padding: 0 10px;
display: flex;
flex-direction: row;
align-items: center;
font-weight: bold;
color: var(--color-text-1);
`
const NavbarCenterContainer = styled.div`
flex: 1;
display: flex;
align-items: center;
padding: 0 ${isMac ? '20px' : 0};
font-weight: bold;
color: var(--color-text-1);
`
const NavbarRightContainer = styled.div<{ $isFullscreen: boolean }>`
min-width: var(--topic-list-width);
display: flex;
align-items: center;
padding: 0 12px;
padding-right: ${({ $isFullscreen }) => ($isFullscreen ? '12px' : isWin ? '140px' : isLinux ? '120px' : '12px')};
justify-content: flex-end;
`
const NavbarMainContainer = styled.div<{ $isFullscreen: boolean }>`
flex: 1;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: 0 ${isMac ? '20px' : 0};
font-weight: bold;
color: var(--color-text-1);
padding-right: ${({ $isFullscreen }) => ($isFullscreen ? '12px' : isWin ? '140px' : isLinux ? '120px' : '12px')};
`
const NavbarHeaderContent = styled.div`
flex: 1;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: 0 12px;
min-height: var(--navbar-height);
max-height: var(--navbar-height);
`