-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindowManager.js
71 lines (55 loc) · 1.47 KB
/
windowManager.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
const DEFAULT_WIDTH = 1366;
const DEFAULT_HEIGHT = 768;
import path from 'path';
global.window = {
Music: false,
Pictures: false,
};
global.createWindow = function(title, documentURL, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT, options={}) {
if(window[title] === true) { return {}; }
if(window[title] === false) {
window[title] = true;
}
const externalURL = (documentURL.substr(0, 4) === 'http');
const windowData = {
width,
height,
frame: externalURL,
autoHideMenuBar: externalURL,
icon: path.resolve('./img/icon.png'),
webPreferences: {
backgroundThrottling: false,
contextIsolation: false,
nodeIntegration: true
},
title,
};
if(options !== undefined) {
for(const i in options) {
windowData[i] = options[i];
}
}
const win = new BrowserWindow(windowData);
// et charge le index.html de l'application.
if(externalURL) {
win.loadURL(documentURL);
} else {
win.loadFile(documentURL);
}
return win;
};
global.createWindowFromModule = function(title, moduleName, documentURL, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT, options={}) {
const tmpURL = documentURL.replaceAll('views/', 'tmp/' + moduleName + '_');
return createWindow(title, tmpURL, width, height, options);
};
global.closeWindow = function(title) {
window[title] = false;
};
global.exitPopup = function() {
const options = {
parent: mainWindow,
modal: true,
resizable: false,
};
createWindow('Confirmation de fermeture', 'views/exitPopup.html', 300, 150, options);
};