<template>
  <div class="pc-menu" app-border dir-right>
    <ul class="pc-menu-container">
      <li v-for="(item, key) in menu" :key="key">
        <router-link :to="item.link" :exact="false">
          <i class="iconfont" :class="item.icon"></i>
          <span>{{ item.text }}</span>
        </router-link>
      </li>
    </ul>
  </div>
</template>
<script>
import { PCMenu } from "../config/menu";
import { mapGetters } from "vuex";

export default {
  name: "pc-menu",
  data() {
    return {
      menu: []
    };
  },
  computed: {
    ...mapGetters({
      isShow:'isShow'
    })
  },
  watch:{
    '$route.name':{
      handler:function (newVal) {
        if (newVal!='information'&&!this.isShow) {
          this.$router.push({path:'/information',redirect:true})
        }
      }
    }
  },
  mounted() {
    // 添加滚动条
  },
  created() {
    this.menu = PCMenu;
  }
};
</script>
<style lang="less">
.pc-menu {
  width: 80px;
  ul {
    li {
      cursor: pointer;
      text-align: center;
      margin-top: 10px;
      white-space: normal;

      a {
        width: 100%;
        height: 100%;
        padding: 8px;
        display: inline-block;
        &.router-link-exact-active,
        &.router-link-active {
          background-color: @color;
        }
      }
    }

    span {
      display: block;
      font-size: 12px;
    }

    a {
      color: #fff;
      text-decoration: none;
    }

    .iconfont {
      font-size: 28px;
    }
  }
}
</style>
