| | |
| | | <div class="user-panel max-w-sm min-w-96 h-fit"> |
| | | <el-card class="card"> |
| | | <div class="panel-content flex flex-col items-center"> |
| | | <div class="avatar-container w-40 h-40 rounded-full overflow-hidden"> |
| | | <!-- 学生信息 --> |
| | | <div class="avatar-container w-40 h-40 rounded-full overflow-hidden" @click="quit()"> |
| | | <div class="avatar-content" v-if="userInfo.imagePath"> |
| | | <img :src="userInfo.imagePath" class="avatar-img" alt=""> |
| | | </div> |
| | |
| | | <div class="department-container text-base mb-10"> |
| | | {{ userInfo.userName }} |
| | | </div> |
| | | |
| | | <!-- 学生选项 --> |
| | | <div class="tool-container grid grid-cols-3 gap-10"> |
| | | <div class="tool-item text-center cursor-pointer" v-for="item in toolList" @click="toolClick(item)"> |
| | | <div class="tool-icon mb-1"> |
| | |
| | | import { useRouter } from 'vue-router'; |
| | | import { storeToRefs } from 'pinia'; |
| | | import { useUserStore } from '@/store/index.js'; |
| | | import { logout } from '@/api/modules/user.js'; |
| | | |
| | | const userStore = useUserStore(); |
| | | const { userInfo } = storeToRefs(userStore); |
| | | const { userInfo } = storeToRefs(userStore |
| | | |
| | | ) |
| | | |
| | | |
| | | |
| | | const router = useRouter(); |
| | | |
| | | // 获取列表 |
| | | const toolList = ref([ |
| | | { |
| | | id: 1, |
| | |
| | | }, |
| | | ]); |
| | | |
| | | |
| | | // 获取颜色 |
| | | const getColor = computed(() => { |
| | | return randomColor(); |
| | | }); |
| | | |
| | | // 获取用户信息 |
| | | const getFirstName = computed(() => { |
| | | return userInfo.value.realName && userInfo.value.realName[0]; |
| | | }); |
| | | |
| | | // 点击事件 |
| | | const toolClick = (item) => { |
| | | if (item.path) { |
| | | router.push(item.path); |
| | | } |
| | | } |
| | | |
| | | // 退出登录 |
| | | const quit = () => { |
| | | logout().then(() =>{ |
| | | router.push('/login').then(()=>{ |
| | | userStore.setUserInfo(null) |
| | | localStorage.clear("user") |
| | | }) |
| | | }).catch((err) =>{ |
| | | console.log("退出登录失败,失败原因;",err) |
| | | }) |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |