import { mapGetters } from 'vuex'

export default {
  data() {
    return {}
  },
  computed: {
    // 使用对象展开运算符将 getter 混入 computed 对象中
    ...mapGetters(['theme'])
  },
  beforeCreate() {

  },
  created() {
    this.initTheme()
  },
  methods: {
    initTheme() {
      // const storageTheme = localStorage.getItem('dee-theme')

      // if (!storageTheme) {
      //   document.getElementsByTagName('body')[0].className = `dee-theme-${this.theme}`
      //   // localStorage.setItem('dee-theme', this.theme)
      //   this.$store.dispatch('theme/setTheme', this.theme)
      // } else {
      //   document.getElementsByTagName('body')[0].className = `dee-theme-${storageTheme}`
      //   this.$store.dispatch('theme/setTheme', storageTheme)
      // }
    },
    changeTheme(theme) {
      // // localStorage.setItem('dee-theme', theme)
      // document.getElementsByTagName('body')[0].className = `dee-theme-${theme}`
      this.$store.dispatch('theme/setTheme', theme)
    }
  }
}