feat(electron): app menu item and hotkey for creating new page (#2267)

Co-authored-by: Peng Xiao <pengxiao@outlook.com>
This commit is contained in:
Doma
2023-05-13 23:45:12 +08:00
committed by GitHub
parent b240a70e51
commit 05d88215d1
6 changed files with 164 additions and 0 deletions

View File

@@ -89,6 +89,14 @@ export const RootAppSidebar = ({
const page = await createPage();
openPage(page.id);
}, [createPage, openPage]);
// Listen to the "New Page" action from the menu
useEffect(() => {
if (environment.isDesktop) {
return window.events?.applicationMenu.onNewPageAction(onClickNewPage);
}
}, [onClickNewPage]);
const sidebarOpen = useAtomValue(appSidebarOpenAtom);
useEffect(() => {
if (environment.isDesktop && typeof sidebarOpen === 'boolean') {