UserInfo.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <script setup lang="ts">
  2. import SvgIcon from "@/components/SvgIcon/index.vue";
  3. import { useUserStore } from "@/store/modules/user";
  4. import { useTagsViewStore } from "@/store/modules/tagsView";
  5. import { useRoute, useRouter } from "vue-router";
  6. const userStore = useUserStore();
  7. const tagsViewStore = useTagsViewStore();
  8. const route = useRoute();
  9. const router = useRouter();
  10. /**
  11. * 注销
  12. */
  13. function logout() {
  14. ElMessageBox.confirm("确定退出系统吗?", "提示", {
  15. confirmButtonText: "确定",
  16. cancelButtonText: "取消",
  17. type: "warning",
  18. }).then(() => {
  19. userStore
  20. .logout()
  21. .then(() => {
  22. tagsViewStore.delAllViews();
  23. })
  24. .then(() => {
  25. router.push("/login?redirect=/");
  26. });
  27. });
  28. }
  29. </script>
  30. <template>
  31. <!-- 用户头像 -->
  32. <div class="avatar-container">
  33. <span class="spl">|</span>
  34. <img src="../../../assets/login/avatar.png" alt="头像" />
  35. <span class="">{{ userStore.nickname + " " + userStore.phone }}</span>
  36. <span @click="logout"><svg-icon color="#006eff" icon-class="exit" size="20px" /></span>
  37. </div>
  38. </template>
  39. <style scoped lang="scss">
  40. .avatar-container {
  41. display: flex;
  42. align-items: center;
  43. justify-items: center;
  44. margin: 0 20px 0 0;
  45. cursor: pointer;
  46. img {
  47. width: 40px;
  48. height: 40px;
  49. line-height: 40px;
  50. text-align: center;
  51. background: #494949;
  52. border-radius: 20px;
  53. }
  54. span {
  55. margin-left: 12px;
  56. font-size: 16px;
  57. color: #494949;
  58. &.spl {
  59. margin: 0 12px;
  60. color: #d7d8d8;
  61. }
  62. }
  63. }
  64. </style>