From 372224469d247e7a626c32349690e14129f73255 Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Thu, 19 Sep 2024 23:27:50 +0800 Subject: [PATCH] feat: added minapp event handling and sidebar menu interactions #50 - Added functionality for handling MinApp window closure and provided a default close event handler. - Added event listeners to Sidebar menus to interact with MinApp. --- src/renderer/src/components/MinApp/index.tsx | 3 +++ src/renderer/src/components/app/Sidebar.tsx | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/components/MinApp/index.tsx b/src/renderer/src/components/MinApp/index.tsx index 0564d62c..75354701 100644 --- a/src/renderer/src/components/MinApp/index.tsx +++ b/src/renderer/src/components/MinApp/index.tsx @@ -30,6 +30,8 @@ const PopupContainer: React.FC = ({ app, resolve }) => { setTimeout(() => resolve({}), 300) } + MinApp.onClose = onClose + const onReload = () => { if (webviewRef.current) { webviewRef.current.src = app.url @@ -163,6 +165,7 @@ const Button = styled.div` export default class MinApp { static topviewId = 0 + static onClose = () => {} static close() { TopView.hide('MinApp') store.dispatch(setMinappShow(false)) diff --git a/src/renderer/src/components/app/Sidebar.tsx b/src/renderer/src/components/app/Sidebar.tsx index 37d95bac..8da91222 100644 --- a/src/renderer/src/components/app/Sidebar.tsx +++ b/src/renderer/src/components/app/Sidebar.tsx @@ -10,6 +10,7 @@ import { useTranslation } from 'react-i18next' import { useLocation, useNavigate } from 'react-router-dom' import styled from 'styled-components' +import MinApp from '../MinApp' import UserPopup from '../Popups/UserPopup' const Sidebar: FC = () => { @@ -45,7 +46,7 @@ const Sidebar: FC = () => { - + @@ -73,7 +74,7 @@ const Sidebar: FC = () => { - + to(isLocalAi ? '/settings/assistant' : '/settings/provider')}> @@ -96,6 +97,7 @@ const Container = styled.div` border-right: 0.5px solid var(--color-border); margin-top: ${isMac ? 'var(--navbar-height)' : 0}; transition: background-color 0.3s ease; + z-index: 10000; ` const AvatarImg = styled(Avatar)`