import Vue from 'vue';
import Vuex from 'vuex';
import _ from 'lodash';
Vue.use(Vuex);
const api = {
  list: `/api/cms/menu/list`,
  fetch: id => `/api/cms/menu/fetch/${id}`,
};
export const state = () => ({});
export const mutations = {};
export const actions = {
  async getMenu({ commit }, { type, data }) {
    let result;
    if (type === `list`) {
      result = await this.$axios.$get(api.list, { ...data, is_use: '0' });
    } else {
      let { id } = data;
      result = await this.$axios.$get(api.fetch(id));
    }
    return result;
  },
};
