menu.js 640 B

12345678910111213141516171819202122232425262728293031323334
  1. import axios from "axios";
  2. export const state = () => ({
  3. menu: []
  4. });
  5. export const mutations = {
  6. SET_MENU(state, menu) {
  7. state.menu = menu;
  8. }
  9. };
  10. export const actions = {
  11. async getMenu({ commit }) {
  12. await axios.get("https://api.amic.ru/api/v1/menu/list").then(res => {
  13. commit("SET_MENU", res.data.data)
  14. return true
  15. })
  16. }
  17. };
  18. export const getters = {
  19. menuHeader: s => s.menu.filter(link => link.type == 'header'),
  20. menuFooter: s => s.menu.filter(link => link.type == 'footer'),
  21. };
  22. export default {
  23. namespaced: true,
  24. state,
  25. getters,
  26. actions,
  27. mutations
  28. }