mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-11 22:29:38 +00:00
Initial settings tab
This commit is contained in:
@@ -6,8 +6,10 @@ import { Settings } from 'src/electron/shared/Settings'
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class SettingsService {
|
||||
readonly builtinThemes = ['Default', 'Dark']
|
||||
|
||||
private settings: Settings
|
||||
private currentThemeLink: HTMLLinkElement
|
||||
|
||||
constructor(private electronService: ElectronService) { }
|
||||
|
||||
@@ -17,4 +19,47 @@ export class SettingsService {
|
||||
}
|
||||
return this.settings
|
||||
}
|
||||
|
||||
saveSettings() {
|
||||
if (this.settings != undefined) {
|
||||
this.electronService.sendIPC('update-settings', this.settings)
|
||||
}
|
||||
}
|
||||
|
||||
changeTheme(theme: string) {
|
||||
if (this.currentThemeLink != undefined) this.currentThemeLink.remove()
|
||||
if (theme == 'Default') { return }
|
||||
|
||||
const link = document.createElement('link')
|
||||
link.type = 'text/css'
|
||||
link.rel = 'stylesheet'
|
||||
link.href = `assets/themes/${theme}.css`
|
||||
this.currentThemeLink = document.head.appendChild(link)
|
||||
}
|
||||
|
||||
async getCacheSize() {
|
||||
return this.electronService.defaultSession.getCacheSize()
|
||||
}
|
||||
|
||||
async clearCache() {
|
||||
this.saveSettings()
|
||||
return this.electronService.defaultSession.clearCache()
|
||||
}
|
||||
|
||||
get libraryDirectory() {
|
||||
return this.settings == undefined ? '' : this.settings.libraryPath
|
||||
}
|
||||
set libraryDirectory(newValue: string) {
|
||||
this.settings.libraryPath = newValue
|
||||
this.saveSettings()
|
||||
}
|
||||
|
||||
get theme() {
|
||||
return this.settings == undefined ? '' : this.settings.theme
|
||||
}
|
||||
set theme(newValue: string) {
|
||||
this.settings.theme = newValue
|
||||
this.changeTheme(newValue)
|
||||
this.saveSettings()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user