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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
import { mapActions } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'App'
|
name: 'App',
|
||||||
|
methods: {
|
||||||
|
...mapActions('settings', ['getSettings'])
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
this.getSettings()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -13,6 +13,9 @@ const mutations = {
|
|||||||
},
|
},
|
||||||
setShowTasksInOnelist (state, value) {
|
setShowTasksInOnelist (state, value) {
|
||||||
state.settings.showTasksInOnelist = value
|
state.settings.showTasksInOnelist = value
|
||||||
|
},
|
||||||
|
setSettings (state, value) {
|
||||||
|
Object.assign(state.settings, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,6 +30,12 @@ const actions = {
|
|||||||
},
|
},
|
||||||
saveSettings ({ state }) {
|
saveSettings ({ state }) {
|
||||||
LocalStorage.set('settings', state.settings)
|
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