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

@ -6,10 +6,12 @@
import path from "path";
import url from "url";
import { app, Menu, ipcMain, Tray } from "electron";
import createWindow from "./helpers/window";
import { devMenuTemplate } from "./menu/dev_menu_template";
import { editMenuTemplate } from "./menu/edit_menu_template";
import { settingsMenuTemplate } from "./menu/config_menu_template";
import createWindow from "./helpers/window";
import { aboutMenuTemplate } from "./menu/about_menu_template";
// Special module holding environment variables which you declared
// in config/env_xxx.json file.
@ -19,7 +21,7 @@ const { spawn, exec } = require('child_process')
const fs = require('fs')
const setApplicationMenu = () => {
const menus = [editMenuTemplate, settingsMenuTemplate];
const menus = [editMenuTemplate, settingsMenuTemplate, aboutMenuTemplate];
if (env.name !== "production") {
menus.push(devMenuTemplate);
}

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)
}
}
]
};