topNav.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <div class="work-layout-title">
  3. <div class="work-layout-left">
  4. <div class="work-layout-image">
  5. <img src="https://file-node.oss-cn-shanghai.aliyuncs.com/youji/2f7b4bfaf9e64817bc2cb46f3a632b01"
  6. alt="logo.png" />
  7. </div>
  8. <div class="work-layout-label">WORKARK</div>
  9. </div>
  10. <div class="work-layout-right">
  11. <div class="work-layout-badge">
  12. <el-badge :is-dot="systemCountStatus">
  13. <i class="iconfont huifont-xiaoxi"></i>
  14. </el-badge>
  15. </div>
  16. <el-dropdown @visible-change="value => userDropdown = value" @command="userCommand">
  17. <div class="work-layout-user">
  18. <div class="work-layout-avatar">
  19. <avatar :user="users"></avatar>
  20. </div>
  21. <i :class="'iconfont huifont-gerenzhongxinxiala'+ (userDropdown ? ' dropdown-icon' : '')"></i>
  22. </div>
  23. <el-dropdown-menu class="user-dropdown" slot="dropdown">
  24. <el-dropdown-item command="user">{{users.name}}</el-dropdown-item>
  25. <el-dropdown-item command="detail">个人信息</el-dropdown-item>
  26. <el-dropdown-item command="loginout">退出登录</el-dropdown-item>
  27. </el-dropdown-menu>
  28. </el-dropdown>
  29. </div>
  30. </div>
  31. </template>
  32. <script>
  33. import {
  34. removeToken
  35. } from '@/uitls/auth';
  36. import {
  37. mapGetters
  38. } from 'vuex';
  39. export default {
  40. data() {
  41. return {
  42. users: {},
  43. userDropdown: false,
  44. systemCountStatus: false
  45. }
  46. },
  47. mounted() {
  48. this.init();
  49. },
  50. methods: {
  51. init() {
  52. this.users = this.$store.getters.user;
  53. },
  54. userCommand(command) {
  55. switch (command) {
  56. case 'detail':
  57. break;
  58. case 'loginout':
  59. this.loginout();
  60. break;
  61. default:
  62. break;
  63. }
  64. },
  65. loginout() {
  66. this.$confirm('是否要退出登录?', () => {
  67. removeToken();
  68. this.$router.replace('/loginRegister/login')
  69. this.$message.success('退出成功');
  70. });
  71. },
  72. },
  73. watch: {
  74. user() {
  75. this.init();
  76. }
  77. },
  78. computed: {
  79. ...mapGetters(['user'])
  80. },
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .work-layout-title {
  85. display: flex;
  86. height: 52px;
  87. position: absolute;
  88. left: 0;
  89. right: 0;
  90. top: 0;
  91. justify-content: space-between;
  92. background: $--color-white;
  93. border-bottom: 1px solid $--border-color-lighter;
  94. }
  95. .work-layout-left {
  96. height: 100%;
  97. padding-left: 24px;
  98. display: flex;
  99. align-items: center;
  100. }
  101. .work-layout-image {
  102. width: 36px;
  103. height: 36px;
  104. border-radius: 4px;
  105. overflow: hidden;
  106. img {
  107. width: 100%;
  108. height: 100%;
  109. }
  110. }
  111. .work-layout-label {
  112. padding-left: 10px;
  113. font-size: 18px;
  114. font-weight: bold;
  115. font-weight: 600;
  116. margin-right: 77px;
  117. }
  118. .work-layout-right {
  119. height: 100%;
  120. padding-right: 24px;
  121. display: flex;
  122. align-items: center;
  123. }
  124. .work-layout-badge {
  125. margin-right: 35px;
  126. cursor: pointer;
  127. margin-left: 20px;
  128. .iconfont {
  129. font-size: 22px;
  130. }
  131. .el-badge__content {
  132. border: none;
  133. }
  134. }
  135. .work-layout-user {
  136. display: flex;
  137. align-items: center;
  138. cursor: pointer;
  139. .work-layout-avatar {
  140. width: 32px;
  141. height: 32px;
  142. border-radius: 50%;
  143. overflow: hidden;
  144. margin-right: 8px;
  145. }
  146. .iconfont {
  147. font-size: 14px;
  148. transition: all 300ms;
  149. }
  150. .dropdown-icon {
  151. transform: rotate(180deg);
  152. }
  153. }
  154. </style>