<template>
  <div class="home-header">
    <page-tags />
  </div>
</template>
<script>
import pageTags from './pageTags.vue'
import { logout } from '@/common/api/login'
import { setToken, setUser } from '@/utils/auth'
import { mapState } from 'vuex'

export default {
  components: { pageTags },
  name: 'HomeHeader',
  computed: {
    ...mapState(['userInfo']),
  },
  methods: {
    async logout() {
      try {
        await logout()
      } catch (e) {
        console.error(e)
      }

      setUser(null)
      setToken('')
      localStorage.setItem('tags', null)
      this.$store.commit('tags/removeAllTags')
      this.$router.push('/login')
    },
  },
}
</script>
<style lang="scss" scoped>
.home-header {
  display: flex;
  overflow: hidden;
}

.page-tags {
  flex: 1;
  overflow: auto hidden;
}

</style>
