-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmain.js
89 lines (71 loc) · 1.79 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
/*'use strict';
const { app, BrowserWindow } = require('electron');
console.log('in main.js');
var mainWindow = null;
let serve;
const args = process.argv.slice(1);
serve = args.some(val => val === '--serve');
console.log(`args = ${args}`);
if (serve) {
require('electron-reload')(__dirname, {});
console.log('init electron-reload');
}
var ipcMain = require('electron').ipcMain
ipcMain.on('close-main-window', function () {
app.quit();
});
ipcMain.on('image-changed', function(sender, fileName) {
//console.log('on image-changed with ' + JSON.stringify(arguments));
mainWindow.setTitle(fileName);
});
ipcMain.on('exit-full-screen', function() {
if (mainWindow.isFullScreen()) {
mainWindow.setFullScreen(false);
}
});
ipcMain.on('enter-full-screen', function() {
if (!mainWindow.isFullScreen()) {
mainWindow.setFullScreen(true);
}
});
ipcMain.on('log', (sender, msg) => {
console.log(msg);
});
ipcMain.on('toggle-full-screen', function() {
if (mainWindow.isFullScreen()) {
mainWindow.setFullScreen(false);
} else {
mainWindow.setFullScreen(true);
}
});
function createWindow() {
mainWindow = new BrowserWindow({
//frame: false,
resizable: true,
height: 600,
width: 800,
webPreferences: {
webSecurity: false
}
});
mainWindow.loadURL('file://' + __dirname + '/app/index.html');
// cleanup
mainWindow.on('closed', function () {
mainWindow = null;
});
}
app.on('ready', function() {
createWindow();
});
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit()
}
});
app.on('activate', function () {
// macOS specific close process
if (mainWindow === null) {
createWindow();
}
});
*/