mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-08-13 19:49:36 +00:00
implement first Electron-API Bridge functions - Add little sample in WebApp
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user