Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3.  
  4. import * as api from './api'
  5.  
  6. Vue.use(Vuex)
  7.  
  8. const state = {
  9. appLoaded: false,
  10.  
  11. appName: 'cryChan',
  12.  
  13. appBoardsList: [],
  14. appPagesList: [],
  15.  
  16. appPage: {}
  17. }
  18.  
  19. const mutations = {
  20. SET_BOARDS_LIST (state) {
  21. state.appBoardsList = [
  22. { slug: 'b', name: 'Random', isHide: false },
  23. { slug: 'mu', name: 'Music', isHide: false }
  24. ]
  25. },
  26. SET_PAGES_LIST (state, payload) {
  27. state.appPagesList = payload.pages_list
  28. },
  29. SET_PAGE (state, payload) {
  30. state.appPage[payload.page_slug] = payload.page_data
  31. }
  32. }
  33.  
  34. const actions = {
  35. FETCH_HEADER ({ commit }) {
  36. commit('SET_BOARDS_LIST')
  37. api.pages.getList()
  38. .then(function(pages_list) {
  39. commit('SET_PAGES_LIST', { pages_list })
  40. })
  41. .catch(function(error) {
  42. console.log(error)
  43. })
  44. },
  45. FETCH_PAGE ({ commit }, page_slug) {
  46. api.pages.getPage(page_slug)
  47. .then(function(page_data) {
  48. commit('SET_PAGE', { page_slug, page_data })
  49. })
  50. .catch(function(error) {
  51. console.log(error)
  52. })
  53. }
  54. }
  55.  
  56. const store = new Vuex.Store({
  57. state,
  58. mutations,
  59. actions
  60. })
  61.  
  62. export default store
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement