15.08 Get & Apply the LocalStorage Settings on App Load
This commit is contained in:
parent
7443c2cf6a
commit
5f9b395ecc
10
src/App.vue
10
src/App.vue
@ -4,8 +4,16 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { mapActions } from 'vuex'
|
||||
|
||||
export default {
|
||||
name: 'App'
|
||||
name: 'App',
|
||||
methods: {
|
||||
...mapActions('settings', ['getSettings'])
|
||||
},
|
||||
mounted () {
|
||||
this.getSettings()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -13,6 +13,9 @@ const mutations = {
|
||||
},
|
||||
setShowTasksInOnelist (state, value) {
|
||||
state.settings.showTasksInOnelist = value
|
||||
},
|
||||
setSettings (state, value) {
|
||||
Object.assign(state.settings, value)
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,6 +30,12 @@ const actions = {
|
||||
},
|
||||
saveSettings ({ state }) {
|
||||
LocalStorage.set('settings', state.settings)
|
||||
},
|
||||
getSettings ({ commit }) {
|
||||
const settings = LocalStorage.getItem('settings')
|
||||
if (settings) {
|
||||
commit('setSettings', settings)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user