<template>
  <div class="headerNav">
    <div style="position: relative">
      <ai-icon type="logo" :icon="'iconcunwei'"/>
      <ai-icon type="logo" :icon="'iconcunwei'" class="textShadow"/>
    </div>
    <span class="headerTitle">{{ title }}<div class="textShadow" v-html="title"/></span>
    <el-row type="flex" align="middle" class="toolbar">
      <slot v-if="$slots.right" name="right"/>
    </el-row>
    <el-dropdown @visible-change="v=>isClick=v" @command="doMenu" class="rightDropdown">
      <el-row type="flex" align="middle">
        <el-avatar :src="user.info.avatar">
          {{ user.info.name.slice(-2) }}
        </el-avatar>
        <span>{{ [user.info.name, user.info.roleName].join(" - ") }}</span>
        <i :class="dropdownIcon"/>
      </el-row>
      <el-dropdown-menu>
        <el-dropdown-item command="user">用户中心</el-dropdown-item>
        <el-dropdown-item command="signOut">退出</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<script>
import {mapState} from "vuex";

export default {
  name: 'headerNav',
  props: {
    title: {default: ""}
  },
  data() {
    return {
      isClick: false,
      drawer: false,//抽屉
      count: 0,
      filesList: [],
      fileName: '',
      badgeNum: 0,
      dvOptions: []
    }
  },
  computed: {
    ...mapState(['user']),
    dropdownIcon() {
      return this.isClick ? 'el-icon-caret-top' : 'el-icon-caret-bottom'
    },
  },
  methods: {
    // 获取最新的安卓、ios下载二维码
    doMenu(comm) {
      switch (comm) {
        case 'signOut':
          //登出
          this.$confirm("是否要登出?", {type: "warning"}).then(() => {
            this.$store.commit("SignOut")
          }).catch(() => {
          })
          break;
        case 'user':
          this.$router.push({name: "个人中心"})
          break;
      }
    },
  }
}
</script>


<style lang="scss" scoped>
.headerNav {
  display: flex;
  align-items: center;
  width: 100%;
  background-image: url("../assets/nav_bg.png");
  background-repeat: no-repeat;
  background-size: 100% 48px;
  position: fixed;
  z-index: 99;
  height: 48px;
  padding-left: 24px;
  box-sizing: border-box;
  top: 0;
  color: white;
  font-size: 14px;

  .AiIcon {
    font-size: 38px;
    width: auto;
    height: auto;
    background: linear-gradient(180deg, #FFFFFF 0%, #CCDBF6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;

    &:hover {
      color: white;
    }
  }

  .headerTitle {
    flex: 1;
    min-width: 0;
    font-size: 24px;
    color: #FFF;
    line-height: 28px;
    background: linear-gradient(180deg, #FFFFFF 0%, #CCDBF6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: bold;
    margin-left: 8px;
    position: relative;
  }

  .textShadow {
    position: absolute;
    top: 0;
    text-shadow: 0 2px 0 #384DC3;
    color: transparent;
    z-index: -1;
  }

  ::v-deep.toolbar {
    gap: 12px;
    margin-right: 32px;

    & > div {
      padding: 0 12px;

      &:hover {
        cursor: pointer;
        color: rgba(#fff, .8);
      }
    }
  }

  .el-dropdown {
    height: 48px;
    line-height: 48px;
    color: #fff;
    padding: 0 12px;

    &:hover {
      background-color: rgba(46, 51, 68, .15);
      color: white;
    }
  }

  .el-image {
    margin: 12px 0 12px 16px;
  }


  .rightDropdown {
    font-size: 12px;
    padding: 0 16px;
    height: 48px;
    background: rgba(#fff, .1);

    .el-row {
      gap: 4px;
    }
  }
}

::v-deep .downLoad_main {
  width: 100%;
  height: 100%;
  padding: 16px;
  box-sizing: border-box;

  .search_top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
  }

  .infinite-list {
    width: 100%;
    height: 100%;

    .infinite-list-item {
      width: 100%;
      padding: 8px;
      box-sizing: border-box;
      background: rgba(255, 255, 255, 1);
      border-radius: 4px;
      border: 1px solid rgba(208, 212, 220, 1);
      margin-bottom: 8px;
      display: flex;
      justify-content: space-between;

      .left {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 30px;

        .svg {
          width: 24px;
          height: 24px;
          vertical-align: middle;
        }
      }

      .middle {
        flex: 1;

        .fileName {
          color: #333333;
          font-size: 14px;
        }

        p:nth-child(2) {
          color: #999999;
          font-size: 12px;

          span {
            padding: 0 4px;
          }

          span:nth-child(2) {
            border-right: solid 1px #999999;
          }

          span:nth-child(3) {
            border-right: solid 1px #999999;
          }
        }
      }

      .right {
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 12px;
        width: 90px;
        text-align: center;

        span {
          color: #999999;
        }

        i {
          display: block;
          width: 50px;
          color: #5088FF;
          font-size: 12px;
          cursor: pointer;
        }
      }

    }

  }

  ::-webkit-scrollbar {
    width: 4px;
    background-color: #eee;
  }

  ::-webkit-scrollbar-thumb {
    background-color: #8888;

  }
}

</style>
