feat: init commit
This commit is contained in:
72
src/components/userProfile.vue
Normal file
72
src/components/userProfile.vue
Normal file
@@ -0,0 +1,72 @@
|
||||
<template>
|
||||
<router-link to="/home/user" v-if="userinfo.user.u_avatar" class="user-profile-link">
|
||||
<div class="user-profile">
|
||||
<img :src="userinfo.user.u_avatar" alt="User Avatar" />
|
||||
<div :class="['status-dot', statusClass]"></div>
|
||||
</div>
|
||||
</router-link>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { userInfoStore } from '@/store/store';
|
||||
|
||||
const userinfo = userInfoStore();
|
||||
|
||||
const isLoggedIn = ref(true); // 假设用户已登录
|
||||
|
||||
const statusClass = computed(() => {
|
||||
return isLoggedIn.value ? 'online' : 'offline';
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.user-profile-link {
|
||||
display: inline-block;
|
||||
text-decoration: none;
|
||||
/* 去掉链接的下划线 */
|
||||
}
|
||||
|
||||
.user-profile {
|
||||
position: fixed;
|
||||
bottom: 30px;
|
||||
right: 30px;
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
border-radius: 50%;
|
||||
background-color: #fff;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
|
||||
z-index: 500;
|
||||
|
||||
}
|
||||
|
||||
.user-profile img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border-radius: 50%;
|
||||
border: 2px solid white;
|
||||
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.online {
|
||||
background-color: green;
|
||||
/* 在线状态 */
|
||||
}
|
||||
|
||||
.offline {
|
||||
background-color: red;
|
||||
/* 离线状态 */
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user