header.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <div class="main-header">
  3. <div class="main-logo">
  4. <img src="@/assets/logo.png" alt="" />
  5. <span>维修检测平台</span>
  6. </div>
  7. <div class="main-user" ref="buttonRef" @click="onClickOutside">
  8. <span class="user-name">李明华</span>
  9. <img src="@/assets/logo.png" alt="" />
  10. </div>
  11. <el-popover
  12. :teleported="false"
  13. ref="popoverRef"
  14. :virtual-ref="buttonRef"
  15. trigger="click"
  16. title=""
  17. virtual-triggering
  18. >
  19. <div class="loginOut" @click="loginOutFun">退出登录</div>
  20. </el-popover>
  21. </div>
  22. </template>
  23. <script setup lang="ts">
  24. import { ref, unref } from "vue";
  25. import { ClickOutside as vClickOutside } from "element-plus";
  26. const buttonRef = ref();
  27. const popoverRef = ref();
  28. const onClickOutside = () => {
  29. unref(popoverRef).popperRef?.delayHide?.();
  30. };
  31. const loginOutFun = () => {
  32. alert("退出登录");
  33. // window.location.href = "/login";
  34. };
  35. </script>
  36. <style scoped lang="scss">
  37. .main-header {
  38. width: 100%;
  39. height: $main-header-height;
  40. background-color: $hj-white-1;
  41. display: flex;
  42. justify-content: space-between;
  43. align-items: center;
  44. padding: 0 10px;
  45. ::v-deep .el-popper {
  46. .loginOut {
  47. cursor: pointer;
  48. }
  49. }
  50. .main-logo {
  51. img {
  52. vertical-align: middle;
  53. width: 36px;
  54. height: 36px;
  55. }
  56. span {
  57. font-size: var(--hj-fs-16);
  58. color: var(--fc-color-3);
  59. }
  60. }
  61. .main-user {
  62. cursor: pointer;
  63. img {
  64. vertical-align: middle;
  65. width: 18px;
  66. height: 20px;
  67. }
  68. .user-name {
  69. margin-right: 10px;
  70. font-size: var(--hj-fs-14);
  71. color: var(--fc-color-4);
  72. }
  73. }
  74. }
  75. </style>