| import { app } from 'electron' |
| import Store from 'electron-store' |
|
|
| const DEFAULT_WIDTH = 1000 |
| const DEFAULT_HEIGHT = 800 |
|
|
| const storage = new Store() |
|
|
| export const setupCore = async () => { |
| |
| global.core = { |
| |
| appPath: () => app.getPath('userData'), |
| } |
| } |
|
|
| export const getBounds = async () => { |
| const defaultBounds = { |
| x: undefined, |
| y: undefined, |
| width: DEFAULT_WIDTH, |
| height: DEFAULT_HEIGHT, |
| } |
|
|
| const bounds = await storage.get('windowBounds') |
| if (bounds) { |
| return bounds as Electron.Rectangle |
| } else { |
| storage.set('windowBounds', defaultBounds) |
| return defaultBounds |
| } |
| } |
|
|
| export const saveBounds = (bounds: Electron.Rectangle | undefined) => { |
| storage.set('windowBounds', bounds) |
| } |
|
|