mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-26 20:12:38 +08:00
refactor(App, MainSidebar, OpenedMinapps): streamline component code and enhance layout
- Simplified the handleClick function in App component by removing unnecessary line breaks. - Adjusted MainMenu component in MainSidebar to remove inline margin styling for cleaner layout. - Updated OpenedMinapps to apply margin styling directly to TabsContainer for improved spacing. - Removed the PinnedApps component to declutter the sidebar and enhance performance.
This commit is contained in:
parent
cdfa2ac13a
commit
8d23c810fe
@ -29,9 +29,7 @@ const App: FC<Props> = ({ app, onClick, size = 60, isLast }) => {
|
||||
|
||||
const handleClick = () => {
|
||||
if (!isHome) {
|
||||
setTimeout(() => {
|
||||
navigate('/')
|
||||
}, 300)
|
||||
setTimeout(() => navigate('/'), 300)
|
||||
}
|
||||
|
||||
openMinappKeepAlive(app)
|
||||
|
||||
@ -173,7 +173,7 @@ const MainSidebar: FC = () => {
|
||||
overflow: showAssistants ? 'initial' : 'hidden'
|
||||
}}>
|
||||
<MainNavbar />
|
||||
<MainMenu style={{ marginBottom: 4 }}>
|
||||
<MainMenu>
|
||||
<MainMenuItem active={isAppMenuExpanded} onClick={() => setIsAppMenuExpanded(!isAppMenuExpanded)}>
|
||||
<MainMenuItemLeft>
|
||||
<MainMenuItemIcon>
|
||||
|
||||
@ -81,7 +81,7 @@ const OpenedMinapps: FC = () => {
|
||||
if (!isShowApps) return <TabsContainer className="TabsContainer" />
|
||||
|
||||
return (
|
||||
<TabsContainer className="TabsContainer">
|
||||
<TabsContainer className="TabsContainer" style={{ marginBottom: 4 }}>
|
||||
<Divider />
|
||||
<TabsWrapper>
|
||||
<DragableList
|
||||
|
||||
@ -1,67 +0,0 @@
|
||||
import DragableList from '@renderer/components/DragableList'
|
||||
import MinAppIcon from '@renderer/components/Icons/MinAppIcon'
|
||||
import { useMinappPopup } from '@renderer/hooks/useMinappPopup'
|
||||
import { useMinapps } from '@renderer/hooks/useMinapps'
|
||||
import { useRuntime } from '@renderer/hooks/useRuntime'
|
||||
import type { MenuProps } from 'antd'
|
||||
import { Dropdown } from 'antd'
|
||||
import { isEmpty } from 'lodash'
|
||||
import { FC } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import styled from 'styled-components'
|
||||
|
||||
import { MainMenuItem, MainMenuItemIcon, MainMenuItemLeft, MainMenuItemText } from './MainSidebarStyles'
|
||||
|
||||
const PinnedApps: FC = () => {
|
||||
const { pinned, updatePinnedMinapps } = useMinapps()
|
||||
const { t } = useTranslation()
|
||||
const { openMinappKeepAlive } = useMinappPopup()
|
||||
const { openedKeepAliveMinapps } = useRuntime()
|
||||
|
||||
if (isEmpty(pinned)) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{ marginBottom: -10 }}>
|
||||
<Divider style={{ marginBottom: 5, marginTop: 5 }} />
|
||||
<DragableList list={pinned} onUpdate={updatePinnedMinapps} listStyle={{ margin: '5px 0', marginBottom: 0 }}>
|
||||
{(app) => {
|
||||
const menuItems: MenuProps['items'] = [
|
||||
{
|
||||
key: 'togglePin',
|
||||
label: t('minapp.sidebar.remove.title'),
|
||||
onClick: () => {
|
||||
const newPinned = pinned.filter((item) => item.id !== app.id)
|
||||
updatePinnedMinapps(newPinned)
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
return (
|
||||
<Dropdown menu={{ items: menuItems }} trigger={['contextMenu']} overlayStyle={{ zIndex: 10000 }}>
|
||||
<MainMenuItem key={app.id} onClick={() => openMinappKeepAlive(app)}>
|
||||
<MainMenuItemLeft>
|
||||
<MainMenuItemIcon>
|
||||
<MinAppIcon size={22} app={app} style={{ borderRadius: 6 }} sidebar />
|
||||
</MainMenuItemIcon>
|
||||
<MainMenuItemText>{app.name}</MainMenuItemText>
|
||||
</MainMenuItemLeft>
|
||||
</MainMenuItem>
|
||||
</Dropdown>
|
||||
)
|
||||
}}
|
||||
</DragableList>
|
||||
{isEmpty(openedKeepAliveMinapps) && <Divider style={{ marginBottom: 5, marginTop: 5 }} />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const Divider = styled.div`
|
||||
width: 100%;
|
||||
height: 1px;
|
||||
background-color: var(--color-border);
|
||||
opacity: 0.5;
|
||||
`
|
||||
|
||||
export default PinnedApps
|
||||
Loading…
Reference in New Issue
Block a user