Started working on the app menu
This commit is contained in:
parent
e8bf1e0d81
commit
e758078a8d
12
assets/twig/about.twig
Normal file
12
assets/twig/about.twig
Normal file
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>About Sentry</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>This is a test.</p>
|
||||
</body>
|
||||
</html>
|
8
main.js
8
main.js
@ -1,5 +1,5 @@
|
||||
// Modules to control application life and create native browser window
|
||||
const {app, BrowserWindow} = require('electron');
|
||||
const { app, BrowserWindow, Menu } = require('electron');
|
||||
const path = require('path');
|
||||
|
||||
function createWindow () {
|
||||
@ -7,7 +7,7 @@ function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 700,
|
||||
minWidth: 725,
|
||||
minWidth: 735,
|
||||
minHeight: 600,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
@ -23,6 +23,10 @@ function createWindow () {
|
||||
// mainWindow.webContents.openDevTools()
|
||||
}
|
||||
|
||||
// Set the application menu
|
||||
const menu = require('./src/menu').createMenu(app);
|
||||
Menu.setApplicationMenu(menu);
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
|
15
src/menu/help.js
Normal file
15
src/menu/help.js
Normal file
@ -0,0 +1,15 @@
|
||||
const { BrowserWindow } = require('electron');
|
||||
|
||||
exports.about = function() {
|
||||
const aboutWindow = new BrowserWindow({
|
||||
width: 600,
|
||||
height: 400,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false
|
||||
}
|
||||
});
|
||||
|
||||
// and load the about.html of the app.
|
||||
aboutWindow.loadFile('public/about.html');
|
||||
};
|
30
src/menu/index.js
Normal file
30
src/menu/index.js
Normal file
@ -0,0 +1,30 @@
|
||||
const electron = require('electron');
|
||||
|
||||
// load event handlers
|
||||
const helpHandlers = require('./help');
|
||||
|
||||
exports.createMenu = function(app) {
|
||||
return electron.Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'File',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Close',
|
||||
click: function() {
|
||||
app.quit();
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
label: 'Help',
|
||||
submenu: [
|
||||
{
|
||||
label: 'About',
|
||||
click: helpHandlers.about
|
||||
}
|
||||
]
|
||||
}
|
||||
]);
|
||||
};
|
Loading…
Reference in New Issue
Block a user