ghost-portal/packages/apps-electron/src/electron/window.ts
2022-01-01 09:30:15 +02:00

32 lines
830 B
TypeScript

// Copyright 2017-2022 @polkadot/apps authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { BrowserWindow, screen } from 'electron';
import path from 'path';
export function createWindow (environment: string): Promise<unknown> {
const { height, width } = screen.getPrimaryDisplay().workAreaSize;
const win = new BrowserWindow({
height,
icon: path.join(__dirname, 'icon.png'),
webPreferences: {
contextIsolation: true,
enableRemoteModule: false,
nodeIntegration: false,
preload: path.join(__dirname, 'preload.js')
},
width
});
if (environment === 'development') {
win.webContents.openDevTools();
return win.loadURL('http://127.0.0.1:3000/');
}
const mainFilePath = path.resolve(__dirname, 'index.html');
return win.loadFile(mainFilePath);
}