mirror of
https://gitlab.com/futo-org/fcast.git
synced 2025-06-24 21:25:23 +00:00
Initial commit of new updater
This commit is contained in:
parent
698c10f356
commit
869ac1433f
16 changed files with 952 additions and 295 deletions
35
receivers/electron/src/Store.ts
Normal file
35
receivers/electron/src/Store.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import storage from 'electron-json-storage';
|
||||
import { app } from 'electron';
|
||||
import * as log4js from "log4js";
|
||||
const logger = log4js.getLogger();
|
||||
|
||||
export class Store {
|
||||
private static storeVersion = 1;
|
||||
private static userSettings = 'UserSettings';
|
||||
private static settingsCache: any = null;
|
||||
|
||||
static {
|
||||
storage.setDataPath(app.getPath('userData'));
|
||||
Store.settingsCache = storage.getSync(Store.userSettings);
|
||||
|
||||
if (Store.get('storeVersion') === null) {
|
||||
Store.set('storeVersion', Store.storeVersion);
|
||||
}
|
||||
}
|
||||
|
||||
public static get(key: string): any {
|
||||
return Store.settingsCache[key] ?? null;
|
||||
}
|
||||
|
||||
public static set(key: string, value: any) {
|
||||
Store.settingsCache[key] = value;
|
||||
|
||||
logger.info(`Writing settings file: key '${key}', value ${JSON.stringify(value)}`);
|
||||
storage.set(Store.userSettings, Store.settingsCache, (err) => {
|
||||
if (err) {
|
||||
logger.error(`Error writing user settings: ${err}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue