mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-19 10:59:54 +00:00
41 lines
729 B
TypeScript
41 lines
729 B
TypeScript
import { Injectable } from '@angular/core'
|
|
const Config = nodeRequire('electron-config')
|
|
|
|
|
|
@Injectable()
|
|
export class ConfigService {
|
|
constructor() {
|
|
this.config = new Config({name: 'config'})
|
|
this.load()
|
|
}
|
|
|
|
private config: any
|
|
private store: any
|
|
|
|
set(key: string, value: any) {
|
|
this.store.set(key, value)
|
|
this.save()
|
|
}
|
|
|
|
get(key: string): any {
|
|
return this.store[key]
|
|
}
|
|
|
|
has(key: string): boolean {
|
|
return this.store[key] != undefined
|
|
}
|
|
|
|
delete(key: string) {
|
|
delete this.store[key]
|
|
this.save()
|
|
}
|
|
|
|
load() {
|
|
this.store = this.config.store
|
|
}
|
|
|
|
save() {
|
|
this.config.store = this.store
|
|
}
|
|
}
|