From 21e88b02ea262eb8946078db5c9ca6c202a7e662 Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Mon, 9 Jun 2025 14:39:29 +0800 Subject: [PATCH] refactor: simplify HomeTabs component by removing unused imports and commented code, update AssistantAddItem hover styles --- .../src/pages/home/Tabs/AssistantsTab.tsx | 7 +- src/renderer/src/pages/home/Tabs/index.tsx | 123 +----------------- 2 files changed, 2 insertions(+), 128 deletions(-) diff --git a/src/renderer/src/pages/home/Tabs/AssistantsTab.tsx b/src/renderer/src/pages/home/Tabs/AssistantsTab.tsx index 94e79cf203..c6041210eb 100644 --- a/src/renderer/src/pages/home/Tabs/AssistantsTab.tsx +++ b/src/renderer/src/pages/home/Tabs/AssistantsTab.tsx @@ -197,12 +197,7 @@ const AssistantAddItem = styled.div` cursor: pointer; &:hover { - background-color: var(--color-background-soft); - } - - &.active { - background-color: var(--color-background-soft); - border: 0.5px solid var(--color-border); + background-color: var(--color-list-item-hover); } ` diff --git a/src/renderer/src/pages/home/Tabs/index.tsx b/src/renderer/src/pages/home/Tabs/index.tsx index 99cf5dd2bb..dd619f83e5 100644 --- a/src/renderer/src/pages/home/Tabs/index.tsx +++ b/src/renderer/src/pages/home/Tabs/index.tsx @@ -1,12 +1,8 @@ import AddAssistantPopup from '@renderer/components/Popups/AddAssistantPopup' import { useAssistants, useDefaultAssistant } from '@renderer/hooks/useAssistant' -import { useSettings } from '@renderer/hooks/useSettings' -import { useShowTopics } from '@renderer/hooks/useStore' import { Assistant, Topic } from '@renderer/types' import { uuid } from '@renderer/utils' -import { Segmented as AntSegmented } from 'antd' import { FC } from 'react' -import { useTranslation } from 'react-i18next' import styled from 'styled-components' import Assistants from './AssistantsTab' @@ -19,37 +15,14 @@ interface Props { activeTopic: Topic setActiveAssistant: (assistant: Assistant) => void setActiveTopic: (topic: Topic) => void - position: 'left' | 'right' - forceToSeeAllTab?: boolean style?: React.CSSProperties } type Tab = 'assistants' | 'topic' | 'settings' -const HomeTabs: FC = ({ - tab, - activeAssistant, - activeTopic, - setActiveAssistant, - setActiveTopic, - position, - forceToSeeAllTab, - style -}) => { +const HomeTabs: FC = ({ tab, activeAssistant, activeTopic, setActiveAssistant, setActiveTopic, style }) => { const { addAssistant } = useAssistants() - const { topicPosition } = useSettings() const { defaultAssistant } = useDefaultAssistant() - const { showTopics, toggleShowTopics } = useShowTopics() - - const { t } = useTranslation() - - const showTab = !(position === 'left' && topicPosition === 'right') - - const assistantTab = { - label: t('assistants.abbr'), - value: 'assistants' - // icon: - } const onCreateAssistant = async () => { const assistant = await AddAssistantPopup.show() @@ -62,36 +35,6 @@ const HomeTabs: FC = ({ setActiveAssistant(assistant) } - // useEffect(() => { - // const unsubscribes = [ - // EventEmitter.on(EVENT_NAMES.SHOW_ASSISTANTS, (): any => { - // showTab && setTab('assistants') - // }), - // EventEmitter.on(EVENT_NAMES.SHOW_TOPIC_SIDEBAR, (): any => { - // showTab && setTab('topic') - // }), - // EventEmitter.on(EVENT_NAMES.SHOW_CHAT_SETTINGS, (): any => { - // showTab && setTab('settings') - // }), - // EventEmitter.on(EVENT_NAMES.SWITCH_TOPIC_SIDEBAR, () => { - // showTab && setTab('topic') - // if (position === 'left' && topicPosition === 'right') { - // toggleShowTopics() - // } - // }) - // ] - // return () => unsubscribes.forEach((unsub) => unsub()) - // }, [position, showTab, tab, toggleShowTopics, topicPosition]) - - // useEffect(() => { - // if (position === 'right' && topicPosition === 'right' && tab === 'assistants') { - // setTab('topic') - // } - // if (position === 'left' && topicPosition === 'right' && forceToSeeAllTab != true && tab !== 'assistants') { - // setTab('assistants') - // } - // }, [position, tab, topicPosition, forceToSeeAllTab]) - return ( @@ -134,68 +77,4 @@ const TabContent = styled.div` overflow-x: hidden; ` -const Divider = styled.div` - border-top: 0.5px solid var(--color-border); - margin-top: 10px; - margin-left: 10px; - margin-right: 10px; -` - -const Segmented = styled(AntSegmented)` - font-family: var(--font-family); - - &.ant-segmented { - background-color: transparent; - margin: 0 10px; - margin-top: 10px; - padding: 0; - } - .ant-segmented-item { - overflow: hidden; - transition: none !important; - height: 34px; - line-height: 34px; - background-color: transparent; - user-select: none; - border-radius: var(--list-item-border-radius); - box-shadow: none; - } - .ant-segmented-item-selected, - .ant-segmented-item-selected:active { - transition: none !important; - background-color: var(--color-list-item); - } - .ant-segmented-item-label { - align-items: center; - display: flex; - flex-direction: row; - justify-content: center; - font-size: 13px; - height: 100%; - } - .ant-segmented-item-label[aria-selected='true'] { - color: var(--color-text); - } - .icon-business-smart-assistant { - margin-right: -2px; - } - .ant-segmented-thumb { - transition: none !important; - background-color: var(--color-list-item); - border-radius: var(--list-item-border-radius); - box-shadow: none; - &:hover { - background-color: transparent; - } - } - .ant-segmented-item-label, - .ant-segmented-item-icon { - display: flex; - align-items: center; - } - /* These styles ensure the same appearance as before */ - border-radius: 0; - box-shadow: none; -` - export default HomeTabs