-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
94 lines (80 loc) · 2.3 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
const { app, BrowserWindow, ipcMain } = require('electron')
var path = require('path')
let modalTitle;
let mainWindow;
function createWindow () {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 750,
height: 650,
backgroundColor: '#ffffff',
icon: 'knife.png'
})
// turn off dev menu
mainWindow.setMenu(null);
// load index.html as main window
mainWindow.loadURL(`file://${__dirname}/dist/index.html`);
// test modal window
modalWindow = new BrowserWindow({
width: 400,
height: 475,
maxWidth: 400,
maxHeight: 475,
backgroundColor: '#ffffff',
show: false,
icon: 'Mahm0udwally-All-Flat-Music.ico',
parent: mainWindow,
title: modalTitle
})
modalWindow.setMenu(null);
modalWindow.loadURL(`file://${__dirname}/src/app/primarySectors/shared/templates/generic-modal.tmp.html`)
//// uncomment below to open the DevTools.
// mainWindow.webContents.openDevTools()
// Event when the window is closed.
mainWindow.on('closed', function (event) {
mainWindow = null;
})
}
// icon: `file://${__dirname}/src/assets/newItem.PNG`
// icon: path.join(__dirname+'assets/sample-1.jpg')
// doesn't find icon file
ipcMain.on('open-modal', (event, arg) => {
modalTitle = arg;
modalWindow.show();
});
// replace electron modal with pure HTML/CSS/JS modal
// cannot 'close' modal window after first usage, because
// framework destroys the only instance of the popup
ipcMain.on('closed', (event) => {
// console.log(event);
// event.preventDefault();
// event.returnValue = false;
// modalWindow.hide();
modalWindow = null;
});
// open development/debug window
ipcMain.on('open-dev-menu', (event, arg)=>{
mainWindow.webContents.openDevTools();
});
// TODO:
// when development window is closed, change
// checked input back to false in app settings
ipcMain.on('close-dev-menu', (event, arg) => {
mainWindow.setMenu(null);
});
// Create window on electron intialization
app.on('ready', createWindow)
// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On macOS specific close process
if (process.platform !== 'darwin') {
app.quit()
}
});
app.on('activate', function () {
// macOS specific close process
if (mainWindow === null) {
createWindow()
}
});
ELECTRON_ENABLE_LOGGING=1