From 7e179a407e84dcbdfa5f1e2c07c0c0b042188706 Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Fri, 6 Sep 2024 18:03:06 +0800 Subject: [PATCH] feat: Add theme switching to Navbar - Added a new theme switching functionality to the Navbar. --- src/renderer/src/pages/home/Navbar.tsx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/renderer/src/pages/home/Navbar.tsx b/src/renderer/src/pages/home/Navbar.tsx index 19d48d91fb..2a77fb9ed4 100644 --- a/src/renderer/src/pages/home/Navbar.tsx +++ b/src/renderer/src/pages/home/Navbar.tsx @@ -10,6 +10,7 @@ import { useSettings } from '@renderer/hooks/useSettings' import { useShowAssistants, useShowTopics } from '@renderer/hooks/useStore' import { getDefaultTopic } from '@renderer/services/assistant' import { Assistant, Topic } from '@renderer/types' +import { Switch } from 'antd' import { FC, useCallback } from 'react' import { useTranslation } from 'react-i18next' import styled from 'styled-components' @@ -97,13 +98,13 @@ const HeaderNavbar: FC = ({ activeAssistant, setActiveAssistant, setActiv - - {theme === 'dark' ? ( - - ) : ( - - )} - + } + unCheckedChildren={} + checked={theme === 'dark'} + onChange={toggleTheme} + style={{ opacity: theme === 'dark' ? 0.6 : 1 }} + /> {topicPosition === 'right' && ( @@ -153,4 +154,12 @@ const TitleText = styled.span` font-weight: 500; ` +const ThemeSwitch = styled(Switch)` + -webkit-app-region: no-drag; + margin-right: 10px; + .icon-theme { + font-size: 14px; + } +` + export default HeaderNavbar