48 lines
1.2 KiB
TypeScript

import ElectronStore from 'electron-store';
import { app } from 'electron';
const STORE_KEY_STARTUPHIDEWINDOW = 'options.startupHideWindow';
const STORE_KEY_DOWNLOADFOLDER = 'options.downloadPath';
export class Storage {
private readonly store: ElectronStore<any>;
constructor() {
this.store = new ElectronStore({
schema: {
options: {
type: 'object',
properties: {
startupHideWindow: {
type: 'boolean'
},
downloadPath: {
type: 'string'
}
},
default: {
startupHideWindow: false,
downloadPath: app.getPath('downloads')
}
}
},
encryptionKey: 'ucap',
fileExtension: 'dat'
});
}
get startupHideWindow(): boolean {
return this.store.get(STORE_KEY_STARTUPHIDEWINDOW, false);
}
set startupHideWindow(startupHideWindow: boolean) {
this.store.set(STORE_KEY_STARTUPHIDEWINDOW, startupHideWindow);
}
get downloadPath(): string {
return this.store.get(STORE_KEY_DOWNLOADFOLDER, false);
}
set downloadPath(downloadPath: string) {
this.store.set(STORE_KEY_DOWNLOADFOLDER, downloadPath);
}
}