pages.js 651 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const SET_PAGES = 'SET_PAGES';
  2. const SET_AD = 'SET_AD';
  3. const state = {
  4. loaded: false,
  5. data: undefined,
  6. ad: false,
  7. };
  8. const getters = {
  9. pages(state) {
  10. return state.data;
  11. },
  12. };
  13. const actions = {
  14. setPage({ commit }, pages) {
  15. console.log('setPage', pages);
  16. if (pages.main.adUrl) {
  17. commit(SET_AD, true);
  18. }
  19. commit(SET_PAGES, pages);
  20. },
  21. };
  22. const mutations = {
  23. [SET_PAGES](state, payload) {
  24. console.log('SET_PAGES', payload);
  25. state.loaded = true;
  26. state.data = payload;
  27. },
  28. [SET_AD](state, payload) {
  29. state.ad = payload;
  30. },
  31. };
  32. export default {
  33. state,
  34. getters,
  35. actions,
  36. mutations,
  37. };