Skip to content

Latest commit

 

History

History
56 lines (41 loc) · 1.5 KB

CREATING_WINDOWS.md

File metadata and controls

56 lines (41 loc) · 1.5 KB




Creating Windows

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()
})

Creating a Window by IPC

Check the About window example and its usage in the main process and in the preload script.