<template>
  <div class="c-device-dashboard-header">
    <div class="c-device-dashboard-header__logo has-bg" />
    <div class="c-device-dashboard-header__name u-bold">浪 潮 屏 媒 安 播 云 平 台</div>
    <div class="l-flex c-device-dashboard-header__wrapper">
      <div class="c-device-dashboard-header__time">{{ now }}</div>
      <div
        class="c-device-dashboard-header__exit u-pointer"
        @click="onExit"
      >
        退出
      </div>
    </div>
  </div>
</template>

<script>
import { parseTime } from '@/utils'

export default {
  data () {
    return {
      now: ''
    }
  },
  created () {
    this.getCurrentTime()
    this.$timer = setInterval(this.getCurrentTime, 500)
  },
  beforeDestroy () {
    clearInterval(this.$timer)
  },
  methods: {
    getCurrentTime () {
      this.now = parseTime(new Date(), '{y}/{m}/{d}   {h}:{i}')
    },
    onExit () {
      this.$router.replace({
        name: 'device-detail'
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.c-device-dashboard-header {
  position: relative;
  height: 54px;
  padding-top: 4px;
  color: #fff;
  font-size: 24px;
  text-align: center;
  background: url("~@/assets/line.png") 0 16px / 100% 38px no-repeat;

  &__logo {
    position: absolute;
    top: 8px;
    left: 16px;
    width: 90px;
    height: 22px;
    background-image: url("~@/assets/logo.png");
  }

  &__wrapper {
    position: absolute;
    top: 8px;
    right: 16px;
    font-size: 16px;
    line-height: 22px;
  }

  &__time {
    margin-right: 32px;
    line-height: 24px;
    white-space: pre;
  }

  &__exit {
    color: #2956f0;
  }
}
</style>
