<template>
  <div class="home admin-home">
    <div class="home-header">
      <view-header :show-reset-pwd="false">
        <h1 slot="logo" @click="$router.push({ name: 'WorkManage' })">
          美术阅卷管理端
        </h1>
        <div class="home-navs" slot="info">
          <ul>
            <li
              :class="{ act: curNav.name === nav.name }"
              v-for="(nav, index) in navs"
              :key="index"
              @click="switchNav(nav)"
            >
              <span class="nav-item-cont">{{ nav.title }}</span>
            </li>
          </ul>
        </div>
      </view-header>
    </div>

    <div class="home-body">
      <div class="home-main">
        <router-view />
      </div>
    </div>
  </div>
</template>

<script>
import { navs } from "@/routers/main";
import menuMixins from "@/components/homeMenuMixins";

export default {
  name: "admin-home",
  mixins: [menuMixins],
  data() {
    return {
      navs,
      curNav: {}
    };
  },
  watch: {
    $route: {
      handler(val) {
        this.actMainNav();
      }
    }
  },
  mounted() {
    this.actMainNav();
  },
  methods: {
    actMainNav() {
      const router = this.$route.matched.filter(
        item => item.name !== "Main"
      )[0];
      this.actCurNav(router);
    }
  }
};
</script>
