Header.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <div class="c-device-dashboard-header">
  3. <img
  4. class="c-device-dashboard-header__logo"
  5. src="/logo.png"
  6. >
  7. <div class="u-bold">{{ title }}</div>
  8. <div class="l-flex c-device-dashboard-header__wrapper">
  9. <div class="c-device-dashboard-header__time">{{ now }}</div>
  10. <div
  11. class="c-device-dashboard-header__exit u-pointer"
  12. @click="onExit"
  13. >
  14. 退出
  15. </div>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. import { parseTime } from '@/utils'
  21. export default {
  22. data () {
  23. return {
  24. title: process.env.VUE_APP_NAME,
  25. now: ''
  26. }
  27. },
  28. created () {
  29. this.getCurrentTime()
  30. this.$timer = setInterval(this.getCurrentTime, 500)
  31. },
  32. beforeDestroy () {
  33. clearInterval(this.$timer)
  34. },
  35. methods: {
  36. getCurrentTime () {
  37. this.now = parseTime(new Date(), '{y}/{m}/{d} {h}:{i}')
  38. },
  39. onExit () {
  40. this.$router.replace({
  41. name: 'device-detail'
  42. })
  43. }
  44. }
  45. }
  46. </script>
  47. <style lang="scss" scoped>
  48. .c-device-dashboard-header {
  49. position: relative;
  50. height: 54px;
  51. padding-top: 4px;
  52. color: #fff;
  53. font-size: 24px;
  54. text-align: center;
  55. background: url("~@/assets/line.png") 0 16px / 100% 38px no-repeat;
  56. &__logo {
  57. position: absolute;
  58. top: 8px;
  59. left: 16px;
  60. height: 24px;
  61. }
  62. &__wrapper {
  63. position: absolute;
  64. top: 8px;
  65. right: 16px;
  66. font-size: 16px;
  67. line-height: 24px;
  68. }
  69. &__time {
  70. margin-right: 32px;
  71. white-space: pre;
  72. }
  73. &__exit {
  74. color: #2956f0;
  75. }
  76. }
  77. </style>