<!-- Please remove this file from your project -->
<template>
  <nav class="nav">
    <div class="imgBox">
      <!-- 测试查询 -->
      <!-- <img
        class="land"
        src="../assets/mask/test_req.png"
        alt=""
        @click="showLandBox"
      /> -->
      <img class="logo" src="../assets/partOne/logo.png" alt="" />
    </div>
    <ul class="nav-list">
      <li
        v-for="(item, index) in navlist"
        :key="item.class"
        class="nav-item"
        :class="index == activeIndex ? 'active' : ''"
      >
        <div v-if="activeIndex == index" class="active-line"></div>
        <!-- <img
          :class="'nav-' + item.class"
          :src="item.src"
          alt=""
          @click="toViewSwiper(index)"
        /> -->
        <div
          class="nav_img"
          :class="'nav-' + item.class"
          @click="toViewSwiper(index)"
        ></div>
      </li>
    </ul>
  </nav>
</template>

<script>
export default {
  props: {
    activeIndex: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      navlist: [
        {
          class: "home",
          src: require("../assets/partOne/home.png"),
        },
        {
          class: "trailer",
          src: require("../assets/partOne/news.png"),
        },
        {
          class: "world",
          src: require("../assets/partOne/world.png"),
        },
        {
          class: "Characters",
          src: require("../assets/partOne/Characters.png"),
        },
      ],
    };
  },
  methods: {
    toViewSwiper(index) {
      this.$emit("toViewSwiper", index);
    },
    showLandBox() {
      this.$emit("showLandBox");
    },
  },
};
</script>

<style lang="scss" scoped>
.nav {
  width: 100vw;
  height: 86px;
  background: url("https://cdn.star-linear.com/resource/dream/top_bg.png") left
    no-repeat;
  background-size: cover;
  display: flex;
  justify-content: space-between;
  overflow: hidden;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 12;
  &::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 61px;
    transform: translateY(49%);
    background: url("../assets/partOne/top_line.png") left no-repeat;
    background-size: contain;
  }
  .imgBox {
    display: flex;
    justify-content: space-between;
    margin-left: 60px;
  }
  .land {
    cursor: pointer;
  }
  .logo {
    width: 223px;
    height: 84px;
    margin-left: 60px;
  }

  .nav-list {
    display: flex;
    justify-content: center;
    align-items: center;
    list-style: none;
    margin-top: 35px;
    margin-right: 130px;
    z-index: 2;
    .nav-item {
      margin-left: 88px;
      position: relative;
      &:first-child {
        &::after {
          width: 0;
        }
      }
      &.active {
        .active-line {
          position: absolute;
          bottom: -3px;
          left: 37px;
          width: 194px;
          height: 142px;
          background: url("../assets/partOne/light_bg.png") left no-repeat;
          background-size: contain;
          cursor: pointer;
          opacity: 0.55;
        }
        &::before {
          content: "";
          position: absolute;
          top: -15px;
          left: 0;
          width: 92px;
          height: 88px;
          background: url("../assets/partOne/light.png") left no-repeat;
          background-size: contain;
          animation: shake 0.8s ease infinite alternate;
          transform: translateX(-10%);
          z-index: 12;
        }
      }

      @keyframes shake {
        from {
          opacity: 1;
        }
        to {
          opacity: 0.5;
        }
      }
      &::after {
        content: "";
        position: absolute;
        top: 35%;
        left: 0;
        transform: translate(-83%, -50%);
        width: 134px;
        height: 50px;
        background: url("../assets/partOne/line.png") left no-repeat;
        background-size: cover;
      }
    }
    img {
      cursor: pointer;
      height: 79px;
      z-index: 13;
      position: relative;
    }

    .nav_img {
      background: url("../assets/partOne/nav_img.png");
      background-size: auto 100%;
      background-repeat: no-repeat;
      cursor: pointer;
      height: 84px;
    }
    .nav-home {
      // height: 216px;
      // height: 84px;
      width: 156px;
      background-position: 11px 0;
    }
    .nav-world {
      // height: 216px;
      width: 207px;
      background-position: -115px 0;
    }
    .nav-Characters {
      // height: 220px;
      // width: 532px;
      width: 200px;
      background-position: -305px 0;
    }
    .nav-trailer {
      // height: 218px;
      // width: 618px;
      width: 150px;
      // height: 55px;
      // background: url("../assets/partOne/news.png") center no-repeat;
      // background-size: contain;

      background-position: -507px 12px;
    }
    // .nav-home {
    //   background-size: contain;
    //   background-repeat: no-repeat;
    //   height: 79px;
    // }
  }
}
</style>