add ping function

This commit is contained in:
Mylloon 2023-07-29 16:23:38 +02:00
parent 6946a7821b
commit 0255515f77
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 12 additions and 2 deletions

View file

@ -1,4 +1,4 @@
import { app, BrowserWindow } from "electron"; import { BrowserWindow, app, ipcMain } from "electron";
import path = require("path"); import path = require("path");
/* import ffmpegPath = require("ffmpeg-static"); */ /* import ffmpegPath = require("ffmpeg-static"); */
@ -15,6 +15,8 @@ const createWindow = () => {
}; };
app.whenReady().then(() => { app.whenReady().then(() => {
ipcMain.handle("ping", () => "pong");
createWindow(); createWindow();
app.on("activate", () => { app.on("activate", () => {

View file

@ -1,7 +1,8 @@
import { contextBridge } from "electron"; import { contextBridge, ipcRenderer } from "electron";
contextBridge.exposeInMainWorld("versions", { contextBridge.exposeInMainWorld("versions", {
node: () => process.versions.node, node: () => process.versions.node,
chrome: () => process.versions.chrome, chrome: () => process.versions.chrome,
electron: () => process.versions.electron, electron: () => process.versions.electron,
ping: () => ipcRenderer.invoke("ping"),
}); });

View file

@ -4,3 +4,10 @@ var versions: any;
const information = document.getElementById("info"); const information = document.getElementById("info");
information.innerText = `Cette application utilise Chrome (v${versions.chrome()}), Node.js (v${versions.node()}), et Electron (v${versions.electron()})`; information.innerText = `Cette application utilise Chrome (v${versions.chrome()}), Node.js (v${versions.node()}), et Electron (v${versions.electron()})`;
const func = async () => {
const response = await versions.ping();
console.log(response);
};
func();