15.03 Vuex - Create a Settings Store
This commit is contained in:
parent
db595d0276
commit
fe08b091e7
@ -19,11 +19,14 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
|
||||
export default {
|
||||
name: 'PageSettings',
|
||||
data () {
|
||||
return {
|
||||
show12HourTimeFormat: false
|
||||
computed: {
|
||||
...mapGetters('settings', ['settings']),
|
||||
show12HourTimeFormat () {
|
||||
return this.settings.show12HourTimeFormat
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
import tasks from './store-tasks'
|
||||
import settings from './store-settings'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
@ -17,7 +18,8 @@ Vue.use(Vuex)
|
||||
export default function (/* { ssrContext } */) {
|
||||
const Store = new Vuex.Store({
|
||||
modules: {
|
||||
tasks
|
||||
tasks,
|
||||
settings
|
||||
},
|
||||
|
||||
// enable strict mode (adds overhead!)
|
||||
|
25
src/store/store-settings.js
Normal file
25
src/store/store-settings.js
Normal file
@ -0,0 +1,25 @@
|
||||
const state = {
|
||||
settings: {
|
||||
show12HourTimeFormat: false
|
||||
}
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
}
|
||||
|
||||
const actions = {
|
||||
}
|
||||
|
||||
const getters = {
|
||||
settings: state => {
|
||||
return state.settings
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
mutations,
|
||||
actions,
|
||||
getters
|
||||
}
|
Loading…
Reference in New Issue
Block a user