46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
const { app, BrowserWindow, screen, ipcMain } = require('electron');
|
|
const path = require('path');
|
|
|
|
let mainWindow;
|
|
let screenWindow;
|
|
|
|
function createWindows() {
|
|
const displays = screen.getAllDisplays();
|
|
const primary = screen.getPrimaryDisplay();
|
|
const secondary = displays.find(d => d.id !== primary.id) || primary;
|
|
|
|
mainWindow = new BrowserWindow({
|
|
x: primary.bounds.x,
|
|
y: primary.bounds.y,
|
|
width: primary.bounds.width,
|
|
height: primary.bounds.height,
|
|
webPreferences: {
|
|
preload: path.join(__dirname, 'preload.js'),
|
|
contextIsolation: true,
|
|
}
|
|
});
|
|
|
|
mainWindow.loadURL('http://192.168.0.103:4200/login');
|
|
|
|
screenWindow = new BrowserWindow({
|
|
x: secondary.bounds.x,
|
|
y: secondary.bounds.y,
|
|
width: secondary.bounds.width,
|
|
height: secondary.bounds.height,
|
|
frame: false,
|
|
show: false,
|
|
webPreferences: {
|
|
preload: path.join(__dirname, 'preload.js'),
|
|
contextIsolation: true,
|
|
}
|
|
});
|
|
|
|
screenWindow.loadURL('http://192.168.0.103:4200/shared-display');
|
|
|
|
ipcMain.on('open-second-screen', () => screenWindow.show());
|
|
ipcMain.on('close-second-screen', () => screenWindow.hide());
|
|
}
|
|
|
|
app.whenReady().then(createWindows);
|
|
app.on('window-all-closed', () => app.quit());
|