fix: default setup language to system locale (#500)
This commit is contained in:
committed by
GitHub
Unverified
parent
04aa94f907
commit
08960d700f
@@ -4,6 +4,8 @@
|
||||
*/
|
||||
|
||||
import { randomBytes } from 'crypto';
|
||||
import { app } from 'electron';
|
||||
import { resolveSupportedLanguage } from '../../shared/language';
|
||||
|
||||
// Lazy-load electron-store (ESM module)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@@ -59,42 +61,54 @@ export interface AppSettings {
|
||||
/**
|
||||
* Default settings
|
||||
*/
|
||||
const defaults: AppSettings = {
|
||||
// General
|
||||
theme: 'system',
|
||||
language: 'en',
|
||||
startMinimized: false,
|
||||
launchAtStartup: false,
|
||||
telemetryEnabled: true,
|
||||
machineId: '',
|
||||
hasReportedInstall: false,
|
||||
function getSystemLocale(): string {
|
||||
const preferredLanguages = typeof app.getPreferredSystemLanguages === 'function'
|
||||
? app.getPreferredSystemLanguages()
|
||||
: [];
|
||||
return preferredLanguages[0]
|
||||
|| (typeof app.getLocale === 'function' ? app.getLocale() : '')
|
||||
|| Intl.DateTimeFormat().resolvedOptions().locale
|
||||
|| 'en';
|
||||
}
|
||||
|
||||
// Gateway
|
||||
gatewayAutoStart: true,
|
||||
gatewayPort: 18789,
|
||||
gatewayToken: generateToken(),
|
||||
proxyEnabled: false,
|
||||
proxyServer: '',
|
||||
proxyHttpServer: '',
|
||||
proxyHttpsServer: '',
|
||||
proxyAllServer: '',
|
||||
proxyBypassRules: '<local>;localhost;127.0.0.1;::1',
|
||||
function createDefaultSettings(): AppSettings {
|
||||
return {
|
||||
// General
|
||||
theme: 'system',
|
||||
language: resolveSupportedLanguage(getSystemLocale()),
|
||||
startMinimized: false,
|
||||
launchAtStartup: false,
|
||||
telemetryEnabled: true,
|
||||
machineId: '',
|
||||
hasReportedInstall: false,
|
||||
|
||||
// Update
|
||||
updateChannel: 'stable',
|
||||
autoCheckUpdate: true,
|
||||
autoDownloadUpdate: false,
|
||||
skippedVersions: [],
|
||||
// Gateway
|
||||
gatewayAutoStart: true,
|
||||
gatewayPort: 18789,
|
||||
gatewayToken: generateToken(),
|
||||
proxyEnabled: false,
|
||||
proxyServer: '',
|
||||
proxyHttpServer: '',
|
||||
proxyHttpsServer: '',
|
||||
proxyAllServer: '',
|
||||
proxyBypassRules: '<local>;localhost;127.0.0.1;::1',
|
||||
|
||||
// UI State
|
||||
sidebarCollapsed: false,
|
||||
devModeUnlocked: false,
|
||||
// Update
|
||||
updateChannel: 'stable',
|
||||
autoCheckUpdate: true,
|
||||
autoDownloadUpdate: false,
|
||||
skippedVersions: [],
|
||||
|
||||
// Presets
|
||||
selectedBundles: ['productivity', 'developer'],
|
||||
enabledSkills: [],
|
||||
disabledSkills: [],
|
||||
};
|
||||
// UI State
|
||||
sidebarCollapsed: false,
|
||||
devModeUnlocked: false,
|
||||
|
||||
// Presets
|
||||
selectedBundles: ['productivity', 'developer'],
|
||||
enabledSkills: [],
|
||||
disabledSkills: [],
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the settings store instance (lazy initialization)
|
||||
@@ -104,7 +118,7 @@ async function getSettingsStore() {
|
||||
const Store = (await import('electron-store')).default;
|
||||
settingsStoreInstance = new Store<AppSettings>({
|
||||
name: 'settings',
|
||||
defaults,
|
||||
defaults: createDefaultSettings(),
|
||||
});
|
||||
}
|
||||
return settingsStoreInstance;
|
||||
|
||||
Reference in New Issue
Block a user