<template>
  <router-link to="/home/user" class="user-profile-link">
    <div class="user-profile">
      <!-- 原逻辑：:src="userinfo.user.u_avatar"（远端头像） -->
      <img :src="defaultAvatar" alt="User Avatar" />
      <div :class="['status-dot', statusClass]"></div>
    </div>
  </router-link>

</template>

<script setup>
import { ref, computed } from 'vue';
import { userInfoStore } from '@/store/user.ts';
import defaultAvatar from '@/assets/defaultavatar.jpg';

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>