index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <header>
  3. <div class="left-box">
  4. <!-- 收缩按钮 -->
  5. <div class="menu-icon" @click="opendStateChange">
  6. <i class="sfont head-fold" :class="isCollapse ? 'system-s-unfold' : 'system-s-fold'"></i>
  7. </div>
  8. <Breadcrumb />
  9. </div>
  10. <div class="right-box">
  11. <!-- 快捷功能按钮 -->
  12. <div class="function-list">
  13. <div class="function-list-item"><Notices /></div>
  14. <div class="function-list-item hidden-sm-and-down"><Full-screen /></div>
  15. <div class="function-list-item">
  16. <SizeChange />
  17. </div>
  18. <div class="function-list-item hidden-sm-and-down">
  19. <Theme />
  20. </div>
  21. <!-- <div class="function-list-item hidden-sm-and-down"><Github /></div> -->
  22. </div>
  23. <!-- 用户信息 -->
  24. <div class="user-info">
  25. <el-dropdown>
  26. <span class="el-dropdown-link" style="display: flex;align-items: center; min-width: 90px;justify-content: space-between;">
  27. <el-avatar :size="40" :src="userInfo.headImage" />
  28. <div style="margin: 0 5px;">
  29. {{userInfo.nickName}}
  30. <i class="sfont system-xiala"></i>
  31. </div>
  32. </span>
  33. <template #dropdown>
  34. <el-dropdown-menu>
  35. <!-- <el-dropdown-item @click="showPasswordLayer">修改密码</el-dropdown-item> -->
  36. <el-dropdown-item @click="loginOut">退出登录</el-dropdown-item>
  37. </el-dropdown-menu>
  38. </template>
  39. </el-dropdown>
  40. </div>
  41. <password-layer :layer="layer" v-if="layer.show" />
  42. </div>
  43. </header>
  44. </template>
  45. <script lang="js">
  46. import { defineComponent, computed, reactive } from 'vue'
  47. import { useStore } from 'vuex'
  48. import { useRouter, useRoute } from 'vue-router'
  49. import Notices from './functionList/notices.vue'
  50. import FullScreen from './functionList/fullscreen.vue'
  51. import SizeChange from './functionList/sizeChange.vue'
  52. import Github from './functionList/github.vue'
  53. import Theme from './functionList/theme.vue'
  54. import Breadcrumb from './Breadcrumb.vue'
  55. import PasswordLayer from './passwordLayer.vue'
  56. export default defineComponent({
  57. components: {
  58. Notices,
  59. FullScreen,
  60. Breadcrumb,
  61. SizeChange,
  62. Github,
  63. Theme,
  64. PasswordLayer
  65. },
  66. setup() {
  67. const store = useStore()
  68. const router = useRouter()
  69. const route = useRoute()
  70. const layer = reactive({
  71. show: false,
  72. showButton: true
  73. })
  74. const isCollapse = computed(() => store.state.app.isCollapse)
  75. const userInfo = computed(() => store.state.user.info)
  76. // isCollapse change to hide/show the sidebar
  77. const opendStateChange = () => {
  78. store.commit('app/isCollapseChange', !isCollapse.value)
  79. }
  80. // login out the system
  81. const loginOut = () => {
  82. store.dispatch('user/loginOut')
  83. }
  84. const showPasswordLayer = () => {
  85. layer.show = true
  86. }
  87. return {
  88. isCollapse,
  89. userInfo,
  90. layer,
  91. opendStateChange,
  92. loginOut,
  93. showPasswordLayer
  94. }
  95. }
  96. })
  97. </script>
  98. <style lang="scss" scoped>
  99. header {
  100. display: flex;
  101. justify-content: space-between;
  102. align-items: center;
  103. height: 60px;
  104. background-color: var(--system-header-background);
  105. padding-right: 22px;
  106. }
  107. .left-box {
  108. height: 100%;
  109. display: flex;
  110. align-items: center;
  111. .menu-icon {
  112. width: 60px;
  113. height: 100%;
  114. display: flex;
  115. align-items: center;
  116. justify-content: center;
  117. font-size: 25px;
  118. font-weight: 100;
  119. cursor: pointer;
  120. margin-right: 10px;
  121. &:hover {
  122. background-color: var(--system-header-item-hover-color);
  123. }
  124. i {
  125. color: var(--system-header-text-color);
  126. }
  127. }
  128. }
  129. .right-box {
  130. display: flex;
  131. justify-content: center;
  132. align-items: center;
  133. .function-list {
  134. display: flex;
  135. .function-list-item {
  136. width: 30px;
  137. display: flex;
  138. justify-content: center;
  139. align-items: center;
  140. :deep(i) {
  141. color: var(--system-header-text-color);
  142. }
  143. }
  144. }
  145. .user-info {
  146. margin-left: 20px;
  147. .el-dropdown-link {
  148. color: var(--system-header-breadcrumb-text-color);
  149. }
  150. }
  151. }
  152. .head-fold {
  153. font-size: 20px;
  154. }
  155. </style>