From fa8bf61532fdc5a1104d999c71c773b9f227f23c Mon Sep 17 00:00:00 2001 From: ousugo Date: Mon, 17 Feb 2025 03:48:42 +0800 Subject: [PATCH] fix: sidebar navigation and active state handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 当固定在侧边栏的小程序被打开时,对应图标显示为被选中 - 修复点击两次主题切换按钮会导致当前 Webview 被错误关闭的问题 - 修复当 Webview 处于打开状态,点击侧边栏按钮无法立即跳转到对应界面的问题 - 修复打开帮助文档,其按钮没有显示为被选中的问题 - 修复在设置界面时打开帮助文档,设置按钮继续显示为被选中的问题 --- src/renderer/src/components/app/Sidebar.tsx | 33 ++++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/renderer/src/components/app/Sidebar.tsx b/src/renderer/src/components/app/Sidebar.tsx index 355a30a5..94cd5610 100644 --- a/src/renderer/src/components/app/Sidebar.tsx +++ b/src/renderer/src/components/app/Sidebar.tsx @@ -77,9 +77,11 @@ const Sidebar: FC = () => { )} - + - + @@ -93,8 +95,14 @@ const Sidebar: FC = () => { - to(isLocalAi ? '/settings/assistant' : '/settings/provider')}> - + { + if (minappShow) { + await MinApp.close() + } + await to(isLocalAi ? '/settings/assistant' : '/settings/provider') + }}> + @@ -108,10 +116,11 @@ const MainMenus: FC = () => { const { t } = useTranslation() const { pathname } = useLocation() const { sidebarIcons } = useSettings() + const { minappShow } = useRuntime() const navigate = useNavigate() - const isRoute = (path: string): string => (pathname === path ? 'active' : '') - const isRoutes = (path: string): string => (pathname.startsWith(path) ? 'active' : '') + const isRoute = (path: string): string => (pathname === path && !minappShow ? 'active' : '') + const isRoutes = (path: string): string => (pathname.startsWith(path) && !minappShow ? 'active' : '') const iconMap = { assistants: , @@ -139,7 +148,13 @@ const MainMenus: FC = () => { return ( - navigate(path)}> + { + if (minappShow) { + await MinApp.close() + } + navigate(path) + }}> {iconMap[icon]} @@ -150,6 +165,7 @@ const MainMenus: FC = () => { const PinnedApps: FC = () => { const { pinned, updatePinnedMinapps } = useMinapps() const { t } = useTranslation() + const { minappShow } = useRuntime() return ( @@ -164,11 +180,12 @@ const PinnedApps: FC = () => { } } ] + const isActive = minappShow && MinApp.app?.id === app.id return ( - MinApp.start(app)}> + MinApp.start(app)} className={isActive ? 'active' : ''}>