<template>
  <div class="diy-header">
    <div class="header-logo">
      <div class="logo-item" @click="toggleSideBar()"></div>
      <div class="logo-name">产品档案管理系统</div>
    </div>
    <div class="header-user">
      <div class="btn-back" @click="goBack()">
        <span class="back-btn-icon"></span>
        返回门户
      </div>
      <div class="separate-line"></div>
      <div class="user-data">
        <div class="user-icon"></div>
        <div class="avatar-wrapper">
          <span class="user-name">{{ realName }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      userName: "",
    };
  },
  computed: {
    ...mapGetters(["realName"]),
  },
  methods: {
    goBack() {
      if (process.env.NODE_ENV === "production") {
        // window.open(location.origin + "/sdsp/home", "_self");
        window.open(location.origin + "/ims/workbench/", "_self");
      }
    },
    toggleSideBar() {
      this.$store.dispatch("app/toggleSideBar");
    },
  },
};
</script>

<style lang="scss" scoped>
.diy-header {
  width: 100%;
  height: 50px;
  z-index: 1000;
  background-color: #1e80eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
  .header-logo {
    display: flex;
    align-items: center;
    .logo-item {
      cursor: pointer;
      width: 44px;
      height: 40px;
      background: url("../../assets/images/header-logo.png");
      background-size: cover;
      margin-right: 10px;
    }
    .logo-name {
      font-size: 22px;
      font-family: Source Han Sans SC-Bold, Source Han Sans SC;
      font-weight: bold;
      color: #ffffff;
      letter-spacing: 2px;
      text-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
    }
  }
  .header-user {
    display: flex;
    align-items: center;
  }
  .btn-back {
    cursor: pointer;
    font-size: 13px;
    font-family: Source Han Sans SC-Medium, Source Han Sans SC;
    font-weight: 500;
    color: #ffffff;
    letter-spacing: 1px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 24px 24px 24px 24px;
    display: flex;
    align-items: center;
    .back-btn-icon {
      display: inline-block;
      width: 18px;
      height: 14px;
      background: url("../../assets/images/back.png");
      background-size: 100% 100%;
      margin-right: 6px;
    }
  }
  .separate-line {
    margin: 0 20px;
    height: 17px;
    width: 1px;
    opacity: 0.6;
    background: #fff;
  }
  .avatar-wrapper {
    cursor: pointer;
    display: flex;
    align-items: center;
    color: #fff;
    .user-avatar {
      width: 34px;
      height: 34px;
      border-radius: 50%;
    }
    .user-name {
      margin: 0 6px;
      font-size: 16px;
      font-weight: 400;
      color: #ffffff;
    }
  }
}
</style>
