Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Desenvolvendo Aplicações Desktop com Electron

Desenvolvendo Aplicações Desktop com Electron

Conheça o Electron e aprenda como é simples desenvolver aplicações desktop apenas com HTML, CSS e Javascript.

Sérgio Vilar

October 01, 2015
Tweet

More Decks by Sérgio Vilar

Other Decks in Programming

Transcript

  1. index.html 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta

    charset="UTF-8"> 5 <title>Hello World!</title> 6 </head> 7 <body> 8 <h1>Hello World!</h1> 9 </body> 10 </html>
  2. index.js 1 var app = require('app'); 2 var BrowserWindow =

    require('browser-window'); // Window API 3 4 app.on('window-all-closed', function() { 5 app.quit(); 6 }); 7 8 app.on('ready', function() { 9 // Cria uma nova janela 10 var mainWindow = new BrowserWindow({width: 800, height: 600}); 11 12 // Carrega o arquivo index.html 13 mainWindow.loadUrl('file://' + __dirname + '/index.html'); 14 15 });
  3. ipc-browser.js 1 var ipc = require('ipc'); 2 ipc.on('do-async', function(event, arg)

    { 3 event.sender.send('async', arg); 4 }); 5 6 ipc.on('sync', function(event, arg) { 7 event.returnValue = 'bar'; 8 });
  4. ipc-renderer.html 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta

    charset="UTF-8"> 5 <title>IPC</title> 6 </head> 7 <body></body> 8 <script type="text/javascript"> 9 var ipc = require('ipc'); 10 var foo = ipc.sendSync('sync', 'foo'); // Síncrono 11 12 ipc.on('async', function(arg) { 13 console.log(arg); // imprime "baz" 14 }); 15 ipc.send('do-async', 'baz'); 16 </script> 17 </html>
  5. remote.html 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta

    charset="UTF-8"> 5 <title>IPC</title> 6 </head> 7 <body></body> 8 <script type="text/javascript"> 9 var remote = require('remote'); 10 var BrowserWindow = remote.require('browser-window'); 11 12 var win = new BrowserWindow({ width: 800, height: 600 }); 13 win.loadUrl('http://vilar.cc'); 14 </script> 15 </html>
  6. • MyApp.app • MyApp.exe • MyApp_linux_trusty_amd64.deb • MyApp_linux_trusty_i386.deb • MyApp_linux_utopic_amd64.deb

    • MyApp_linux_utopic_i386.deb • MyApp_linux_vivid_amd64.deb • MyApp_linux_vivid_i386.deb • MyApp_linux_amd64.rpm • MyApp_linux_i386.rpm Linux
  7. • MyApp.app • MyApp.exe • MyApp_linux_trusty_amd64.deb • MyApp_linux_trusty_i386.deb • MyApp_linux_utopic_amd64.deb

    • MyApp_linux_utopic_i386.deb • MyApp_linux_vivid_amd64.deb • MyApp_linux_vivid_i386.deb • MyApp_linux_amd64.rpm • MyApp_linux_i386.rpm Linux
  8. • MyApp.app • MyApp.exe • MyApp_linux_trusty_amd64.deb • MyApp_linux_trusty_i386.deb • MyApp_linux_utopic_amd64.deb

    • MyApp_linux_utopic_i386.deb • MyApp_linux_vivid_amd64.deb • MyApp_linux_vivid_i386.deb • MyApp_linux_amd64.rpm • MyApp_linux_i386.rpm Linux