diff --git a/main.js b/main.js index ad8d13e..de3936d 100644 --- a/main.js +++ b/main.js @@ -1,4 +1,5 @@ -const { BrowserWindow, app, net, dialog } = require("electron") +const { BrowserWindow, app, net, dialog, ipcMain } = require("electron") +const os = require("os") const hwid = require("./modules/hwid") const path = require("node:path") const config = require("./config.json") @@ -67,4 +68,15 @@ app.whenReady().then(() => { app.on("window-all-closed", () => { app.quit() +}) + +ipcMain.on("call", (event, data) => { + switch (data.method) { + case "hardware::ramInformation": + launcherWindow.webContents.send("hardware::ramInformation", { + totalRam: Math.round(os.totalmem() / 1024 / 1024 * 100) / 100, + avaibleRam: Math.round(os.freemem() / 1024 / 1024 * 100) / 100, + }) + break + } }) \ No newline at end of file diff --git a/modules/preload.js b/modules/preload.js index 505462c..9fad43d 100644 --- a/modules/preload.js +++ b/modules/preload.js @@ -1,5 +1,6 @@ -const { shell, contextBridge } = require("electron") +const { shell, contextBridge, ipcRenderer } = require("electron") contextBridge.executeInMainWorld("system", { - openInBrowser: (url) => shell.openExternal(url) + openInBrowser: (url) => shell.openExternal(url), + call: (method, args) => ipcRenderer.send("call", { method, args }) }) \ No newline at end of file