show app version on electron loading screen

This commit is contained in:
liamcottle
2024-05-28 22:19:18 +12:00
parent 8cf55933d3
commit bb86ab31aa
3 changed files with 20 additions and 2 deletions

View File

@@ -18,7 +18,7 @@
<!-- about -->
<div class="mx-auto text-center mb-2">
<div class="font-bold">Reticulum WebChat</div>
<div class="text-sm">Developed by Liam Cottle</div>
<div class="text-sm"><span id="app-version"></span> Developed by Liam Cottle</div>
</div>
<!-- loading spinner -->
@@ -33,8 +33,14 @@
<script>
showAppVersion();
check();
async function showAppVersion() {
const appVersion = await window.electron.appVersion();
document.getElementById("app-version").innerText = "v" + appVersion;
}
async function check() {
try {

View File

@@ -10,6 +10,11 @@ var mainWindow = null;
// remember child process for exe so we can kill it when app exits
var exeChildProcess = null;
// allow fetching app version via ipc
ipcMain.handle('app-version', async() => {
return app.getVersion();
});
// add support for showing a prompt window via ipc
ipcMain.handle('prompt', async(event, message) => {
return await electronPrompt({

View File

@@ -3,9 +3,16 @@ const { ipcRenderer, contextBridge } = require('electron');
// forward logs received from exe to web console
ipcRenderer.on('log', (event, message) => console.log(message));
// add support for using "prompt" in electron browser window
contextBridge.exposeInMainWorld('electron', {
// allow fetching app version in electron browser window
appVersion: async function() {
return await ipcRenderer.invoke('app-version');
},
// add support for using "prompt" in electron browser window
prompt: async function(message) {
return await ipcRenderer.invoke('prompt', message);
},
});