feat(changelog): changelog inside application
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
38
src/background/menu/about_menu_template.js
Normal file
38
src/background/menu/about_menu_template.js
Normal 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)
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
Reference in New Issue
Block a user