forked from Deviouslrd/json-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
121 lines (106 loc) · 3.1 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
const { app, BrowserWindow, Menu, MenuItem } = require("electron");
require('update-electron-app')({
updateInterval: '1 hour'
});
autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
const dialogOpts = {
type: 'info',
buttons: ['Restart', 'Later'],
title: 'Application Update',
message: process.platform === 'win32' ? releaseNotes : releaseName,
detail: 'A new version has been downloaded. Restart the application to apply the updates.'
};
dialog.showMessageBox(dialogOpts).then((returnValue) => {
if (returnValue.response === 0) autoUpdater.quitAndInstall();
});
});
autoUpdater.on('error', message => {
console.error('There was a problem updating the application');
console.error(message);
});
function createWindow () {
const win = new BrowserWindow({
show: false,
width: 850,
height: 600,
title: "Mod JSON Generator vA1.9",
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true
}
});
win.loadFile('pages/main.html');
win.once('ready-to-show', () => {
win.show();
});
}
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
const menu = new Menu();
menu.append(new MenuItem({
label: 'File',
submenu: [
{
label: 'Exit',
accelerator: process.platform === 'darwin' ? 'esc' : 'esc',
click: () => { app.quit(); }
},
/*{
label: 'Save Dialog',
accelerator: process.platform === 'darwin' ? 'cmd+s' : 'ctrl+s',
click: () => {
dialog.showOpenDialog( { properties: ['openDirectory'] } ).then(data => {
console.log(data.filePaths);
module.exports.filePath = data.filePaths;
});
}
}*/
]
}));
menu.append(new MenuItem({
label: 'Dev Tools',
submenu: [
{
role: 'toggleDevTools',
accelerator: process.platform === 'darwin' ? 'cmd+shift+i' : 'ctrl+shift+i',
click: () => {
openDevTools();
}
},
{
role: 'reload',
accelerator: process.platform === 'darwin' ? 'cmd+r' : 'ctrl+r',
click: () => { app.relaunch(); }
}
]
}));
menu.append(new MenuItem({
label: 'Help',
submenu: [
{
role: 'help',
accelerator: process.platform === 'darwin' ? 'cmd+h' : 'ctrl+h',
click: () => {
const win = new BrowserWindow({
width: 850,
height: 600,
title: "Generator Help",
webPreferences: {
nodeIntegration: true
}
});
win.loadFile('./pages/help.html');
}
}
]
}));
Menu.setApplicationMenu(menu);