Navbar.vue 5.5 KB

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