AppHeader.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div class="app-header">
  3. <div class="app-header-time">{{time}}</div>
  4. <div class="app-header-tit">
  5. <!-- AI-Hub智能处理平台 -->
  6. </div>
  7. <!-- <div>
  8. <img src="@/assets/images/header.png"/>
  9. <div>admin</div>
  10. </div> -->
  11. <div class="avatar-container right-menu-item hover-effect">
  12. <div class="avatar-wrapper">
  13. <img :src="avatar" class="user-avatar">
  14. <div class="name">{{name}}</div>
  15. <div class="line"></div>
  16. <div class="out" @click="logout">退出</div>
  17. </div>
  18. </div>
  19. <!-- <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
  20. <div class="avatar-wrapper">
  21. <img :src="avatar" class="user-avatar">
  22. <div class="name">123</div>
  23. <div @click.native="logout">退出</div>
  24. <i class="el-icon-caret-bottom" />
  25. </div>
  26. <el-dropdown-menu slot="dropdown">
  27. <router-link to="/user/profile">
  28. <el-dropdown-item>个人中心</el-dropdown-item>
  29. </router-link>
  30. <el-dropdown-item divided @click.native="logout">
  31. <span>退出登录</span>
  32. </el-dropdown-item>
  33. </el-dropdown-menu>
  34. </el-dropdown> -->
  35. </div>
  36. </template>
  37. <script>
  38. import { mapGetters } from 'vuex'
  39. // import 'qweather-icons/font/qweather-icons.css'
  40. // import { getWeatherInfo } from '@/utils/weather'
  41. export default {
  42. data() {
  43. return {
  44. time: '',
  45. timer: null,
  46. mhHost: '',
  47. }
  48. },
  49. computed:{
  50. ...mapGetters([
  51. 'avatar','name'
  52. ]),
  53. },
  54. async mounted() {
  55. this.refreshTime()
  56. this.timer = setInterval(this.refreshTime, 1000);
  57. // this.weather = await getWeatherInfo(this.city);
  58. },
  59. methods: {
  60. refreshTime() {
  61. this.time = new Date().toLocaleString('zh-CN', {
  62. year: 'numeric',
  63. hour12: false,
  64. month: '2-digit',
  65. day: '2-digit',
  66. // hour: 'numeric',
  67. // minute: 'numeric',
  68. // second: 'numeric',
  69. weekday: 'long',
  70. }).replace(/(星期|周)/, ' $1');
  71. // const date = new Date();
  72. // const options = {
  73. // weekday: 'long',
  74. // year: 'numeric',
  75. // month: 'long',
  76. // day: 'numeric',
  77. // };
  78. // const parts = new Intl.DateTimeFormat('zh-CN', options).formatToParts(date);
  79. // let result = '';
  80. // for (const part of parts) {
  81. // if (part.type === 'weekday') {
  82. // result += ' ' + part.value; // 在星期前加空格
  83. // } else {
  84. // result += part.value;
  85. // }
  86. // }
  87. // this.time=result
  88. },
  89. //退出
  90. logout() {
  91. this.$confirm('确定注销并退出系统吗?', '提示', {
  92. confirmButtonText: '确定',
  93. cancelButtonText: '取消',
  94. type: 'warning'
  95. }).then(() => {
  96. this.$store.dispatch('LogOut').then(() => {
  97. location.href = '/login'
  98. })
  99. }).catch(() => {})
  100. }
  101. },
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .app-header {
  106. display: flex;
  107. align-items: flex-start;
  108. font-size: 14px;
  109. font-weight: 400;
  110. color: #ffffff;position: relative;
  111. padding:28px 45px 0 45px;
  112. .app-header-time{padding-left: 2px;}
  113. .app-header-tit{ background: url('~@/assets/images/headertit.png') no-repeat;
  114. background-size: contain;width:601px;height: 36px;flex:1;
  115. background-position: center center;}
  116. }
  117. .avatar-container {
  118. margin-right: 30px;
  119. .avatar-wrapper {
  120. position: relative;
  121. display: flex;align-items: center;
  122. .user-avatar {
  123. cursor: pointer;
  124. width: 40px;
  125. height: 40px;
  126. border-radius: 40px;
  127. }
  128. .name{font-weight: bold;
  129. font-size: 14px;
  130. color: #FFFFFF;margin-left:10px;}
  131. .el-icon-caret-bottom {margin-left:8px;
  132. // cursor: pointer;
  133. // position: absolute;
  134. // right: -20px;
  135. // top: 25px;
  136. font-size: 14px;
  137. }
  138. .line{width: 1px;height: 12px;background: #33536F;margin-left: 12px;}
  139. .out{margin-left: 12px;}
  140. }
  141. }
  142. </style>