|
@@ -1,6 +1,5 @@
|
|
import api from '@/api'
|
|
import api from '@/api'
|
|
-import { Page } from '@/api/queries'
|
|
|
|
-
|
|
|
|
|
|
+import { Page, Burger } from '@/api/queries'
|
|
|
|
|
|
export default {
|
|
export default {
|
|
state: {
|
|
state: {
|
|
@@ -13,6 +12,11 @@ export default {
|
|
kit: 265,
|
|
kit: 265,
|
|
gallery: 349
|
|
gallery: 349
|
|
},
|
|
},
|
|
|
|
+ pages: {},
|
|
|
|
+ burger: [
|
|
|
|
+ { name: 'home' },
|
|
|
|
+ { name: 'introduction' }
|
|
|
|
+ ],
|
|
visited: localStorage.getItem('visited') === 'true'
|
|
visited: localStorage.getItem('visited') === 'true'
|
|
},
|
|
},
|
|
|
|
|
|
@@ -21,6 +25,14 @@ export default {
|
|
state[slug] = page
|
|
state[slug] = page
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ 'SET_PAGE_FROM_ID' (state, { id, page }) {
|
|
|
|
+ state.pages[id] = page
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ 'SET_BURGER' (state, burger) {
|
|
|
|
+ state.burger = [...state.burger, ...burger]
|
|
|
|
+ },
|
|
|
|
+
|
|
'SET_VISITED' (state, visited) {
|
|
'SET_VISITED' (state, visited) {
|
|
state.visited = visited
|
|
state.visited = visited
|
|
localStorage.setItem('visited', visited)
|
|
localStorage.setItem('visited', visited)
|
|
@@ -34,10 +46,32 @@ export default {
|
|
commit('SET_PAGE', { slug, page: data.page })
|
|
commit('SET_PAGE', { slug, page: data.page })
|
|
return state[slug]
|
|
return state[slug]
|
|
})
|
|
})
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ async 'QUERY_PAGE_BY_ID' ({ state, commit, dispatch, getters }, id) {
|
|
|
|
+ if (state.pages[id] !== undefined) return state.pages[id]
|
|
|
|
+ return api.query(Page, { id }).then(data => {
|
|
|
|
+ commit('SET_PAGE_FROM_ID', { id, page: data.page })
|
|
|
|
+ return state.pages[id]
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ async 'GET_BURGER' ({ state, commit }) {
|
|
|
|
+ if (state.burger.length > 2) return state.burger
|
|
|
|
+ return api.query(Burger).then(data => {
|
|
|
|
+ const burger = data.burger.sort((a, b) => {
|
|
|
|
+ return a.poid > b.poid ? 1 : -1
|
|
|
|
+ }).map(page => {
|
|
|
|
+ return { name: 'pages', id: page.id, title: page.title }
|
|
|
|
+ })
|
|
|
|
+ commit('SET_BURGER', burger)
|
|
|
|
+ return burger
|
|
|
|
+ })
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
getters: {
|
|
getters: {
|
|
- visited: state => state.visited
|
|
|
|
|
|
+ visited: state => state.visited,
|
|
|
|
+ burger: state => state.burger
|
|
}
|
|
}
|
|
}
|
|
}
|