-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
41 lines (37 loc) · 1.13 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const { app, BrowserWindow, screen, ipcMain } = require("electron");
const path = require("path");
const fs = require("fs");
const { shell } = require("electron");
ipcMain.handle("open-external-link", async (event, url) => {
try {
await shell.openExternal(url);
} catch (error) {
console.error("Failed to open URL:", error);
}
});
app.whenReady().then(() => {
const display = screen.getPrimaryDisplay();
const { width, height } = display.workAreaSize;
const mainWindow = new BrowserWindow({
width: width,
height: height,
webPreferences: {
preload: path.join(__dirname, "renderer.js"),
contextIsolation: true,
enableRemoteModule: false,
},
});
mainWindow.maximize();
mainWindow.loadFile("index.html");
});
ipcMain.handle("fetch-companies", async (event) => {
const filePath = path.join(__dirname, "./Companies.json");
try {
const data = fs.readFileSync(filePath, "utf-8");
const companies = JSON.parse(data);
return { companies };
} catch (err) {
console.error("Error reading JSON file:", err);
return { companies: [] };
}
});