index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <div class="top-bar-container">
  3. <div class="vab-main">
  4. <el-row>
  5. <el-col :xl="7" :lg="7" :md="7" :sm="7" :xs="7">
  6. <vab-logo />
  7. </el-col>
  8. <el-col :xl="12" :lg="12" :md="12" :sm="12" :xs="12">
  9. <el-menu
  10. :background-color="variables['menu-background']"
  11. :text-color="variables['menu-color']"
  12. :active-text-color="variables['menu-color-active']"
  13. :default-active="activeMenu"
  14. mode="horizontal"
  15. menu-trigger="hover"
  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 :xl="5" :lg="5" :md="5" :sm="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. title="重载路由"
  34. :pulse="pulse"
  35. :icon="['fas', 'redo']"
  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. setTimeout(() => {
  78. this.pulse = false
  79. }, 1000)
  80. },
  81. },
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. .top-bar-container {
  86. display: flex;
  87. align-items: center;
  88. justify-items: flex-end;
  89. height: $base-top-bar-height;
  90. background: $base-menu-background;
  91. .vab-main {
  92. background: $base-menu-background;
  93. ::v-deep {
  94. .el-menu {
  95. &.el-menu--horizontal {
  96. display: flex;
  97. align-items: center;
  98. justify-content: flex-end;
  99. height: $base-top-bar-height;
  100. border-bottom: 0 solid transparent !important;
  101. .el-menu-item,
  102. .el-submenu__title {
  103. padding: 0 15px;
  104. }
  105. @media only screen and (max-width: 767px) {
  106. .el-menu-item,
  107. .el-submenu__title {
  108. padding: 0 8px;
  109. }
  110. li:nth-child(4),
  111. li:nth-child(5) {
  112. display: none !important;
  113. }
  114. }
  115. > .el-menu-item {
  116. height: $base-top-bar-height;
  117. line-height: $base-top-bar-height;
  118. }
  119. > .el-submenu {
  120. .el-submenu__title {
  121. height: $base-top-bar-height;
  122. line-height: $base-top-bar-height;
  123. }
  124. }
  125. }
  126. svg {
  127. width: 1rem;
  128. margin-right: 3px;
  129. }
  130. &--horizontal {
  131. .el-menu {
  132. .el-menu-item,
  133. .el-submenu__title {
  134. height: $base-menu-item-height;
  135. line-height: $base-menu-item-height;
  136. }
  137. }
  138. .el-submenu,
  139. .el-menu-item {
  140. &.is-active {
  141. background-color: $base-color-blue !important;
  142. border-bottom: 0 solid transparent !important;
  143. .el-submenu__title {
  144. border-bottom: 0 solid transparent !important;
  145. }
  146. }
  147. }
  148. > .el-menu-item {
  149. .el-tag {
  150. margin-top: calc(#{$base-top-bar-height} / 2 - 7.5px);
  151. margin-left: 5px;
  152. }
  153. @media only screen and (max-width: 1199px) {
  154. .el-tag {
  155. display: none;
  156. }
  157. }
  158. &.is-active {
  159. background-color: transparent !important;
  160. border-bottom: 3px solid $base-color-blue !important;
  161. }
  162. }
  163. }
  164. }
  165. }
  166. }
  167. .right-panel {
  168. display: flex;
  169. align-items: center;
  170. justify-content: flex-end;
  171. height: $base-top-bar-height;
  172. ::v-deep {
  173. .user-name {
  174. color: rgba($base-color-white, 0.9);
  175. }
  176. .user-name + i {
  177. color: rgba($base-color-white, 0.9);
  178. }
  179. svg {
  180. width: 1em;
  181. height: 1em;
  182. margin-right: 15px;
  183. font-size: $base-font-size-big;
  184. color: rgba($base-color-white, 0.9);
  185. cursor: pointer;
  186. fill: rgba($base-color-white, 0.9);
  187. }
  188. button {
  189. svg {
  190. margin-right: 0;
  191. color: rgba($base-color-white, 0.9);
  192. cursor: pointer;
  193. fill: rgba($base-color-white, 0.9);
  194. }
  195. }
  196. .el-badge {
  197. margin-right: 15px;
  198. }
  199. }
  200. }
  201. }
  202. </style>