Header.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <div class="header-wp">
  3. <div class="header-left-wp">
  4. <div class="title">两江资本</div>
  5. <div class="sub-title">无敌中控</div>
  6. </div>
  7. <div class="header-right-wp">
  8. <div class="info-wp">
  9. <div class="info-name">欢迎, {{ nickname }}</div>
  10. <lay-dropdown trigger="hover" placement="bottom-end" updateAtScroll>
  11. <div class="info-avatar">
  12. <img :src="avatarUrl" />
  13. </div>
  14. <template #content>
  15. <lay-dropdown-menu>
  16. <lay-dropdown-menu-item @click="handeLoginOut()">退出登录</lay-dropdown-menu-item>
  17. </lay-dropdown-menu>
  18. </template>
  19. </lay-dropdown>
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script lang="ts" setup>
  25. import { useRouter } from "vue-router";
  26. import { client_logout } from "@/api/index";
  27. const router = useRouter();
  28. defineProps({
  29. nickname: String,
  30. avatarUrl: String,
  31. });
  32. const handeLoginOut = () => {
  33. client_logout({}, () => {
  34. window.sessionStorage.removeItem("_4L_TOKEN");
  35. window.sessionStorage.removeItem("_4L_MENU_PATH");
  36. window.sessionStorage.removeItem("_4L_S_MENU_PATH");
  37. window.sessionStorage.removeItem("_4L_TAG_LIST");
  38. window.sessionStorage.removeItem("_4L_API_LIST");
  39. window.sessionStorage.removeItem("_4L_MENU_COLLAPSE");
  40. router.push({ path: "/login" });
  41. });
  42. };
  43. </script>
  44. <style lang="scss" scoped>
  45. .header-wp {
  46. box-sizing: border-box;
  47. height: 100%;
  48. width: 100%;
  49. border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  50. display: flex;
  51. .header-left-wp {
  52. box-sizing: border-box;
  53. display: flex;
  54. justify-content: center;
  55. flex-direction: column;
  56. text-align: center;
  57. width: 256px;
  58. border-right: 1px solid rgba(0, 0, 0, 0.1);
  59. .title {
  60. font-size: 18px;
  61. font-weight: bold;
  62. }
  63. .sub-title {
  64. font-weight: bold;
  65. }
  66. }
  67. .header-right-wp {
  68. flex: 1;
  69. display: flex;
  70. justify-content: right;
  71. align-items: center;
  72. .info-wp {
  73. display: flex;
  74. align-items: center;
  75. padding: 0 20px;
  76. .info-name {
  77. padding-right: 10px;
  78. font-size: 14px;
  79. }
  80. .info-avatar {
  81. font-size: 0;
  82. img {
  83. border-radius: 50%;
  84. width: 32px;
  85. height: 32px;
  86. }
  87. }
  88. }
  89. }
  90. }
  91. </style>