<template>
  <div :class="!flog ? 'tabbar' : 'tabbar-active'">
    <div class="container">
      <div class="logo">LOGO</div>
      <div class="menu">
        <ul>
          <li
            :class="{ active: settingStore.useIndex === index }"
            v-for="(item, index) in constRouter[0].children"
            :key="item.path"
            @click="goToRouter(item, index)"
          >
            {{ item.meta.title }}
          </li>
        </ul>
        <div class="entry">
          <div>企业入口</div>
          <div>教师入口</div>
          <div>学生入口</div>
          <div>毕业生入口</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { constRouter } from '@/router/module/constRouter'
import { useRouter } from 'vue-router'
import { onMounted,ref } from 'vue'
import useSettingStore from '@/store/module/setting'
const $router = useRouter()
const settingStore = useSettingStore()
const goToRouter = (item: any, index: number) => {
  settingStore.setuseIndex(index)
  $router.push({ path: `${item.path}`})
}
const flog = ref(false)
onMounted(() => {
  window.addEventListener('scroll', ()=> {

    if(window.scrollY >= 50 ){
      flog.value = true
    }else  if(flog.value && window.scrollY <= 50){
      flog.value = false
    }
   
    
  });
})
</script>

<style lang="scss" scoped>
.tabbar {
  position: fixed;
  top: 0;
  height: 120px;
  width: 100%;
  background-color: transparent;
  animation-duration: .3s;
  animation-name: tabber-to;

}
.tabbar-active {
  position: fixed;
  top: 0;
  height: 120px;
  width: 100%;
  background-color:#6da0ff;
  animation-duration: .3s;
  animation-name: tabber;
  z-index:999;
  box-shadow:
  0px 0px 43px rgba(0, 0, 0, 0.2)
;
}
@keyframes tabber {
  0%{
    // transform: translateY(-120px);
  background-color: transparent;

  }
  100%{
    // transform: translateY(0);
  background-color:#6da0ff;

  }
  
}
@keyframes tabber-to {
  0%{
    // transform: translateY(-120px);
  background-color:#6da0ff;

  }
  100%{
    // transform: translateY(0);
    background-color: transparent;


  }
  
}
.container {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 auto;
    width: $base-container-width;
    .menu {
      position: relative;
      padding: 0 20px;
      height: 100%;
      display: flex;
      align-items: center;
      ul {
        display: flex;
        align-items: center;
        li {
          padding: 20px;
          color: #ffffff;
          font-size: 14px;
          cursor: pointer;
          transition: all 0.2s;
          position: relative;
        }
        li:hover {
          color: #7aa4ff;
          transform: translateY(-5px);
        }
        .active::before {
          content: ' ';
          display: block;
          position: absolute;
          top: 0px;
          left: 50%;
          transform: translateX(-50%);
          width: 5px;
          height: 5px;
          border-radius: 50%;
          background-color: #fff;
        }
      }
      .entry{
        position: absolute;
        top: 5px;
        right: 30px;
        display: flex;
        align-content: center;
        div{
          // padding: 5px;
          margin: 5px;
          margin-right: 0;
          padding: 0 10px;
          border-right: 1px solid #fff;
          color: #fff;
          font-size: 14px;
          cursor: pointer;
        }
        div:last-child{
          border-right: none;
        }
      }
    }
    .logo{
      height: 100%;
      display: flex;
      align-items: center;
    }
  }
</style>
