<template>
  <div class="navbar">
    <div class="navbars">
      <hamburger id="hamburger-container" :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />

<breadcrumb id="breadcrumb-container" class="breadcrumb-container" v-if="!topNav"/>
<top-nav id="topmenu-container" class="topmenu-container" v-if="topNav"/>

<div class="right-menu">
  <template v-if="device!=='mobile'">
    <!-- <search id="header-search" class="right-menu-item" /> -->

    <!-- <el-tooltip content="源码地址" effect="dark" placement="bottom">
      <ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" />
    </el-tooltip>

    <el-tooltip content="文档地址" effect="dark" placement="bottom">
      <ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" />
    </el-tooltip> -->
    <div @click="toPush" class="right-menu-item work"> <i class="el-icon-s-platform"></i> 首页</div>
    <el-dropdown trigger="click">
      <span class="el-dropdown-link work right-menu-item1">
        APP下载
      </span>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item>  <img class="qrCode" :src="shuangUrl" alt="">
          <img class="qrCode" :src="nfcUrl" alt=""></el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
            <div @click.prevent="seeNew" class="right-menu-item work">
              <Information  :newType="newType" @close="close" />
            </div>
    <screenfull id="screenfull" class="right-menu-item hover-effect" />

    <!-- <el-tooltip content="布局大小" effect="dark" placement="bottom">
      <size-select id="size-select" class="right-menu-item hover-effect" />
    </el-tooltip> -->

  </template>

  <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
    <div class="avatar-wrapper">
      <!-- <img :src="avatar" class="user-avatar"> -->
      <img src="@/assets/images/profile.png" class="user-avatar">
      <!-- <i class="el-icon-caret-bottom" /> -->
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item  @click.native="logout">
        <span>退出登录</span>
      </el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import TopNav from '@/components/TopNav'
import Hamburger from '@/components/Hamburger'
import Screenfull from '@/components/Screenfull'
import Information from '@/layout/components/information'
import SizeSelect from '@/components/SizeSelect'
import Search from '@/components/HeaderSearch'
import RuoYiGit from '@/components/RuoYi/Git'
import RuoYiDoc from '@/components/RuoYi/Doc'

export default {
  data() {
    return {
      newType: false,
      shuangUrl: require("@/assets/images/shuang.png"),
      nfcUrl: require("@/assets/images/nfc.png"),
    }
  },
  components: {
    Breadcrumb,
    TopNav,
    Hamburger,
    Screenfull,
    SizeSelect,
    Search,
    RuoYiGit,
    RuoYiDoc,
    Information
  },
  computed: {
    ...mapGetters([
      'sidebar',
      'avatar',
      'device'
    ]),
    setting: {
      get() {
        return this.$store.state.settings.showSettings
      },
      set(val) {
        this.$store.dispatch('settings/changeSetting', {
          key: 'showSettings',
          value: val
        })
      }
    },
    topNav: {
      get() {
        return this.$store.state.settings.topNav
      }
    }
  },
  methods: {
    close (val) {
      this.newType = val
    },
    toPush() {
      this.$router.push({path: '/home'})
    },
    seeNew () {
      this.newType = true
    },
    toggleSideBar() {
      this.$store.dispatch('app/toggleSideBar')
    },
    async logout() {
      this.$confirm('确定注销并退出系统吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$store.dispatch('LogOut').then(() => {
          location.href = '/index';
        })
      }).catch(() => {});
    }
  }
}
</script>

<style lang="scss" scoped>
.navbars{
  height: 50px;
  overflow: hidden;
  position: relative;
  background: linear-gradient(to bottom, transparent, transparent, rgba(36, 222, 255, 0.16));
  box-shadow: 0 1px 4px rgba(0,21,41,.08);
  color: #fff;
}
.navbar {
  height: 50px;
  overflow: hidden;
  position: relative;
  background: linear-gradient(360deg, #51BEFF 0%, rgba(0, 159, 255, 0.45) 1%, rgba(0, 132, 211, 0.41) 4%, rgba(0, 126, 201, 0.4) 9%, rgba(0, 0, 0, 0) 100%);
  box-shadow: 0 1px 4px rgba(0,21,41,.08);
  color: #fff;
  .hamburger-container {

    line-height: 46px;
    height: 100%;
    float: left;
    cursor: pointer;
    transition: background .3s;
    -webkit-tap-highlight-color:transparent;

    &:hover {
      background: rgba(0, 0, 0, .025)
    }
  }

  .breadcrumb-container {
    float: left;
  }

  .topmenu-container {
    position: absolute;
    left: 50px;
  }

  .errLog-container {
    display: inline-block;
    vertical-align: top;
  }

  .right-menu {
    float: right;
    height: 100%;
    line-height: 50px;
    color: #fff !important;
    &:focus {
      outline: none;
    }

    .right-menu-item {
      display: inline-block;
      padding: 0 8px;
      height: 100%;
      font-size: 18px;
      color: #fff;
      vertical-align: text-bottom;

      &.hover-effect {
        cursor: pointer;
        transition: background .3s;

        &:hover {
          background: rgba(0, 0, 0, .025)
        }
      }
    }
    .right-menu-item1 {
      display: inline-block;
      padding: 0 8px;
      height: 100%;
      font-size: 18px;
      vertical-align: text-bottom;

      &.hover-effect {
        cursor: pointer;
        transition: background .3s;

        &:hover {
          background: rgba(0, 0, 0, .025)
        }
      }
    }

    .avatar-container {
      margin-right: 30px;

      .avatar-wrapper {
        margin-top: 5px;
        position: relative;

        .user-avatar {
          cursor: pointer;
          width: 35px;
          height: 35px;
          border-radius: 10px;
        }
        //.user-avatar:hover {
        //  transform: rotate(99999deg);
        //  transition: all 40s  cubic-bezier(.34, 0, .84, 1);
        //}

        .el-icon-caret-bottom {
          cursor: pointer;
          position: absolute;
          right: -20px;
          top: 25px;
          font-size: 12px;
        }
      }
    }
  }
}
.work{
  font-size: 16px !important;
  cursor: pointer;

}
.close{
  z-index: 99999;
  position: fixed;
  right: 40px;
  top: 85px;
}
.qrCode{
  width: 150px;
  margin: 10px 30px;
}
.works{
  font-size: 20px !important;
  padding-top: 10px !important;
}
</style>
