implement first Electron-API Bridge functions - Add little sample in WebApp

This commit is contained in:
Gregor Biswanger
2017-10-12 02:24:27 +02:00
parent 6020369892
commit 5f0be6543b
13 changed files with 206 additions and 9 deletions

View File

@@ -18,6 +18,12 @@ namespace ElectronNET.WebApp.Controllers
App.IpcMain.Send("Goodbye", "Elephant!");
});
App.IpcMain.On("GetPath", async (args) =>
{
string pathName = await App.GetPathAsync(PathName.pictures);
App.IpcMain.Send("GetPathComplete", pathName);
});
return View();
}
}

View File

@@ -17,6 +17,11 @@
<br /><br />
<input id="callButton" type="button" value="Call Notification" />
<div>
<p id="picturesPathLabel"></p>
<input id="picturesButton" type="button" value="Get Pictures-Path" />
</div>
<script>
const { ipcRenderer } = require("electron");
@@ -27,6 +32,15 @@
ipcRenderer.on("Goodbye", (sender, data) => {
alert('Goodbye ' + data);
});
document.getElementById("picturesButton").addEventListener("click", () => {
ipcRenderer.send("GetPath");
});
ipcRenderer.on("GetPathComplete", (sender, data) => {
document.getElementById("picturesPathLabel").innerText = data;
});
</script>
</body>
</html>