const baseInfo = {
  set (info) {
    localStorage.setItem('baseInfo', JSON.stringify(info))
  },
  get (...arg) {
    let baseInfo = null
    try {
      baseInfo = JSON.parse(localStorage.getItem('baseInfo'))
    } catch(err) {
      return null
    }
    if (baseInfo === null) {
      return null
    }
    if (arg.length === 0 || arg[0] === '') {
      return baseInfo
    } else {
      return baseInfo[arg[0]]
    }
  },
  clear () {
    localStorage.removeItem('baseInfo')
  },

  menu () {
    return this.get('menu')
  },
  decLevels () {
    return this.get('decLevels')
  },
  empLevels () {
    return this.get('empLevels')
  },
  adminRoles () {
    return this.get('adminRoles')
  },
  setDaysDiff (daysDiff) {
    let baseInfo = {
      daysDiff: daysDiff
    }
    localStorage.setItem('baseInfo', JSON.stringify(baseInfo))
  },
  daysDiff () {
    return this.get('daysDiff')
  },
  shopWalletType () {
    return this.get('shopWalletType')
  },
  setSiteTitle (siteTitle) {
    let baseInfo = {
      siteTitle: siteTitle
    }
    localStorage.setItem('baseInfo', JSON.stringify(baseInfo))
  },
  siteTitle(){
    return this.get('siteTitle')
  },
  whetherBA() {
    return this.get('whetherBA');
  },
}

export default baseInfo
