const useEqStore = defineStore('dcs', {
  state: () => ({
    eqIndexArr: {}, // websocket设备id对应索引
    flowPageIndex: '0',
    M1Step1: 1,
    M1Step2: 1,
    M2Step1: 1,
    M2Step2: 1,
  }),
  getters: {
    getEqIndexArr: (state) => state.eqIndexArr,
    getFlowPageIndex: (state) => state.flowPageIndex,
    getM1Step1: (state) => state.M1Step1,
    getM1Step2: (state) => state.M1Step2,
    getM2Step1: (state) => state.M2Step1,
    getM2Step2: (state) => state.M2Step2,
  },
  actions: {
    setEqIndexArr(eqIndexArr) {
      this.eqIndexArr = eqIndexArr;
    },
    setFlowPageIndex(flowPageIndex) {
      this.flowPageIndex = flowPageIndex;
    },
    setM1Step1(M1Step1) {
      this.M1Step1 = M1Step1;
    },
    setM1Step2(M1Step2) {
      this.M1Step2 = M1Step2;
    },
    setM2Step1(M2Step1) {
      this.M2Step1 = M2Step1;
    },
    setM2Step2(M2Step2) {
      this.M2Step2 = M2Step2;
    },
  },
  persist: {
    enabled: true,
    strategies: [
      {
        key: 'eq-store',
        storage: localStorage,
        paths: ['flowPageIndex', 'M1Step1', 'M1Step2', 'M2Step1', 'M2Step2'],
      },
    ],
  },
});

export default useEqStore;
