Navbar.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <div class="navbar">
  3. <hamburger id="hamburger-container" :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
  4. <breadcrumb id="breadcrumb-container" class="breadcrumb-container" v-if="!topNav"/>
  5. <top-nav id="topmenu-container" class="topmenu-container" v-if="topNav"/>
  6. <div class="right-menu">
  7. <template v-if="device!=='mobile'">
  8. <el-tooltip content="预警待办" effect="dark" placement="bottom">
  9. <ruo-yi-bell id="ruoyi-bell" class="right-menu-item hover-effect" />
  10. </el-tooltip>
  11. <search id="header-search" class="right-menu-item" />
  12. <el-tooltip content="源码地址" effect="dark" placement="bottom">
  13. <ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" />
  14. </el-tooltip>
  15. <el-tooltip content="文档地址" effect="dark" placement="bottom">
  16. <ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" />
  17. </el-tooltip>
  18. <screenfull id="screenfull" class="right-menu-item hover-effect" />
  19. <el-tooltip content="布局大小" effect="dark" placement="bottom">
  20. <size-select id="size-select" class="right-menu-item hover-effect" />
  21. </el-tooltip>
  22. </template>
  23. <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
  24. <div class="avatar-wrapper">
  25. <img :src="avatar" class="user-avatar">
  26. <i class="el-icon-caret-bottom" />
  27. </div>
  28. <el-dropdown-menu slot="dropdown">
  29. <router-link to="/user/profile">
  30. <el-dropdown-item>个人中心</el-dropdown-item>
  31. </router-link>
  32. <el-dropdown-item @click.native="setting = true">
  33. <span>布局设置</span>
  34. </el-dropdown-item>
  35. <el-dropdown-item divided @click.native="logout">
  36. <span>退出登录</span>
  37. </el-dropdown-item>
  38. </el-dropdown-menu>
  39. </el-dropdown>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import { mapGetters } from 'vuex'
  45. import Breadcrumb from '@/components/Breadcrumb'
  46. import TopNav from '@/components/TopNav'
  47. import Hamburger from '@/components/Hamburger'
  48. import Screenfull from '@/components/Screenfull'
  49. import SizeSelect from '@/components/SizeSelect'
  50. import Search from '@/components/HeaderSearch'
  51. import RuoYiGit from '@/components/RuoYi/Git'
  52. import RuoYiDoc from '@/components/RuoYi/Doc'
  53. import RuoYiBell from '@/components/RuoYi/Bell'
  54. export default {
  55. components: {
  56. Breadcrumb,
  57. TopNav,
  58. Hamburger,
  59. Screenfull,
  60. SizeSelect,
  61. Search,
  62. RuoYiGit,
  63. RuoYiDoc,
  64. RuoYiBell
  65. },
  66. computed: {
  67. ...mapGetters([
  68. 'sidebar',
  69. 'avatar',
  70. 'device'
  71. ]),
  72. setting: {
  73. get() {
  74. return this.$store.state.settings.showSettings
  75. },
  76. set(val) {
  77. this.$store.dispatch('settings/changeSetting', {
  78. key: 'showSettings',
  79. value: val
  80. })
  81. }
  82. },
  83. topNav: {
  84. get() {
  85. return this.$store.state.settings.topNav
  86. }
  87. }
  88. },
  89. methods: {
  90. toggleSideBar() {
  91. this.$store.dispatch('app/toggleSideBar')
  92. },
  93. async logout() {
  94. this.$confirm('确定注销并退出系统吗?', '提示', {
  95. confirmButtonText: '确定',
  96. cancelButtonText: '取消',
  97. type: 'warning'
  98. }).then(() => {
  99. this.$store.dispatch('LogOut').then(() => {
  100. location.href = '/index';
  101. })
  102. }).catch(() => {});
  103. }
  104. }
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. .navbar {
  109. height: 50px;
  110. overflow: hidden;
  111. position: relative;
  112. background: #fff;
  113. box-shadow: 0 1px 4px rgba(0,21,41,.08);
  114. .hamburger-container {
  115. line-height: 46px;
  116. height: 100%;
  117. float: left;
  118. cursor: pointer;
  119. transition: background .3s;
  120. -webkit-tap-highlight-color:transparent;
  121. &:hover {
  122. background: rgba(0, 0, 0, .025)
  123. }
  124. }
  125. .breadcrumb-container {
  126. float: left;
  127. }
  128. .topmenu-container {
  129. position: absolute;
  130. left: 50px;
  131. }
  132. .errLog-container {
  133. display: inline-block;
  134. vertical-align: top;
  135. }
  136. .right-menu {
  137. float: right;
  138. height: 100%;
  139. line-height: 50px;
  140. &:focus {
  141. outline: none;
  142. }
  143. .right-menu-item {
  144. display: inline-block;
  145. padding: 0 8px;
  146. height: 100%;
  147. font-size: 18px;
  148. color: #5a5e66;
  149. vertical-align: text-bottom;
  150. &.hover-effect {
  151. cursor: pointer;
  152. transition: background .3s;
  153. &:hover {
  154. background: rgba(0, 0, 0, .025)
  155. }
  156. }
  157. }
  158. .avatar-container {
  159. margin-right: 30px;
  160. .avatar-wrapper {
  161. margin-top: 5px;
  162. position: relative;
  163. .user-avatar {
  164. cursor: pointer;
  165. width: 40px;
  166. height: 40px;
  167. border-radius: 10px;
  168. }
  169. .el-icon-caret-bottom {
  170. cursor: pointer;
  171. position: absolute;
  172. right: -20px;
  173. top: 25px;
  174. font-size: 12px;
  175. }
  176. }
  177. }
  178. }
  179. }
  180. </style>