diff --git a/sample-electron/README.md b/sample-electron/README.md new file mode 100644 index 00000000..04a76490 --- /dev/null +++ b/sample-electron/README.md @@ -0,0 +1,5 @@ +To run this sample, you need to [download Electron](https://github.com/electron/electron/releases) + +``` +$/sample-electron> electron main.js +``` \ No newline at end of file diff --git a/sample-electron/index.html b/sample-electron/index.html new file mode 100644 index 00000000..902ccdf1 --- /dev/null +++ b/sample-electron/index.html @@ -0,0 +1,48 @@ + + + + + Hello World! + + +

Hello World!

+
+ + + + + + + \ No newline at end of file diff --git a/sample-electron/main.js b/sample-electron/main.js new file mode 100644 index 00000000..8b836884 --- /dev/null +++ b/sample-electron/main.js @@ -0,0 +1,28 @@ +const electron = require('electron') +const app = electron.app +const BrowserWindow = electron.BrowserWindow + +let mainWindow; + +function createWindow () { + mainWindow = new BrowserWindow({width: 800, height: 600}) + mainWindow.loadURL(`file://${__dirname}/index.html`) + mainWindow.webContents.openDevTools() + mainWindow.on('closed', function () { + mainWindow = null + }) +} + +app.on('ready', createWindow) + +app.on('window-all-closed', function () { + if (process.platform !== 'darwin') { + app.quit() + } +}) + +app.on('activate', function () { + if (mainWindow === null) { + createWindow() + } +})