https://github.com/xupea/stateful-electron-window
A library to store and restore window sizes and positions for your Electron app
https://github.com/xupea/stateful-electron-window
electron electron-window
Last synced: about 1 month ago
JSON representation
A library to store and restore window sizes and positions for your Electron app
- Host: GitHub
- URL: https://github.com/xupea/stateful-electron-window
- Owner: xupea
- Created: 2024-01-12T13:58:16.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-14T03:18:29.000Z (over 2 years ago)
- Last Synced: 2025-02-24T15:48:25.013Z (over 1 year ago)
- Topics: electron, electron-window
- Language: TypeScript
- Homepage: https://www.xupea.com
- Size: 143 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# stateful-electron-window
[](https://github.com/xupea/stateful-electron-window/actions/workflows/tests.yml)
[](https://badge.fury.io/js/stateful-electron-window)
[](https://img.shields.io/npm/dw/stateful-electron-window)
A library to store and restore window sizes and positions for your Electron app
## Installation
Install with [npm](https://npmjs.org/package/stateful-electron-window):
npm install stateful-electron-window
## Usage
```
import { StatefullBrowserWindow } from 'stateful-electron-window'
const mainWindow = new StatefullBrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
},
supportMaximize: true
})
```
## API
#### new StatefullBrowserWindow(options)
StatefullBrowserWindow extends BrowserWindow.
##### options
`configFilePath` - _String_
The path where the state file should be written to. Defaults to
`app.getPath('userData')`
`configFileName` - _String_
The name of file. Defaults to `window-state.json`. This is usefull if you want to support multiple windows.
`supportMaximize` - _Boolean_
Should we automatically maximize the window, if it was last closed
maximized. Defaults to `false`