-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
110 lines (91 loc) · 3.12 KB
/
main.js
File metadata and controls
110 lines (91 loc) · 3.12 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
const { app, BrowserWindow, ipcMain } = require("electron");
const path = require("path");
// Disable GPU acceleration on Linux to avoid sandbox issues
if (process.platform === "linux") {
app.disableHardwareAcceleration();
}
// Keep a global reference to prevent garbage collection
let mainWindow;
function createWindow() {
// Create the browser window
mainWindow = new BrowserWindow({
width: 1200,
height: 800,
minWidth: 1000,
minHeight: 700,
backgroundColor: "#ECE9D8",
icon: path.join(__dirname, "assets/icon.png"),
webPreferences: {
preload: path.join(__dirname, "preload.js"),
contextIsolation: true,
nodeIntegration: false,
},
show: false,
});
// Load the index.html
mainWindow.loadFile(path.join(__dirname, "src/renderer/index.html"));
// Show window when ready
mainWindow.once("ready-to-show", () => {
mainWindow.show();
});
// Open DevTools in development
if (process.env.NODE_ENV === "development") {
mainWindow.webContents.openDevTools();
}
// Emitted when the window is closed
mainWindow.on("closed", () => {
mainWindow = null;
});
}
// This method will be called when Electron has finished initialization
app.whenReady().then(() => {
createWindow();
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});
// Quit when all windows are closed
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});
// Handle IPC messages from renderer
ipcMain.handle("get-market-data", async () => {
const { getMarketData } = require("./src/services/data-fetcher");
return await getMarketData();
});
ipcMain.handle("get-gainers-losers", async (event, params) => {
const { getGainersLosers } = require("./src/services/data-fetcher");
return await getGainersLosers(params);
});
ipcMain.handle("get-sectoral-data", async (event, params) => {
const { getSectoralPerformance } = require("./src/services/data-fetcher");
return await getSectoralPerformance(params?.timePeriod || "1D");
});
ipcMain.handle("get-vix-data", async () => {
const { getVixData } = require("./src/services/data-fetcher");
return await getVixData();
});
ipcMain.handle("search-stocks", async (event, query) => {
const { searchStocks } = require("./src/services/data-fetcher");
return await searchStocks(query);
});
ipcMain.handle("get-trending-stocks", async (event, limit) => {
const { getTrendingStocks } = require("./src/services/data-fetcher");
return await getTrendingStocks(limit);
});
ipcMain.handle("get-stock-profile", async (event, symbol) => {
const { getStockProfile } = require("./src/services/data-fetcher");
return await getStockProfile(symbol);
});
ipcMain.handle("get-stock-chart-data", async (event, symbol, timePeriod) => {
const { getStockChartData } = require("./src/services/data-fetcher");
return await getStockChartData(symbol, timePeriod);
});
ipcMain.handle("get-stock-quote", async (event, symbol, timePeriod) => {
const { getStockQuote } = require("./src/services/data-fetcher");
return await getStockQuote(symbol, timePeriod || "1D");
});