-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
93 lines (80 loc) · 2.9 KB
/
main.js
File metadata and controls
93 lines (80 loc) · 2.9 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
// main.js
const { app, BrowserWindow, BrowserView } = require('electron');
const path = require('path');
const createWindow = () => {
// Create the browser window with specified dimensions
const mainWindow = new BrowserWindow({
width: 1400,
height: 900,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: false,
contextIsolation: true,
},
});
// Create three BrowserViews for the AI services with persistent partitions
const claudeView = new BrowserView({
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: false,
contextIsolation: true,
partition: 'persist:claude'
}
});
const chatGPTView = new BrowserView({
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: false,
contextIsolation: true,
partition: 'persist:gpt'
}
});
const grokView = new BrowserView({
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: false,
contextIsolation: true,
partition: 'persist:grok'
}
});
// Add the views to the main window
mainWindow.addBrowserView(claudeView);
mainWindow.addBrowserView(chatGPTView);
mainWindow.addBrowserView(grokView);
// Set the bounds for each view (dividing the window into 3 equal columns)
const windowWidth = 1400;
const windowHeight = 900;
const columnWidth = Math.floor(windowWidth / 3);
claudeView.setBounds({ x: 0, y: 0, width: columnWidth, height: windowHeight });
chatGPTView.setBounds({ x: columnWidth, y: 0, width: columnWidth, height: windowHeight });
grokView.setBounds({ x: columnWidth * 2, y: 0, width: columnWidth, height: windowHeight });
// Load the respective URLs
claudeView.webContents.loadURL('https://claude.ai');
chatGPTView.webContents.loadURL('https://chat.openai.com');
grokView.webContents.loadURL('https://grok.x.ai');
// Handle window resize to adjust view bounds
mainWindow.on('resize', () => {
const [newWidth, newHeight] = mainWindow.getSize();
const newColumnWidth = Math.floor(newWidth / 3);
claudeView.setBounds({ x: 0, y: 0, width: newColumnWidth, height: newHeight });
chatGPTView.setBounds({ x: newColumnWidth, y: 0, width: newColumnWidth, height: newHeight });
grokView.setBounds({ x: newColumnWidth * 2, y: 0, width: newColumnWidth, height: newHeight });
});
};
// This method will be called when Electron has finished initialization
app.whenReady().then(() => {
createWindow();
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});
// Quit when all windows are closed, except on macOS
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});