systemHeader.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <div id="systemHeader">
  3. <div id="systemInformation">
  4. <img class="logoImg" src="@/assets/thlogo.png" alt="">
  5. <span>太湖流域河湖管理系统</span>
  6. </div>
  7. <div id="systemMenuContainer">
  8. <systemMenu @addSystemMenuView='menuItemClick'></systemMenu>
  9. </div>
  10. <div class="user-area">
  11. <el-dropdown @command="handleCommand" class="avatar-container right-menu-item hover-effect" trigger="hover">
  12. <div class="avatar-wrapper">
  13. <img :src="userStore.avatar" class="user-avatar"/>
  14. <span class="user-nickname"> {{ userStore.nickName }} </span>
  15. </div>
  16. <template #dropdown>
  17. <el-dropdown-menu>
  18. <router-link to="/user/profile">
  19. <el-dropdown-item>个人中心</el-dropdown-item>
  20. </router-link>
  21. <router-link to="/hlgl/bankline">
  22. <el-dropdown-item>后台管理</el-dropdown-item>
  23. </router-link>
  24. <el-dropdown-item divided command="logout">
  25. <span>退出登录</span>
  26. </el-dropdown-item>
  27. </el-dropdown-menu>
  28. </template>
  29. </el-dropdown>
  30. </div>
  31. </div>
  32. </template>
  33. <script setup>
  34. import {onMounted, ref} from 'vue'
  35. import {useRouter} from 'vue-router'
  36. import Cookies from 'js-cookie'
  37. import systemMenu from './systemMenuBar.vue'
  38. import useUserStore from '@/store/modules/user'
  39. import {ElMessageBox} from "element-plus";
  40. const router = useRouter()
  41. const userStore = useUserStore()
  42. const name = ref('')
  43. const emit = defineEmits(['addSystemMenuView'])
  44. const menuItemClick = (menuItem) => {
  45. emit('addSystemMenuView', {viewItem: menuItem.viewItem})
  46. }
  47. function handleCommand(command) {
  48. switch (command) {
  49. case "logout":
  50. logout()
  51. break
  52. default:
  53. break
  54. }
  55. }
  56. function logout() {
  57. ElMessageBox.confirm('确定注销并退出系统吗?', '提示', {
  58. confirmButtonText: '确定',
  59. cancelButtonText: '取消',
  60. type: 'warning'
  61. }).then(() => {
  62. userStore.logOut().then(() => {
  63. location.href = '/index'
  64. })
  65. }).catch(() => {
  66. })
  67. }
  68. onMounted(() => {
  69. if (Cookies.get('isLogin') === 'true') name.value = Cookies.get('name')
  70. })
  71. </script>
  72. <style lang="scss" scoped>
  73. #systemHeader {
  74. height: 56px;
  75. width: 100%;
  76. background: linear-gradient(135deg, #e8f4fd 0%, #d4ecfb 50%, #c5e5fa 100%);
  77. display: flex;
  78. align-items: center;
  79. color: #1a3a5c;
  80. box-shadow: 0 1px 6px rgba(0, 0, 0, .06);
  81. position: relative;
  82. z-index: 500;
  83. border-bottom: 2px solid #b8d8f0;
  84. .right-menu-item {
  85. display: inline-block;
  86. padding: 0 8px;
  87. height: 100%;
  88. font-size: 18px;
  89. color: #5a5e66;
  90. vertical-align: text-bottom;
  91. &.hover-effect {
  92. cursor: pointer;
  93. transition: background 0.3s;
  94. &:hover {
  95. background: rgba(0, 0, 0, 0.025);
  96. }
  97. }
  98. &.theme-switch-wrapper {
  99. display: flex;
  100. align-items: center;
  101. svg {
  102. transition: transform 0.3s;
  103. &:hover {
  104. transform: scale(1.15);
  105. }
  106. }
  107. }
  108. }
  109. .avatar-container {
  110. margin-right: 0px;
  111. padding-right: 0px;
  112. .avatar-wrapper {
  113. margin-top: 10px;
  114. right: 8px;
  115. position: relative;
  116. .user-avatar {
  117. cursor: pointer;
  118. width: 30px;
  119. height: 30px;
  120. margin-right: 8px;
  121. border-radius: 50%;
  122. }
  123. .user-nickname {
  124. position: relative;
  125. left: 0px;
  126. bottom: 10px;
  127. font-size: 14px;
  128. font-weight: bold;
  129. }
  130. i {
  131. cursor: pointer;
  132. position: absolute;
  133. right: -20px;
  134. top: 25px;
  135. font-size: 12px;
  136. }
  137. }
  138. }
  139. }
  140. #systemInformation {
  141. display: flex;
  142. align-items: center;
  143. gap: 10px;
  144. padding: 0 16px;
  145. min-width: 340px;
  146. flex-shrink: 0;
  147. font-size: 17px;
  148. font-weight: 600;
  149. color: #0d4b80;
  150. }
  151. .logoImg {
  152. width: 36px;
  153. height: 36px;
  154. border-radius: 8px;
  155. }
  156. #systemMenuContainer {
  157. flex: 1;
  158. height: 100%;
  159. display: flex;
  160. align-items: center;
  161. }
  162. .user-area {
  163. flex-shrink: 0;
  164. padding: 0 20px;
  165. }
  166. .user-name {
  167. font-size: 13px;
  168. cursor: pointer;
  169. color: #4682b4;
  170. padding: 6px 18px;
  171. border-radius: 20px;
  172. border: 1px solid #b0d0e8;
  173. background: #fff;
  174. }
  175. .user-name:hover {
  176. color: #0d4b80;
  177. border-color: #6baed6;
  178. background: #f0f8ff;
  179. }
  180. </style>