import Vue from 'vue';
import Vuex from 'vuex';
import _ from 'lodash';
Vue.use(Vuex);
const api = {
  query: `/api/cms/site/query`,
  fetch: `/api/cms/site/config`,
  content: `/api/cms/site/content`,
};
export const state = () => ({});
export const mutations = {};
export const actions = {
  async getSite({ commit }, { type, data }) {
    let content = await this.$axios.$get(api.content, {});
    let result = await this.$axios.$get(_.get(api, `fetch`));
    if (content.data && `${content.errcode}` === '0') {
      result.data.content = content && content.data ? content.data : '';
    }
    return result;
  },
};
