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: [],
    desktopDevice: 1, //1是兄弟，2是其他
    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;
    },
    changeDesktopDevice(state, value) {
      state.desktopDevice = value;
    },
  },
  getters: {
    systemSetting(state) {
      return state.systemSetting;
    },
    getActionList(state) {
      return state.actionList;
    },
    getActionIndex: (state) => state.actionIndex,
    imgList: (state) => state.imgList,
  },
  actions: {},
  modules: {},
});
