<template>
  <div class="Layout">
    <nav class="Layout__nav" v-if="!$store.state.isMinion">
      <NavMenu :menus="menus" />
    </nav>
    <main class="Layout__main">
      <article class="Layout__content">
        <router-view />
      </article>
    </main>
  </div>
</template>

<script>
import { mapState } from 'vuex'
import NavMenu from '@/components/common/menu'

export default {
  components: {
    NavMenu,
  },
  computed: {
    ...mapState('user', {
      userInfo: 'info',
      menus: 'menus',
    }),
  },
  methods: {
    goBack ({ keyCode }) {
      if (keyCode === 27) this.$stack.go()
    },
  },
  mounted () {
    window.addEventListener('keydown', this.goBack, false)
  },
  beforeDestroy () {
    window.removeEventListener('keydown', this.goBack, false)
  },
}
</script>

<style lang="scss" scoped>
.Layout {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #fff;
}

.Layout__nav {
  flex: 0 0 auto;
  overflow: hidden;
}

.Layout__main {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.Layout__content {
  flex: 1;
  overflow: hidden;
}
</style>
