<template>
  <div class="pc-menu" app-border dir-right>
    <ul class="pc-menu-container">
      <li v-for="(item, key) in menu" v-show="!item.hidden" :class="{disable:key!=0&&!isShow}" :key="key">
        <router-link :to="item.link" :exact="false">
          <img class="normal" :src="require(`@/assets/images/icons/navs/${item.icon}_normal.svg`)" alt="">
          <img class="active" :src="require(`@/assets/images/icons/navs/${item.icon}_selected.svg`)" alt="">
          <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':{
      immediate:true,
      handler:function (newVal) {
        if (newVal!='base'&&!this.isShow) {
          this.$router.push({path:'/base',redirect:true})
        }
      }
    }
  },
  mounted() {
    // 添加滚动条
  },
  created() {
    this.menu = PCMenu;
  }
};
</script>
<style lang="less">
.pc-menu {
  width: 58px;
  ul {
    li {
      cursor: pointer;
      text-align: center;
      white-space: normal;

      a {
        width: 100%;
        height: 100%;
        padding: 5px;
        display: inline-block;
        >img{
          width: 18px;
        }
        .normal{
          display: inline-block;
        }
        .active{
          display: none;
        }
        &.router-link-exact-active,
        &.router-link-active {
          color: @color;
          background: #252526;

          .normal{
            display: none;
          }
          .active{
            display: inline-block;

          }
        }
      }
    }

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

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

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