At src/main/windows
create a folder named as MyWindow
and inside this folder an index.ts
with the following content:
import { createWindow } from 'main/factories'
export async function MyWindow() {
const window = createWindow({
id: 'myWindow',
title: 'My Window',
width: 450,
height: 320,
alwaysOnTop: true,
})
return window
}
Then, at src/main/windows/index.ts
, add the MyWindow
import:
export * from './MyWindow'
export * from './About'
export * from './Main'
Now, at src/main/index.ts
, you can use it like:
import { app } from 'electron'
import { MainWindow, MyWindow, registerAboutWindowCreationByIPC } from './windows'
import { makeAppSetup, makeAppWithSingleInstanceLock } from './factories'
makeAppWithSingleInstanceLock(async () => {
await app.whenReady()
await makeAppSetup(MainWindow)
await MyWindow()
registerAboutWindowCreationByIPC()
})
Check the About window example and its usage in the main process and in the preload script.