Created
March 27, 2017 00:31
-
-
Save guzmonne/2e3360763b8ddd342408e1cef7d81d57 to your computer and use it in GitHub Desktop.
Opens the server window
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {BrowserWindow} = require('electron') | |
const url = require('url') | |
const path = require('path') | |
/** | |
* @function serverWindow | |
* @description Opens the server window. | |
* @param {Function} onClose Function to call after a 'closed' event. | |
*/ | |
function serverWindow(onClose=function(){}) { | |
// Create the server window | |
const win = new BrowserWindow({ | |
show: true, | |
width: 480, | |
height: 72, | |
x: 0, | |
y: 0, | |
show: process.env.NODE_ENV !== 'development', | |
frame: false, | |
movable: false, | |
minimizable: false, | |
maximaizable: false, | |
resizable: false, | |
closable: false, | |
alwaysOnTop: true, | |
skipTaskbar: true, | |
transparent: true, | |
}) | |
// Define the location of the server renderer file. | |
const startUrl = url.format({ | |
pathname: path.join(__dirname, '../renderer/server.html'), | |
protocol: 'file', | |
slashes: true, | |
}) | |
// Load the page | |
win.loadURL(startUrl) | |
// Run the onClose callback on 'closed' event. | |
win.on('closed', onClose) | |
// Return the modified window | |
return win | |
} | |
exports = module.exports = serverWindow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment