Created
March 26, 2016 16:20
-
-
Save KimuraTakaumi/dc10ac423ad23f865f0c to your computer and use it in GitHub Desktop.
Electronでプロセス間通信(remote) 引数あり
This file contains 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> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Hello World!</title> | |
<script type="text/javascript"> | |
var main = require("remote").require("./main"); | |
// 引数を設定し、MainProcess側に値を渡す | |
function exampleRemoteArgsText() { | |
console.log("exampleRemoteArgsText"); | |
main.exampleRemoteArgsText('Render Process Message'); | |
} | |
</script> | |
</head> | |
<body> | |
<h1>Hello World!</h1> | |
<button onclick="exampleRemoteArgsText()">exampleRemoteArgsText</button> | |
</body> | |
</html> |
This file contains 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
'use strict'; | |
const electron = require('electron'); | |
const app = electron.app; | |
const BrowserWindow = electron.BrowserWindow; | |
var mainWindow; | |
function createWindow() { | |
mainWindow = new BrowserWindow({width: 800, height: 600}); | |
mainWindow.loadURL('file://' + __dirname + '/index.html'); | |
// Open the DevTools. | |
mainWindow.webContents.openDevTools(); | |
mainWindow.on('closed', function () { | |
mainWindow = null; | |
}); | |
} | |
app.on('ready', function () { | |
createWindow(); | |
}); | |
app.on('window-all-closed', function () { | |
if (process.platform !== 'darwin') { | |
app.quit(); | |
} | |
}); | |
exports.exampleRemoteArgsText = function (text) { | |
console.log('main process example remote method : ' + text); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment