const app = {
  state: {
    nav: {
      isCollapse: false,
      navClass: 'icon-outdent',
      mobile: false,
      horizontal: false
    },
    constant: {
      perType: 'per_type'
    },
    dict: {}
  },
  mutations: {
    IS_COLLAPSE: state => {
      state.nav.isCollapse = !state.nav.isCollapse;
      state.nav.navClass = state.nav.isCollapse ? 'icon-indent' : 'icon-outdent';
    },
    MOBILE: state => {
      state.nav.mobile = !state.nav.mobile;
    },
    HORIZONTAL: (state, data) => {
      state.nav.horizontal = data;
    },
    SET_DICT: (state, dict) => {
      state.dict = dict;
    }
  },
  actions: {
    // 设置字典
    setDict({ commit }, dict) {
      commit('SET_DICT', dict);
    },
    isCollapseClick: ({ commit }) => {
      commit('IS_COLLAPSE');
    },
    mobile: ({ commit }) => {
      commit('MOBILE');
    },
    horizontal: ({ commit }, data) => {
      commit('HORIZONTAL', data);
    }
  }
};

export default app;
