Links in electron menu


#1

How would one go about including links to specific pages within an electron application in the electron menu. For example, I’d like to have a submenu item ‘About Application’ which would take a user to the about page of the application.


#2

@junkerGeorge I’m guessing you know how to create a menu, if not read menu.md. To open a page when the user clicks the menu item add this code

click: () => {
  shell.openExternal('https://example.com/')
}

#3

Thanks for your response. I similar example and I am able to make that work. However, I’m not trying to open an external page but rather a page within the application.


#4

You can use the BrowserWindow’s loadURL function to load a page on the same BrowserWindow :
BrowserWindow.loadURL('https://example.com/')

Or create another BrowserWindow and “show” it when the user clicks the menu item.
and I suggest you read the API docs here


#5

Thanks, I’ve combed through the docs. In my experience since I’m using angular and the application works as a SPA the loadUrl method reinitialized the index.html file. This is will not work for multiple reason.

I’ve found a solution to simply communicate between ipc events from the main process to a service in my renderer process. I was just hoping for a cleaner method.