index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <div class="vab-avatar" style="display: flex">
  3. <span class="weatherBlock">
  4. <!-- {{ time }} -->
  5. <!-- 天气预留位置 -->
  6. </span>
  7. <span class="goPanelBlock" v-if="$store.state.largeScreenUrl">
  8. <a @click="goPanel" target="_blank">
  9. <img src="/static/svgIcons/home.svg" alt="" width="12" />
  10. 大屏
  11. </a>
  12. </span>
  13. <span class="bell">
  14. <img
  15. src="../../assets/images/bell.png"
  16. alt=""
  17. width="15"
  18. @click="goAlarmingPage"
  19. />
  20. </span>
  21. <a-dropdown>
  22. <span class="ant-dropdown-link">
  23. <!-- <a-avatar :src="avatar" /> -->
  24. <!-- <img
  25. src="https://i.gtimg.cn/club/item/face/img/2/15922_100.gif"
  26. alt=""
  27. style="
  28. background: #ccc;
  29. width: 32px;
  30. height: 32px;
  31. line-height:32px;
  32. border-radius:50%;
  33. "
  34. /> -->
  35. <span style="margin-right: 10px; display: inline-block">
  36. 欢迎您,{{ username }}
  37. </span>
  38. <DownOutlined />
  39. </span>
  40. <template v-slot:overlay>
  41. <a-menu>
  42. <a-menu-item @click="goPerCenter">个人中心</a-menu-item>
  43. <a-menu-item @click="logout">退出登录</a-menu-item>
  44. </a-menu>
  45. </template>
  46. </a-dropdown>
  47. <!-- <span><img src="../../assets/images/switch.png" alt="" width="15" /></span> -->
  48. </div>
  49. </template>
  50. <script>
  51. import { recordRoute } from '@/config'
  52. import { DownOutlined } from '@ant-design/icons-vue'
  53. import { useStore } from 'vuex'
  54. import { mapActions, mapGetters } from 'vuex'
  55. // import { mapGetters, } from 'vuex'
  56. export default {
  57. name: 'VabAvatar',
  58. components: { DownOutlined },
  59. computed: {
  60. ...mapGetters({
  61. avatar: 'https://i.gtimg.cn/club/item/face/img/2/15922_100.gif',
  62. username: 'user/username',
  63. }),
  64. },
  65. data() {
  66. return {
  67. time: '',
  68. }
  69. },
  70. mounted() {
  71. const store = useStore()
  72. setInterval(() => {
  73. store.commit('getTimeAll')
  74. var time = store.state.Time_All
  75. this.time =
  76. time[0] +
  77. '年' +
  78. (time[1] < 9 ? '0' + (time[1] + 1) : time[1] + 1) +
  79. '月' +
  80. (time[2] < 10 ? '0' + time[2] : time[2]) +
  81. '日 ' +
  82. (time[3] < 10 ? '0' + time[3] : time[3]) +
  83. ':' +
  84. (time[4] < 10 ? '0' + time[4] : time[4]) +
  85. ':' +
  86. (time[5] < 10 ? '0' + time[5] : time[5])
  87. }, 0)
  88. },
  89. methods: {
  90. ...mapActions({
  91. delAllVisitedRoutes: 'tagsBar/delAllVisitedRoutes',
  92. // toggleCollapse: 'settings/toggleCollapse',
  93. }),
  94. goPerCenter() {
  95. this.$router.push('/perCenter/index')
  96. },
  97. goPanel() {
  98. if (window.location.host.indexOf('localhost') != -1) {
  99. window.open('http://localhost:8080/#/home')
  100. } else {
  101. var aa = this.$store.state.largeScreenUrl
  102. window.open(aa)
  103. }
  104. },
  105. goAlarmingPage() {
  106. this.$router.push('/alarmManage')
  107. },
  108. async closeAllTabs() {
  109. await this.delAllVisitedRoutes()
  110. if (this.affixTabs.some((tag) => tag.path === this.toThisTag().path))
  111. return
  112. this.toLastTag()
  113. },
  114. async logout() {
  115. await this.$store.dispatch('user/logout')
  116. if (recordRoute) {
  117. // const fullPath = this.$route.fullPath
  118. // this.$router.push(`/login?redirect=${fullPath}`)
  119. // this.$store.visitedRoutes=[]
  120. this.$store.state.homePageUrl=''
  121. this.closeAllTabs()
  122. this.$router.push('/login')
  123. } else {
  124. this.$router.push('/login')
  125. }
  126. },
  127. },
  128. }
  129. </script>
  130. <style lang="less">
  131. .vab-avatar {
  132. .weatherBlock,
  133. .goPanelBlock {
  134. height: @vab-header-height;
  135. line-height: @vab-header-height;
  136. margin-right: 30px;
  137. font-size: 14px;
  138. }
  139. .goPanelBlock a {
  140. text-align: center;
  141. width: 90px;
  142. line-height: 36px;
  143. // background: rgba(255, 255, 255, 0.2);
  144. border-radius: 4px;
  145. display: inline-block;
  146. font-size: 14px;
  147. color: #fff;
  148. img {
  149. position: relative;
  150. top: -1px;
  151. }
  152. }
  153. .goPanelBlock a:hover {
  154. opacity: 0.7;
  155. }
  156. .bell {
  157. margin: 0 18px 0 18px;
  158. cursor: pointer;
  159. img {
  160. position: relative;
  161. top: -1px;
  162. }
  163. }
  164. .bell:hover {
  165. opacity: 0.7;
  166. }
  167. .ant-dropdown-link {
  168. font-size: 14px;
  169. display: block;
  170. min-height: @vab-header-height;
  171. cursor: pointer;
  172. line-height: @vab-header-height;
  173. }
  174. }
  175. </style>