37 lines
898 B
TypeScript
37 lines
898 B
TypeScript
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 (cortexsoVersion: string) => {
|
|
// Setup core api for main process
|
|
global.core = {
|
|
// Define appPath function for app to retrieve app path globally
|
|
appPath: () => app.getPath('userData'),
|
|
cortexVersion: () => cortexsoVersion,
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|