feat(changelog): changelog inside application

This commit is contained in:
Alexey Kasyanchuk
2018-02-06 00:41:23 +03:00
parent 74def9f763
commit 9bac53f559
6 changed files with 324 additions and 12 deletions

View File

@ -0,0 +1,38 @@
import { app, BrowserWindow, shell } from "electron";
import path from "path";
import url from "url";
export const aboutMenuTemplate = {
label: "About",
submenu: [
{
label: "Changelog",
accelerator: "CmdOrCtrl+]",
click: () => {
const win = new BrowserWindow({
parent: BrowserWindow.getFocusedWindow(),
modal: true
})
win.setMenu(null)
win.loadURL(url.format({
pathname: path.join(__dirname, "app.html"),
protocol: "file:",
slashes: true
}))
win.webContents.on('did-finish-load', () => {
win.send('url', '/changelog')
});
const handleRedirect = (e, url) => {
if(url != win.webContents.getURL()) {
e.preventDefault()
shell.openExternal(url)
}
}
win.webContents.on('will-navigate', handleRedirect)
win.webContents.on('new-window', handleRedirect)
}
}
]
};