@fiahfy/electron-window
v0.1.0
Published
Manage Window States in Electron Apps.
Downloads
3
Readme
electron-window
Manage Window States in Electron Apps.
Installation
npm install @fiahfy/electron-window
Usage
// main.js
import { createManager } from '@fiahfy/electron-window'
const manager = createManager()
const baseCreateWindow = (options) => {
const browserWindow = new BrowserWindow({
...options,
:
})
:
return browserWindow
}
const manager = createManager(baseCreateWindow)
app.on('activate', async () => {
if (BrowserWindow.getAllWindows().length === 0) {
await manager.create()
}
})
app.on('before-quit', async () => {
await windowManager.save()
})
app.whenReady().then(async () => {
const browserWindows = await windowManager.restore()
if (browserWindows.length === 0) {
await manager.create()
}
})
// preload.js
import { exposeOperations } from '@fiahfy/electron-window/preload'
contextBridge.exposeInMainWorld('electronAPI', {
...exposeOperations(),
}