|
@@ -6,18 +6,28 @@
|
|
|
<template>
|
|
|
<div class="layout">
|
|
|
<div class="head">
|
|
|
- <el-dropdown class="avatar-con" trigger="click" @visible-change="visibleChange">
|
|
|
+ <el-dropdown :popper-options="{}" popper-class="headDropdown" class="avatar-con" trigger="click" @visible-change="visibleChange">
|
|
|
<div class="avatar">
|
|
|
<div class="imgCon"><img :src="userInfo.avatar" /></div>
|
|
|
<div class="name">{{ userInfo.username }}</div>
|
|
|
<img class="horn" :class="{ isVisible: visible }" src="@/img/layout/horn.png" />
|
|
|
</div>
|
|
|
<template #dropdown>
|
|
|
- <el-dropdown-menu>
|
|
|
- <el-dropdown-item @click="logout">
|
|
|
- <span>退出登录</span>
|
|
|
- </el-dropdown-item>
|
|
|
- </el-dropdown-menu>
|
|
|
+ <div class="dropdown">
|
|
|
+ <div class="avatar-item">
|
|
|
+ <img :src="userInfo.avatar" />
|
|
|
+ <div class="userInfo">
|
|
|
+ <div class="realName">{{ userInfo.realName }}</div>
|
|
|
+ <div class="phone">{{ userInfo.phone }}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="logout-item">
|
|
|
+ <div class="logoutBtn" @click="handleLogout">
|
|
|
+ <img src="@/img/layout/logout.png" />
|
|
|
+ <div class="text">退出登录</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
</el-dropdown>
|
|
|
</div>
|
|
@@ -29,6 +39,7 @@
|
|
|
import userStore from "@/store/modules/user"
|
|
|
import { computed } from "vue"
|
|
|
import { ref } from "vue"
|
|
|
+import { ElMessage } from "element-plus"
|
|
|
|
|
|
const userStoreHook = userStore()
|
|
|
|
|
@@ -40,7 +51,14 @@ const visible = ref(false)
|
|
|
function visibleChange(value: boolean) {
|
|
|
visible.value = value
|
|
|
}
|
|
|
-function logout() {}
|
|
|
+function handleLogout() {
|
|
|
+ userStore()
|
|
|
+ .loginOut()
|
|
|
+ .then()
|
|
|
+ .catch((err: apiResDataType) => {
|
|
|
+ ElMessage.error(err.message)
|
|
|
+ })
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
@@ -99,4 +117,67 @@ function logout() {}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+:global(.headDropdown.el-dropdown__popper.el-popper) {
|
|
|
+ box-shadow: 0px 2px 17px 0px rgba(0, 0, 0, 0.08);
|
|
|
+ background: #ffffff;
|
|
|
+ border-radius: 16px;
|
|
|
+ inset: 84px 54px auto auto !important;
|
|
|
+}
|
|
|
+.dropdown {
|
|
|
+ width: 300px;
|
|
|
+ padding: 20px;
|
|
|
+ & > div {
|
|
|
+ border-bottom: 1px solid #f2f2f2;
|
|
|
+ &:last-child {
|
|
|
+ border-bottom: none;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .avatar-item {
|
|
|
+ display: flex;
|
|
|
+ padding-bottom: 16px;
|
|
|
+ > img {
|
|
|
+ width: 48px;
|
|
|
+ height: 48px;
|
|
|
+ border-radius: 50%;
|
|
|
+ flex-shrink: 0;
|
|
|
+ }
|
|
|
+ .userInfo {
|
|
|
+ margin-left: 16px;
|
|
|
+ .realName {
|
|
|
+ font-weight: 600;
|
|
|
+ font-size: 20px;
|
|
|
+ line-height: 28px;
|
|
|
+ color: #333333;
|
|
|
+ }
|
|
|
+ .phone {
|
|
|
+ font-weight: 400;
|
|
|
+ font-size: 16px;
|
|
|
+ color: #777777;
|
|
|
+ line-height: 22px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .logout-item {
|
|
|
+ padding-top: 16px;
|
|
|
+ .logoutBtn {
|
|
|
+ cursor: pointer;
|
|
|
+ padding: 0 12px;
|
|
|
+ width: 100%;
|
|
|
+ height: 50px;
|
|
|
+ background: #f5f6fa;
|
|
|
+ border-radius: 10px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ &:hover {
|
|
|
+ opacity: $opacity-hover;
|
|
|
+ }
|
|
|
+ .text {
|
|
|
+ margin-left: 20px;
|
|
|
+ font-weight: 500;
|
|
|
+ font-size: 18px;
|
|
|
+ color: #333333;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|