<template>
  <div class="header">
    <div class="logo">视频监控可视化平台</div>
    <v-sidebar></v-sidebar>
    <div class="header-right">
      <div class="header-user-con">
        <!-- 用户头像 -->
        <div class="user-avator">
          <img src="../../assets/img/user.jpeg" />
        </div>
        <!-- 用户名下拉菜单 -->
        <el-dropdown class="user-name" trigger="click" @command="handleCommand">
          <span class="el-dropdown-link">
            {{ username }}
            <i class="el-icon-caret-bottom"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <!-- <el-dropdown-item command="noticeShow">公告</el-dropdown-item>
            <el-dropdown-item command="changePwd"> 修改密码</el-dropdown-item> -->
            <el-dropdown-item command="loginout">退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </div>
    <password-dialog
      :dialogFormPsd="dialogFormPsd"
      @psdDialogClose="psdDialogClose"
    ></password-dialog>
  </div>
</template>
<script>
import { mapState } from "vuex";
import updateElementUiTheme from "update-element-ui-theme";
import vSidebar from "./Sidebar.vue";
import passwordDialog from "@/views/components/passwordDialog.vue";
export default {
  components: {
    vSidebar,
    passwordDialog,
  },
  data() {
    return {
      dialogFormPsd: false,
    };
  },
  computed: {
    ...mapState(["username"]),
    username() {
      let name = localStorage.getItem("username");
      return name;
    },
  },
  methods: {
    // 用户名下拉菜单选择事件
    handleCommand(command) {
      switch (command) {
        case "noticeShow": //公告
          console.log(command);
          break;
        case "changePwd": //修改密码
          console.log(command);
          this.dialogFormPsd = true;
          break;
        case "loginout": //退出登录
          this.$store.commit("REMOVE_INFO");
          this.$router.push("/login");
          break;
      }
      // if (command == "loginout") {
      //   localStorage.removeItem("ms_username");
      //   this.$router.push("/login");
      // }
    },

    //psdDialogClose 修改密码弹窗关闭
    psdDialogClose() {
      this.dialogFormPsd = false;
    },
  },
  created() {},
  mounted() {},
};
</script>
<style lang="less">
.header {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  height: 70px;
  font-size: 22px;
  color: @color-white;
  background-color: @color-primary;
  .collapse-btn {
    float: left;
    padding: 0 21px;
    cursor: pointer;
    line-height: 70px;
  }
  .logo {
    float: left;
    width: 250px;
    line-height: 70px;
    text-align: center;
    display: flex;
    align-items: center;
    padding-left: 16px;
    font-size: 20px;
    img {
      margin-right: 8px;
    }
  }
  .header-right {
    float: right;
    padding-right: 32px;
  }
  .header-user-con {
    display: flex;
    height: 70px;
    align-items: center;
    .el-select {
      width: 90px;
    }
  }
  .btn-fullscreen {
    transform: rotate(45deg);
    margin-right: 5px;
    font-size: 24px;
  }
  .btn-bell,
  .btn-fullscreen {
    position: relative;
    width: 30px;
    height: 30px;
    text-align: center;
    border-radius: 15px;
    cursor: pointer;
  }
  .btn-bell-badge {
    position: absolute;
    right: 0;
    top: -2px;
    width: 8px;
    height: 8px;
    border-radius: 4px;
    background: #f56c6c;
    color: @color-white;
  }
  .btn-bell .el-icon-bell {
    color: @color-white;
  }
  .user-name {
    margin-left: 10px;
  }
  .user-avator {
    margin-left: 20px;
  }
  .user-avator img {
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }
  .el-dropdown-link {
    color: @color-white;
    cursor: pointer;
  }
  .el-dropdown-menu__item {
    text-align: center;
  }
}
</style>
