diff --git a/src/renderer/components/SettingsPanel.vue b/src/renderer/components/SettingsPanel.vue index 6e1f2a4..a7acca1 100644 --- a/src/renderer/components/SettingsPanel.vue +++ b/src/renderer/components/SettingsPanel.vue @@ -33,20 +33,14 @@ } }, methods: { - buttonClick: function () { - this.$store.commit('TOGGLE_HYDRATED') - }, directorySelect: function (flightgearDirectory) { console.log(flightgearDirectory) this.$store.commit('SETTINGS_DIRECTORY', flightgearDirectory.path) } }, computed: { - hydrated: function () { - return this.$store.state.hydrated - }, flightgear_directory: function () { - return this.$store.state.settings.flightgearDirectory + return this.$store.state.Settings.settings.flightgearDirectory } } } diff --git a/src/renderer/store/index.js b/src/renderer/store/index.js index cb16bc5..d8c338b 100644 --- a/src/renderer/store/index.js +++ b/src/renderer/store/index.js @@ -1,25 +1,16 @@ import Vue from 'vue' import Vuex from 'vuex' // import from 'electron-settings' -import createPersistedState from 'vuex-persistedstate' +// import the auto exporter +import createLogger from 'vuex/dist/logger' +import modules from './modules' Vue.use(Vuex) +const debug = process.env.NODE_ENV !== 'production' + export default new Vuex.Store({ - state: { - settings: { flightgearDirectory: '.' } - }, - actions: { - }, - mutations: { - 'DELETE_INDEXED_DB' () {}, - 'SETTINGS_DIRECTORY' (state, flightgearDirectory) { - state.settings.flightgearDirectory = flightgearDirectory - } - }, - getters: { - hydrated: state => state.hydrated - }, - plugins: [createPersistedState()], - strict: true + modules, + strict: debug, + plugins: debug ? [createLogger()] : [] // set logger only for development }) diff --git a/src/renderer/store/modules/Settings.js b/src/renderer/store/modules/Settings.js index ea60197..e8b7cd4 100644 --- a/src/renderer/store/modules/Settings.js +++ b/src/renderer/store/modules/Settings.js @@ -1,25 +1,24 @@ +import createPersistedState from 'vuex-persistedstate' + const state = { - flightgearPath: '' + settings: { flightgearDirectory: '.' } } const mutations = { - DECREMENT_MAIN_COUNTER (state) { - state.main-- - }, - INCREMENT_MAIN_COUNTER (state) { - state.main++ + 'DELETE_INDEXED_DB' () { }, + 'SETTINGS_DIRECTORY' (state, flightgearDirectory) { + state.settings.flightgearDirectory = flightgearDirectory } } +const plugins = [createPersistedState()] + const actions = { - someAsyncTask ({ commit }) { - // do something async - commit('INCREMENT_MAIN_COUNTER') - } } export default { state, mutations, - actions + actions, + plugins }