<template>
  <div class="header">
    <div class="left">
      <img class="first" src="../assets/three.png" alt="" />
      <div class="shu"></div>
      <img class="logo" src="../assets/white-logo.png" alt="" />
      <div
        class="ml20"
        style="color: #fff; font-size: 18px; height: 60px; padding-top: 50px"
      >
        version：{{ timelineData[0].version }}
      </div>
    </div>
    <div class="right">
      <img class="user-icon" src="../assets/user.png" alt="" />
      <div class="user">{{ userName }}</div>
      <el-popover placement="bottom" trigger="hover" :width="160">
        <el-timeline>
          <el-timeline-item
            v-for="item in timelineData"
            center
            :timestamp="item.timer"
            placement="top"
          >
            <div class="log-card">
              <p style="margin-bottom: 5px">Version: {{ item.version }}</p>
              <p>{{ item.remark }}</p>
            </div>
          </el-timeline-item>
        </el-timeline>
        <template #reference>
          <el-badge value="new">
            <div class="log">版本日志</div>
          </el-badge>
        </template>
      </el-popover>
      <div class="quit" @click="quit">[退出]</div>
    </div>
  </div>
</template>
<script>
import store from "../store";
import router from "../router";
import { ref } from "vue";

export default {
  setup() {
    let userName = localStorage.userName;
    function quit() {
      localStorage.clear();
      store.commit("changeLogin", false);
      router.push({ path: "/login" });
    }
    let timelineData = ref([
      { timer: "2022/02/7", version: "1.2.13.1", remark: "版本日志功能更新" },
      {
        timer: "2022/01/24",
        version: "1.2.13.0",
        remark: "磅单上传;下载卸货记录",
      },
    ]);
    return {
      quit,
      userName,
      timelineData,
    };
  },
};
</script>
<style scoped>
.header {
  width: 100%;
  height: 60px;
  background: #212029;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.left,
.right {
  display: flex;
  align-items: center;
}

.first {
  width: 22px;
  height: 20px;
  margin: 0 22px;
}

.shu {
  width: 1px;
  height: 60px;
  background: #101015;
  margin-right: 22px;
}

.logo {
  width: 120px;
  height: 40px;
}

.title {
  font-size: 21px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #ffffff;
  margin-left: 26px;
}

.user,
.quit,
.log {
  font-size: 14px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #ffffff;
  cursor: pointer;
  margin-right: 16px;
}

.log-card p {
  font-size: 10px;
}
.user-icon {
  width: 18px;
  height: 18px;
  margin-right: 16px;
}

.log {
  margin-right: 4px;
}

.quit {
  margin-left: 26px;
}
</style>
