You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/ui/ico.html

69 lines
1.5 KiB
HTML

11 months ago
<!DOCTYPE html>
<html>
10 months ago
<head>
<meta name="description" content="用户头像和登录状态组件">
</head>
11 months ago
10 months ago
<style>
3 weeks ago
.user-container {
11 months ago
display: flex;
align-items: center;
3 weeks ago
gap: var(--spacing-sm);
cursor: pointer;
padding: var(--spacing-xs) var(--spacing-sm);
border-radius: var(--radius-md);
transition: background-color var(--transition-base);
10 months ago
}
3 weeks ago
.user-container:hover {
background-color: rgba(255, 255, 255, 0.1);
11 months ago
}
.user-avatar {
3 weeks ago
width: 32px;
height: 32px;
border-radius: var(--radius-full);
11 months ago
object-fit: cover;
3 weeks ago
border: 2px solid rgba(255, 255, 255, 0.8);
11 months ago
}
.user-name {
3 weeks ago
font-size: var(--font-size-md);
font-weight: var(--font-weight-medium);
color: inherit;
11 months ago
}
</style>
<body>
3 weeks ago
<div v-if="$G.user.name">
<v-dropdown :items="dropdownItems" @command="handleCommand">
<div class="user-container">
<img :src="$G.user.icon" class="user-avatar" alt="用户头像">
<span class="user-name">{{ $G.user.name }}</span>
</div>
</v-dropdown>
11 months ago
</div>
3 weeks ago
<div v-else>
<v-btn size="sm" variant="ghost" :click="() => $router.push('/login')" style="color: inherit; border-color: currentColor;">
11 months ago
登录
3 weeks ago
</v-btn>
11 months ago
</div>
</body>
3 weeks ago
<script setup>
dropdownItems = [
{ label: "个人中心", value: "profile" },
{ label: "退出登录", value: "logout", divided: true }
];
handleCommand = (val) => {
if (val === 'profile') {
$router.push('/profile');
} else if (val === 'logout') {
$G.token.logout();
}
};
</script>
10 months ago
</html>