60 lines
1.7 KiB
JavaScript
60 lines
1.7 KiB
JavaScript
const { app, BrowserWindow, screen, ipcMain } = require('electron');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
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://10.74.231.124: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://10.74.231.124:4200/shared-display');
|
|
|
|
ipcMain.on('open-second-screen', () => screenWindow.show());
|
|
ipcMain.on('close-second-screen', () => screenWindow.hide());
|
|
|
|
// ✅ IPC to return BTID
|
|
ipcMain.handle('get-btid', () => {
|
|
try {
|
|
const filePath = path.join(process.env.HOME || process.env.USERPROFILE, 'BTID', 'betting.txt');
|
|
const content = fs.readFileSync(filePath, 'utf-8');
|
|
const match = content.match(/Btid\s*=\s*(\d+)/i);
|
|
return match ? match[1] : null;
|
|
} catch (err) {
|
|
console.error('Error reading betting.txt:', err);
|
|
return null;
|
|
}
|
|
});
|
|
}
|
|
|
|
app.whenReady().then(createWindows);
|
|
app.on('window-all-closed', () => app.quit());
|