Last active
February 5, 2017 19:19
-
-
Save mmfilesi/f82bb0ca97345482d7fc91b088082a49 to your computer and use it in GitHub Desktop.
electron
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
<!doctype html> | |
<html lang=""> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="x-ua-compatible" content="ie=edge"> | |
<title></title> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body> | |
<h1>Hola mundo</h1> | |
</body> | |
</html> |
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
/* Nos traemos el objeto app, con el que controlaremos el ciclo de vida de la aplicación, | |
y BrowserWindow, que permite definir la ventana */ | |
const { app, BrowserWindow } = require('electron'); | |
/* Declaramos de forma global win, que luego setearemos con la aplicación. */ | |
let win; | |
/* Con esta función auxiliar definimos los parámetros generales de la aplicación. | |
Se podría hacer más adelante en el ready, pero así queda más limpio. */ | |
function createWindow() { | |
/* instanciamos BrowserWindow. */ | |
win = new BrowserWindow({ | |
height: 768, | |
width: 1024, | |
}); | |
/* Ruta del archivo principal, el que se carga por defecto */ | |
win.loadURL(`file://${__dirname}/app/index.html`); | |
/* Para disponer de la consola */ | |
win.webContents.openDevTools(); | |
win.on('closed', () => { | |
/* Nulificamos esta ventana, y solo esta, cuando se cierre */ | |
win = null | |
}); | |
} | |
/* Cuando app esté listo, iniciamos la ventana de la aplicación */ | |
app.on('ready', createWindow); | |
/* Si no estamos en mack, cerramos la aplicación si todos los procesos, las ventanas, han sido cerradas */ | |
app.on('window-all-closed', () => { | |
if (process.platform !== 'darwin') { | |
app.quit(); | |
} | |
}); |
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
{ | |
"name": "electron", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"start": "electron index.js", | |
"build": "electron-packager . windows" | |
}, | |
"author": "mmfilesi", | |
"license": "ISC", | |
"devDependencies": { | |
"electron-packager": "^8.5.1", | |
"electron-prebuilt": "^1.4.13" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment