init change

This commit is contained in:
Gaëtan
2022-12-12 22:14:06 +01:00
parent 398494c320
commit 9fbf81f8f2
+27 -4
View File
@@ -1,10 +1,13 @@
import { InstallationLocationService } from '../services/installation-location.service';
import ElectronStore from "electron-store";
import { Template } from 'webpack';
export class ConfigurationService {
private static instance: ConfigurationService;
private readonly _store: ElectronStore;
private readonly _versionBsStore: ElectronStore;
public static getInstance(): ConfigurationService{
if(!ConfigurationService.instance){ ConfigurationService.instance = new ConfigurationService(); }
@@ -13,20 +16,40 @@ export class ConfigurationService {
private constructor(){
this._store = new ElectronStore();
this._versionBsStore = new ElectronStore({cwd : InstallationLocationService.getInstance().installationDirectory});
}
public get store(): ElectronStore{ return this._store; }
public get versionBsStore() : ElectronStore{ return this._versionBsStore;}
public set(key: string, value: any): void{
public set(key: string, value: any, storeSelected : string): void{
if (storeSelected === "store"){
this.store.set(key, value);
}
else if (storeSelected === "versionBsStore")
{
this.versionBsStore.set(key, value);
}
else return null;
}
public get<T>(key: string): T{
public get<T>(key: string,storeSelected : string): T{
if (storeSelected === "store"){
return this.store.get(key) as T;
}
else if (storeSelected === "versionBsStore"){
return this.store.get(key) as T;
}
}
public delete(key: string): void{
public delete(key: string,storeSelected : string): void{
if (storeSelected === "store"){
this.store.delete(key);
}
else if (storeSelected === "versionBsStore"){
this.store.delete(key);
}
}
}
}