56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
import { app, screen, BrowserWindow } from 'electron'
|
|
import {join} from "path";
|
|
import './load-serialport'
|
|
|
|
function createWindow(page: string, display: any) {
|
|
const win = new BrowserWindow({
|
|
fullscreen: true,
|
|
frame: false,
|
|
x: display.bounds.x,
|
|
y: display.bounds.y,
|
|
webPreferences: {
|
|
nodeIntegration: true,
|
|
preload: join(__dirname, 'preload.js')
|
|
}
|
|
})
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
win.loadURL(`http://localhost:3000/${page}.html`)
|
|
win.webContents.openDevTools()
|
|
} else {
|
|
win.loadFile(`dist/render/${page}.html`)
|
|
win.webContents.openDevTools()
|
|
}
|
|
}
|
|
|
|
function launch() {
|
|
const displays = screen.getAllDisplays()
|
|
|
|
if (displays.length !== 4) {
|
|
createWindow('satellite-data-monitor-platform', displays[0])
|
|
// createWindow('satellite-info-monitor-platform', displays[0])
|
|
// createWindow('satellite-signal-monitor-platform', displays[0])
|
|
// createWindow('satellite-state-monitor-platform', displays[0])
|
|
|
|
} else {
|
|
// createWindow('satellite-data-monitor-platform', displays[0])
|
|
createWindow('satellite-info-monitor-platform', displays[1])
|
|
// createWindow('satellite-signal-monitor-platform', displays[2])
|
|
// createWindow('satellite-state-monitor-platform', displays[3])
|
|
|
|
}
|
|
}
|
|
|
|
app.whenReady().then(launch)
|
|
|
|
app.on('window-all-closed', () => {
|
|
if (process.platform !== 'darwin') {
|
|
app.quit()
|
|
}
|
|
})
|
|
|
|
app.on('activate', () => {
|
|
if (BrowserWindow.getAllWindows().length === 0) {
|
|
launch()
|
|
}
|
|
}) |