add pages store module

This commit is contained in:
axolotle
2021-07-02 17:07:58 +02:00
parent f46eaf846a
commit 2f784cbe29
2 changed files with 36 additions and 1 deletions
+33
View File
@@ -0,0 +1,33 @@
import api from '@/api'
import { Page } from '@/api/queries'
export default {
state: {
welcome: undefined,
intro: undefined,
ids: {
welcome: 1,
intro: 207
}
},
mutations: {
'SET_PAGE' (state, { slug, page }) {
state[slug] = page
}
},
actions: {
async 'QUERY_PAGE' ({ state, commit, dispatch, getters }, slug) {
if (state[slug] !== undefined) return state[slug]
return api.query(Page, { id: state.ids[slug] }).then(data => {
commit('SET_PAGE', { slug, page: data.page })
return state[slug]
})
}
},
getters: {
}
}