ghost-portal/packages/apps-electron/src/electron/window.ts
Jaco 4929b1c6fd
Update headers for 2023 (#8665)
* Update headers for 2023

* Adjust env-config
2023-01-01 10:32:05 +02:00

31 lines
797 B
TypeScript

// Copyright 2017-2023 @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,
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);
}