import Vue from "vue";
import Vuex from "vuex";


Vue.use(Vuex);
const defaultSetting = {
  gridShow: 1,
  language: "cn",
  gridValue: 1,
  autoPrint: false,
  gridSpacing: "10mm"
};
export default new Vuex.Store({
  state: {
    actionList: [],
    imgList: [],
    actionIndex: -1,
    systemSetting: {
      gridShow: 1,
      gridValue: 1,
      unit: "mm",
      language: "cn",
      autoPrint: false,
      gridSpacing: 10
    }
  },
  mutations: {
    setDefaultSetting(state) {
      state.systemSetting = JSON.parse(JSON.stringify(defaultSetting));
    },
    updateSystemSetting(state, f) {
      state.systemSetting[f.field] = f.value;
    },
    changeActionList(state, value) {
      state.actionList = value;
    },
    changeActionIndex(state, value) {
      state.actionIndex = value;
    },
    changeImgList(state, value) {
      state.imgList = value;
    }
  },
  getters: {
    systemSetting(state) {
      return state.systemSetting;
    },
    getActionList(state) {
      return state.actionList;
    },
    getActionIndex: (state) => state.actionIndex,
    imgList: (state) => state.imgList
  },
  actions: {},
  modules: {}
});
