-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
31 lines (27 loc) · 854 Bytes
/
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
const { app, ipcMain, BrowserWindow } = require('electron');
const { createAuthWindow, createLogoutWindow } = require('./main/authProcess');
const createAppWindow = require('./main/appProcess');
const authService = require('./services/authService');
const apiService = require('./services/apiService');
async function showWindow() {
try {
await authService.refreshTokens();
createAppWindow();
} catch (error) {
createAuthWindow();
}
}
app.on('ready', () => {
ipcMain.handle('auth:get-profile', authService.getProfile);
ipcMain.handle('make-open-ai-request', (e, args) => {
return apiService.makeApiRequest(args);
});
ipcMain.on('auth:logout', () => {
BrowserWindow.getAllWindows().forEach((win) => win.close());
createLogoutWindow();
});
showWindow();
})
app.on('window-all-closed', () => {
app.quit();
});