mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-14 05:34:48 +00:00
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
"use strict";
|
|
exports.__esModule = true;
|
|
var electron_1 = require("electron");
|
|
var windows = [];
|
|
var ipc;
|
|
module.exports = function (socket) {
|
|
socket.on('createBrowserWindow', function (options, loadUrl) {
|
|
var window = new electron_1.BrowserWindow(options);
|
|
window.on('closed', function (sender) {
|
|
for (var index = 0; index < windows.length; index++) {
|
|
var windowItem = windows[index];
|
|
try {
|
|
windowItem.id;
|
|
}
|
|
catch (error) {
|
|
if (error.message === 'Object has been destroyed') {
|
|
windows.splice(index, 1);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
if (ipc == undefined) {
|
|
ipc = require('./ipc')(socket, window);
|
|
}
|
|
if (loadUrl) {
|
|
window.loadURL(loadUrl);
|
|
}
|
|
windows.push(window);
|
|
socket.emit('BrowserWindowCreated', window.id);
|
|
});
|
|
socket.on('browserWindow-minimize', function (id) {
|
|
getWindowById(id).minimize();
|
|
});
|
|
function getWindowById(id) {
|
|
for (var index = 0; index < windows.length; index++) {
|
|
var element = windows[index];
|
|
if (element.id == id) {
|
|
return element;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
//# sourceMappingURL=browserWindows.js.map
|