29 lines
856 B
TypeScript
29 lines
856 B
TypeScript
import { Store, ActionTree } from 'vuex'
|
|
import { initialiseStores } from '~/utils/store-accessor'
|
|
import { apiHash } from '~/assets/util'
|
|
|
|
const initializer = (store: Store<any>) => initialiseStores(store)
|
|
|
|
export const actions: ActionTree<any, any> = {
|
|
async nuxtServerInit ({ commit }) {
|
|
const [
|
|
hPosts,
|
|
hSlides,
|
|
tPosts,
|
|
] = await Promise.all([
|
|
apiHash('/build/hash/posts.json', Math.random().toString().substr(-5)),
|
|
apiHash('/build/hash/slides.json', Math.random().toString().substr(-5)),
|
|
apiHash('/build/tag/posts.json', Math.random().toString().substr(-5)),
|
|
])
|
|
|
|
commit('global/setHash', {
|
|
posts: JSON.parse(hPosts),
|
|
slides: JSON.parse(hSlides),
|
|
})
|
|
commit('global/setTag', JSON.parse(tPosts))
|
|
},
|
|
}
|
|
|
|
export const plugins = [initializer]
|
|
export * from '~/utils/store-accessor'
|