<template>
  <div class="side-nav">
    <div v-for="(key, val) in data" class="group-container">
      <p class="side-nav-title">{{key.desc}}</p>
      <div class="side-nav-items" v-for="nav in key.items" v-if="nav.desc">
        <router-link :class="$route.name===nav.name ? 'active' : ''" v-if="nav.name" :to="{name: nav.name}">{{nav.desc}}
          <i>{{nav.descen}}</i></router-link>
        <p v-else class="side-nav-group">{{nav.desc}} <i>{{nav.descen}}</i></p>
        <div v-for="item in nav.items">
          <router-link :to="{name: item.name}" :class="$route.name===item.name ? 'active' : ''"
                       class="slid-nav-component">{{item.desc}} <i>{{nav.descen}}</i></router-link>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import navConf from '../nav.config.json'

  export default {
    data() {
      return {
        data: navConf
      }
    }
  }
</script>

<style lang="less" type="text/less">
  .side-nav {
    padding: 0;
    color: #3F536E;
    background-color: #fff;
    z-index: 99;
    .group-container {
      margin-bottom: 20px;
    }
    .side-nav-title {
      margin-bottom: 10px;
      height: 40px;
      line-height: 40px;
      padding: 0 24px 0;
      color: #999;
      font-size: 14px;
      background: #F2F4F8;
    }
    .side-nav-items {
      font-size: 14px;
      font-weight: normal;
      line-height: 1.8;
      a {
        position: relative;
        display: block;
        padding: 6px 0;
        text-indent: 3em;
        color: #333;
        font-weight: normal;
        line-height: 1.5;
        cursor: pointer;
      }
      i {
        font-style: normal;
        font-size: 12px;

      }
      .side-nav-group {
        display: block;
        position: relative;
        padding: 6px 0 6px 24px;
        color: #2C405A;
        font-weight: bold;
      }
      .slid-nav-component {
        display: block;
        position: relative;
        color: #616367;
        font-size: 14px;
      }
      :hover {
        color: #3FAAF5;
      }
      .active {
        color: #3FAAF5;
      }
    }
  }
</style>
