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: [],
    productDetail: {},
    desktopDevice: 1, //1是兄弟，2是其他
    WHproportion: 1, //宽高比例
    isPreView: false, //宽高比例
    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;
    },
    setProductDetail(state, value) {
      state.productDetail = value;
    },
    setWHproportion(state, value) {
      state.WHproportion = value;
    },
    setIsPreView(state, value) {
      state.isPreView = value;
    },
  },
  getters: {
    systemSetting(state) {
      return state.systemSetting;
    },
    getActionList(state) {
      return state.actionList;
    },
    getActionIndex: (state) => state.actionIndex,
    imgList: (state) => state.imgList,
  },
  actions: {},
  modules: {},
});
