-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
107 lines (100 loc) · 3.14 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/naming-convention */
const electron = require('electron');
const url = require('url');
const path = require('path');
const devMode = process.argv.includes('--dev');
require('@electron/remote/main').initialize();
const { app, BrowserWindow, Menu, ipcMain } = electron;
app.on('ready', () => {
const mainWindow = new BrowserWindow({
width: 1300,
height: 900,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true
}
});
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'app/index.html'),
protocol: 'file:',
slashes: true
}));
const menu = Menu.buildFromTemplate([
{
label: 'Datei',
submenu: [
{
label: 'Neues Projekt',
accelerator: 'CmdOrCtrl+N',
click() {
mainWindow.webContents.send('open:new-project-dialog');
}
},
{
label: 'Projekt öffnen',
accelerator: 'CmdOrCtrl+O',
click() {
mainWindow.webContents.send('open:open-project-dialog');
}
},
{
type: 'separator'
},
{
label: 'Exit',
accelerator: 'CmdOrCtrl+Q',
click() {
app.quit();
}
}
]
},
{
label: 'Ansicht',
submenu: [
{
label: 'Neu laden',
accelerator: 'CmdOrCtrl+R',
click(_item, win) {
win.reload();
}
},
{
label: 'Vollbild',
accelerator: 'F11',
click(_item, win) {
if (win.maximizable) win.maximize();
}
}
]
},
{
label: 'Hilfe',
submenu: [
{
label: 'Docs',
click() {
electron.shell.openExternal('https://github.com/KonstantinEger/Bau-Abrechnungsprogramm/wiki');
}
},
{
label: 'Projekt auf GitHub öffnen',
click() {
electron.shell.openExternal('https://github.com/KonstantinEger/Bau-Abrechnungsprogramm');
}
},
{
label: 'DevTools',
click() {
mainWindow.webContents.openDevTools();
},
accelerator: devMode ? 'CmdOrCtrl+Shift+I' : undefined,
visible: devMode
}
]
}
]);
Menu.setApplicationMenu(menu);
});
ipcMain.once('quit-app', () => app.quit());