feat: update electron configuration and add locale-based language selection #370

This commit is contained in:
kangfenmao
2024-11-21 18:12:34 +08:00
parent a32df473a3
commit e205c021e0
2 changed files with 8 additions and 2 deletions
+4 -1
View File
@@ -2,6 +2,8 @@ import { LanguageVarious, ThemeMode } from '@types'
import { app } from 'electron'
import Store from 'electron-store'
import { locales } from '../utils/locales'
export class ConfigManager {
private store: Store
private subscribers: Map<string, Array<(newValue: any) => void>> = new Map()
@@ -11,7 +13,8 @@ export class ConfigManager {
}
getLanguage(): LanguageVarious {
return this.store.get('language', app.getLocale()) as LanguageVarious
const locale = Object.keys(locales).includes(app.getLocale()) ? app.getLocale() : 'en-US'
return this.store.get('language', locale) as LanguageVarious
}
setLanguage(theme: LanguageVarious) {