<template>
  <div class="pc-menu" :style="`width:${$i18n.t('style_key.menu_width')}`" 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>

    <a class="help" :href="$lang=='en'?'https://docs.4dkankan.com/#/product/4dpano/en-us/README':'https://docs.4dkankan.com/#/product/4dpano/zh-cn/README'" target="_blank">
      <img v-tooltip="$i18n.t('edit_settings.help_center')"  :src="require(`@/assets/images/icons/help_tips.png`)" alt="">
    </a>

  </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: 10px 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;
    }
  }
  .help{
    position: absolute;
    bottom: 10px;
    left: 50%;
    width: 16px;
    transform: translateX(-50%);
    >img{
      width: 100%;
    }
  }
}
</style>
