const getStorage = function(key) {
  const str = zzSessionStorage.getItem(key)
  // const str = localStorage.getItem(key)
  if (!str) {
    var lang = 'zh'
    // localStorage.setItem(key, lang)
    zzSessionStorage.setItem('lang', lang)
    return lang
  }
  return str
}
const setLang = function(language) {
  // const json = JSON.stringify(obj)
  zzSessionStorage.setItem('lang', language)
  // localStorage.setItem('lang', language)
}
const state = {
  language: getStorage('lang')
}

const mutations = {

  setLanguage: (state, language) => {
    state.language = language
    setLang(language)
  }
}

export default {
  namespaced: true,
  state,
  mutations
}

