演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。 Co-authored-by: Cursor <cursoragent@cursor.com>
51 lines
1.8 KiB
TypeScript
51 lines
1.8 KiB
TypeScript
'use client'
|
|
|
|
import { Avatar, AvatarFallback, AvatarImage } from '@langgenius/dify-ui/avatar'
|
|
import { cn } from '@langgenius/dify-ui/cn'
|
|
import { useSuspenseQuery } from '@tanstack/react-query'
|
|
import AccountMenu from '@/app/components/header/account-menu'
|
|
import { userProfileQueryOptions } from '@/features/account-profile/client'
|
|
import { getAvatarInitial } from '@/utils/avatar'
|
|
|
|
type AccountSectionProps = {
|
|
compact?: boolean
|
|
}
|
|
|
|
const AccountSection = ({ compact = false }: AccountSectionProps) => {
|
|
const { data: userProfile } = useSuspenseQuery({
|
|
...userProfileQueryOptions(),
|
|
select: (data) => data.profile,
|
|
})
|
|
|
|
return (
|
|
<AccountMenu
|
|
trigger={({ ariaLabel }) => (
|
|
<button
|
|
type="button"
|
|
title={userProfile.name}
|
|
className={cn(
|
|
'flex min-w-0 shrink items-center rounded-full text-start text-components-main-nav-text transition-colors hover:bg-state-base-hover focus-visible:ring-inset disabled:cursor-default disabled:hover:bg-transparent',
|
|
compact ? 'justify-center p-1' : 'max-w-45 gap-3 py-1 ps-1 pe-4',
|
|
'data-popup-open:bg-state-base-hover',
|
|
)}
|
|
>
|
|
<Avatar size="md" className="size-7" aria-hidden="true">
|
|
<AvatarFallback>{getAvatarInitial(userProfile.name)}</AvatarFallback>
|
|
<AvatarImage src={userProfile.avatar_url || undefined} alt="" />
|
|
</Avatar>
|
|
{!compact && (
|
|
<span className="min-w-0 flex-1 truncate system-md-medium" title={userProfile.name}>
|
|
{userProfile.name}
|
|
</span>
|
|
)}
|
|
<span className="sr-only">
|
|
{compact ? `${userProfile.name} ${ariaLabel}` : ariaLabel}
|
|
</span>
|
|
</button>
|
|
)}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export default AccountSection
|