mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-27 03:19:56 +00:00
Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-019bd8c8-bce1-70bc-a125-baf2a1503ee8
72 lines
1.7 KiB
Vue
72 lines
1.7 KiB
Vue
<!-- A button that shows current authenticated user's avatar -->
|
|
<template>
|
|
<div>
|
|
<Button
|
|
v-if="isLoggedIn"
|
|
class="p-1 hover:bg-transparent"
|
|
variant="muted-textonly"
|
|
:aria-label="$t('g.currentUser')"
|
|
@click="popover?.toggle($event)"
|
|
>
|
|
<div
|
|
:class="
|
|
cn(
|
|
'flex items-center justify-center gap-1 rounded-full hover:bg-interface-button-hover-surface',
|
|
compact && 'aspect-square size-full'
|
|
)
|
|
"
|
|
>
|
|
<UserAvatar
|
|
:photo-url="photoURL"
|
|
:class="compact && 'size-full'"
|
|
/>
|
|
|
|
<i
|
|
v-if="showArrow"
|
|
class="icon-[lucide--chevron-down] size-3 px-1"
|
|
/>
|
|
</div>
|
|
</Button>
|
|
|
|
<Popover
|
|
ref="popover"
|
|
:show-arrow="false"
|
|
:pt="{
|
|
root: {
|
|
class: 'rounded-lg'
|
|
}
|
|
}"
|
|
>
|
|
<CurrentUserPopover @close="closePopover" />
|
|
</Popover>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import Popover from 'primevue/popover'
|
|
import { computed, ref } from 'vue'
|
|
|
|
import UserAvatar from '@/components/common/UserAvatar.vue'
|
|
import Button from '@/components/ui/button/Button.vue'
|
|
import { useCurrentUser } from '@/composables/auth/useCurrentUser'
|
|
import { cn } from '@/utils/tailwindUtil'
|
|
|
|
import CurrentUserPopover from './CurrentUserPopover.vue'
|
|
|
|
const { showArrow = true, compact = false } = defineProps<{
|
|
showArrow?: boolean
|
|
compact?: boolean
|
|
}>()
|
|
|
|
const { isLoggedIn, userPhotoUrl } = useCurrentUser()
|
|
|
|
const popover = ref<InstanceType<typeof Popover> | null>(null)
|
|
const photoURL = computed<string | undefined>(
|
|
() => userPhotoUrl.value ?? undefined
|
|
)
|
|
|
|
const closePopover = () => {
|
|
popover.value?.hide()
|
|
}
|
|
</script>
|