48 lines
1.2 KiB
TypeScript
Raw Normal View History

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