antares/src/renderer/store/modules/settings.store.js

46 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-05-29 18:19:35 +02:00
'use strict';
import i18n from '@/i18n';
import Store from 'electron-store';
const persistentStore = new Store({ name: 'settings' });
2020-05-29 18:19:35 +02:00
export default {
namespaced: true,
strict: true,
state: {
locale: persistentStore.get('locale') || 'en-US',
explorebar_size: persistentStore.get('explorebar_size') || null,
notifications_timeout: persistentStore.get('notifications_timeout') || 5
2020-05-29 18:19:35 +02:00
},
getters: {
2020-06-02 19:13:57 +02:00
getLocale: state => state.locale,
getExplorebarSize: state => state.explorebar_size,
getNotificationsTimeout: state => state.notifications_timeout
2020-05-29 18:19:35 +02:00
},
mutations: {
SET_LOCALE (state, locale) {
state.locale = locale;
i18n.locale = locale;
persistentStore.set('locale', state.locale);
2020-06-02 19:13:57 +02:00
},
SET_NOTIFICATIONS_TIMEOUT (state, timeout) {
state.notifications_timeout = timeout;
persistentStore.set('notifications_timeout', state.notifications_timeout);
},
2020-06-02 19:13:57 +02:00
SET_EXPLOREBAR_SIZE (state, size) {
state.explorebar_size = size;
persistentStore.set('explorebar_size', state.explorebar_size);
2020-05-29 18:19:35 +02:00
}
},
actions: {
changeLocale ({ commit }, locale) {
commit('SET_LOCALE', locale);
2020-06-02 19:13:57 +02:00
},
updateNotificationsTimeout ({ commit }, timeout) {
commit('SET_NOTIFICATIONS_TIMEOUT', timeout);
},
2020-06-02 19:13:57 +02:00
changeExplorebarSize ({ commit }, size) {
commit('SET_EXPLOREBAR_SIZE', size);
2020-05-29 18:19:35 +02:00
}
}
};