jiaqingjiayi-Web/src/views/layout/header/avatar.vue

48 lines
1.2 KiB
Vue
Raw Normal View History

2024-12-24 02:16:37 +00:00
<template>
<el-dropdown>
<span class="el-dropdown-link">
<el-avatar shape="square" :size="40" :src="squareUrl" />
</span>
<template #dropdown>
2025-01-12 06:17:15 +00:00
<el-dropdown-menu>
<el-dropdown-item @click="message">消息通知</el-dropdown-item>
</el-dropdown-menu >
2024-12-24 02:16:37 +00:00
<el-dropdown-menu>
<el-dropdown-item @click="topersonal">个人中心</el-dropdown-item>
</el-dropdown-menu >
<el-dropdown-menu>
<el-dropdown-item @click="logout">安全退出</el-dropdown-item>
</el-dropdown-menu >
</template>
</el-dropdown>
</template>
<script setup>
import { ref } from 'vue'
import { useStore } from 'vuex'
import axios from "@/util/axios";
import router from "@/router";
import {ElMessage} from "element-plus";
const store=useStore();
2025-01-14 13:17:20 +00:00
const squareUrl=ref()
const initForm=()=>{
let userInfoJson = window.sessionStorage.getItem("USER_LOGIN_STATE");
2024-12-24 02:16:37 +00:00
2025-01-14 13:17:20 +00:00
squareUrl.value=JSON.parse(userInfoJson).avatarUrl
}
initForm();
2024-12-24 02:16:37 +00:00
const logout=async ()=>{
store.dispatch('logout')
let res=await axios.post("/user/logout")
ElMessage.warning("退出成功");
// console.log(res)
}
const topersonal= ()=>{
router.push('/personal')
}
2025-01-12 06:17:15 +00:00
const message= ()=>{
router.push('/message')
}
2024-12-24 02:16:37 +00:00
</script>
<style lang="scss" scoped>
</style>