115 lines
3.6 KiB
Vue
115 lines
3.6 KiB
Vue
<script setup lang="ts">
|
|
import { Bell, ChevronsUpDown, LogOut } from "lucide-vue-next";
|
|
|
|
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuGroup,
|
|
DropdownMenuItem,
|
|
DropdownMenuLabel,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
} from "@/components/ui/dropdown-menu";
|
|
import {
|
|
SidebarMenu,
|
|
SidebarMenuButton,
|
|
SidebarMenuItem,
|
|
useSidebar,
|
|
} from "@/components/ui/sidebar";
|
|
import { useDnfHelperStore } from "@/stores/dnfhelper";
|
|
|
|
const props = defineProps<{
|
|
user: {
|
|
name: string;
|
|
id: string;
|
|
avatar: string;
|
|
};
|
|
}>();
|
|
|
|
const { user } = toRefs(props);
|
|
|
|
const { isMobile } = useSidebar();
|
|
|
|
const helperStore = useDnfHelperStore();
|
|
|
|
const bindHelper = () => {
|
|
window.location.href = "/dcalc/dnfhelper";
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<SidebarMenu>
|
|
<SidebarMenuItem>
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger as-child>
|
|
<SidebarMenuButton
|
|
size="lg"
|
|
class="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
|
|
>
|
|
<Avatar class="h-8 w-8 rounded-lg">
|
|
<AvatarImage :src="user.avatar" :alt="user.id" />
|
|
<AvatarFallback class="rounded-lg"> DNF </AvatarFallback>
|
|
</Avatar>
|
|
<div class="grid flex-1 text-left text-sm leading-tight">
|
|
<span class="truncate font-medium">{{ user.name }}</span>
|
|
<span class="truncate text-xs">{{ user.id }}</span>
|
|
</div>
|
|
<ChevronsUpDown class="ml-auto size-4 group-data-[collapsible=icon]:hidden" />
|
|
</SidebarMenuButton>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent
|
|
class="w-(--reka-dropdown-menu-trigger-width) min-w-56 rounded-lg"
|
|
:side="isMobile ? 'bottom' : 'right'"
|
|
align="start"
|
|
:side-offset="4"
|
|
>
|
|
<DropdownMenuLabel class="p-0 font-normal">
|
|
<div class="flex items-center gap-2 px-1 py-1.5 text-left text-sm">
|
|
<Avatar class="h-8 w-8 rounded-lg">
|
|
<AvatarImage :src="user.avatar" :alt="user.name" />
|
|
<AvatarFallback class="rounded-lg"> DNF </AvatarFallback>
|
|
</Avatar>
|
|
<div class="grid flex-1 text-left text-sm leading-tight">
|
|
<span class="truncate font-medium">{{ user.name }}</span>
|
|
<span class="truncate text-xs">{{ user.id }}</span>
|
|
</div>
|
|
</div>
|
|
</DropdownMenuLabel>
|
|
<!-- <DropdownMenuSeparator />
|
|
<DropdownMenuGroup>
|
|
<DropdownMenuItem :disabled="!helperStore.helperInfo">
|
|
<Sparkles />
|
|
切换绑定
|
|
</DropdownMenuItem>
|
|
</DropdownMenuGroup> -->
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuGroup>
|
|
<DropdownMenuItem @click="bindHelper">
|
|
<Bell />
|
|
绑定/同步助手
|
|
</DropdownMenuItem>
|
|
<!-- <DropdownMenuItem>
|
|
<BadgeCheck />
|
|
反馈
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem>
|
|
<CreditCard />
|
|
Billing
|
|
</DropdownMenuItem> -->
|
|
<DropdownMenuItem>
|
|
<Bell />
|
|
反馈
|
|
</DropdownMenuItem>
|
|
</DropdownMenuGroup>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem :disabled="!helperStore.helperInfo" @click="helperStore.logout()">
|
|
<LogOut />
|
|
取消绑定
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</SidebarMenuItem>
|
|
</SidebarMenu>
|
|
</template>
|