index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <div class="top-bar-container">
  3. <div class="vab-main">
  4. <el-row>
  5. <el-col :lg="7" :md="7" :sm="7" :xl="7" :xs="7">
  6. <vab-logo />
  7. </el-col>
  8. <el-col :lg="12" :md="12" :sm="12" :xl="12" :xs="12">
  9. <el-menu
  10. :active-text-color="variables['menu-color-active']"
  11. :background-color="variables['menu-background']"
  12. :default-active="activeMenu"
  13. :text-color="variables['menu-color']"
  14. menu-trigger="hover"
  15. mode="horizontal"
  16. >
  17. <template v-for="route in routes">
  18. <vab-side-bar-item
  19. v-if="!route.hidden"
  20. :key="route.path"
  21. :full-path="route.path"
  22. :item="route"
  23. />
  24. </template>
  25. </el-menu>
  26. </el-col>
  27. <el-col :lg="5" :md="5" :sm="5" :xl="5" :xs="5">
  28. <div class="right-panel">
  29. <vab-error-log />
  30. <vab-full-screen-bar @refresh="refreshRoute" />
  31. <vab-theme-bar class="hidden-md-and-down" />
  32. <vab-icon
  33. :icon="['fas', 'redo']"
  34. :pulse="pulse"
  35. title="重载路由"
  36. @click="refreshRoute"
  37. />
  38. <vab-avatar />
  39. </div>
  40. </el-col>
  41. </el-row>
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. import variables from '@/styles/variables.scss'
  47. import { mapGetters } from 'vuex'
  48. export default {
  49. name: 'VabTopBar',
  50. data() {
  51. return {
  52. pulse: false,
  53. menuTrigger: 'hover',
  54. }
  55. },
  56. computed: {
  57. ...mapGetters({
  58. routes: 'routes/routes',
  59. visitedRoutes: 'tabsBar/visitedRoutes',
  60. }),
  61. activeMenu() {
  62. const route = this.$route
  63. const { meta, path } = route
  64. if (meta.activeMenu) {
  65. return meta.activeMenu
  66. }
  67. return path
  68. },
  69. variables() {
  70. return variables
  71. },
  72. },
  73. methods: {
  74. async refreshRoute() {
  75. this.$baseEventBus.$emit('reload-router-view')
  76. this.pulse = true
  77. this.timeOutID = setTimeout(() => {
  78. this.pulse = false
  79. }, 1000)
  80. },
  81. },
  82. beforeDestroy() {
  83. clearTimeout(this.timeOutID);
  84. }
  85. };
  86. </script>
  87. <style lang="scss" scoped>
  88. .top-bar-container {
  89. display: flex;
  90. align-items: center;
  91. justify-items: flex-end;
  92. height: $base-top-bar-height;
  93. background: $base-menu-background;
  94. .vab-main {
  95. background: $base-menu-background;
  96. ::v-deep {
  97. .el-menu {
  98. &.el-menu--horizontal {
  99. display: flex;
  100. align-items: center;
  101. justify-content: flex-end;
  102. height: $base-top-bar-height;
  103. border-bottom: 0 solid transparent !important;
  104. .el-menu-item,
  105. .el-submenu__title {
  106. padding: 0 15px;
  107. }
  108. @media only screen and (max-width: 767px) {
  109. .el-menu-item,
  110. .el-submenu__title {
  111. padding: 0 8px;
  112. }
  113. li:nth-child(4),
  114. li:nth-child(5) {
  115. display: none !important;
  116. }
  117. }
  118. > .el-menu-item {
  119. height: $base-top-bar-height;
  120. line-height: $base-top-bar-height;
  121. }
  122. > .el-submenu {
  123. .el-submenu__title {
  124. height: $base-top-bar-height;
  125. line-height: $base-top-bar-height;
  126. }
  127. }
  128. }
  129. svg {
  130. width: 1rem;
  131. margin-right: 3px;
  132. }
  133. &--horizontal {
  134. .el-menu {
  135. .el-menu-item,
  136. .el-submenu__title {
  137. height: $base-menu-item-height;
  138. line-height: $base-menu-item-height;
  139. }
  140. }
  141. .el-submenu,
  142. .el-menu-item {
  143. &.is-active {
  144. background-color: $base-color-blue !important;
  145. border-bottom: 0 solid transparent !important;
  146. .el-submenu__title {
  147. border-bottom: 0 solid transparent !important;
  148. }
  149. }
  150. }
  151. > .el-menu-item {
  152. .el-tag {
  153. margin-top: calc(#{$base-top-bar-height} / 2 - 7.5px);
  154. margin-left: 5px;
  155. }
  156. @media only screen and (max-width: 1199px) {
  157. .el-tag {
  158. display: none;
  159. }
  160. }
  161. &.is-active {
  162. background-color: transparent !important;
  163. border-bottom: 3px solid $base-color-blue !important;
  164. }
  165. }
  166. }
  167. }
  168. }
  169. }
  170. .right-panel {
  171. display: flex;
  172. align-items: center;
  173. justify-content: flex-end;
  174. height: $base-top-bar-height;
  175. ::v-deep {
  176. .user-name {
  177. color: rgba($base-color-white, 0.9);
  178. }
  179. .user-name + i {
  180. color: rgba($base-color-white, 0.9);
  181. }
  182. svg {
  183. width: 1em;
  184. height: 1em;
  185. margin-right: 15px;
  186. font-size: $base-font-size-big;
  187. color: rgba($base-color-white, 0.9);
  188. cursor: pointer;
  189. fill: rgba($base-color-white, 0.9);
  190. }
  191. button {
  192. svg {
  193. margin-right: 0;
  194. color: rgba($base-color-white, 0.9);
  195. cursor: pointer;
  196. fill: rgba($base-color-white, 0.9);
  197. }
  198. }
  199. .el-badge {
  200. margin-right: 15px;
  201. }
  202. }
  203. }
  204. }
  205. </style>