Modularized store

pull/36/head
portree_kid 5 years ago
parent 791ec7ae24
commit 40df1f1202

@ -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
}
}
}

@ -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
})

@ -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
}

Loading…
Cancel
Save