feat(UI): auto detect system theme as default app theme

This commit is contained in:
Fabio Di Stasio 2021-10-01 15:48:02 +02:00
parent 7ea7b369ab
commit 7a63608f54
1 changed files with 5 additions and 2 deletions

View File

@ -2,6 +2,9 @@
import i18n from '@/i18n'; import i18n from '@/i18n';
import Store from 'electron-store'; import Store from 'electron-store';
const persistentStore = new Store({ name: 'settings' }); const persistentStore = new Store({ name: 'settings' });
const isDarkTheme = window.matchMedia('(prefers-color-scheme: dark)');
const defaultAppTheme = isDarkTheme.matches ? 'dark' : 'light';
const defaultEditorTheme = isDarkTheme.matches ? 'twilight' : 'sqlserver';
export default { export default {
namespaced: true, namespaced: true,
@ -14,8 +17,8 @@ export default {
data_tab_limit: persistentStore.get('data_tab_limit', 1000), data_tab_limit: persistentStore.get('data_tab_limit', 1000),
auto_complete: persistentStore.get('auto_complete', true), auto_complete: persistentStore.get('auto_complete', true),
line_wrap: persistentStore.get('line_wrap', true), line_wrap: persistentStore.get('line_wrap', true),
application_theme: persistentStore.get('application_theme', 'dark'), application_theme: persistentStore.get('application_theme', defaultAppTheme),
editor_theme: persistentStore.get('editor_theme', 'twilight'), editor_theme: persistentStore.get('editor_theme', defaultEditorTheme),
editor_font_size: persistentStore.get('editor_font_size', 'medium'), editor_font_size: persistentStore.get('editor_font_size', 'medium'),
restore_tabs: persistentStore.get('restore_tabs', true) restore_tabs: persistentStore.get('restore_tabs', true)
}, },