import { defineStore } from 'pinia'

export const useYHZStore = defineStore('config', {
  state: () => ({
    yhzInfo: null
  }),
  getters: {
    getYHZInfo: (state) => {
      if(state.yhzInfo) {
        return state.yhzInfo
      }
      try {
        const yhzInfo = JSON.parse(localStorage.getItem('yhzInfo'))
        if(yhzInfo) {
          return yhzInfo
        }
      } catch (error) {
        console.log(error)

      }
    }
  },
  actions: {
    setYHZInfo(yhzInfo) {
      this.yhzInfo = yhzInfo
      localStorage.setItem('yhzInfo', JSON.stringify(yhzInfo))
    }
  }
})
