李金
7 months ago
10 changed files with 444 additions and 356 deletions
-
50src/components/avatar/index.tsx
-
7src/components/breadcrumb/index.tsx
-
18src/components/icon/index.tsx
-
3src/components/icon/picker/IconRender.tsx
-
2src/components/icon/types.ts
-
45src/layout/RootLayout.tsx
-
12src/layout/style.ts
-
6src/pages/system/menus/index.tsx
-
4src/service/system.ts
-
15src/store/user.ts
@ -0,0 +1,50 @@ |
|||||
|
import Icon from '@/components/icon' |
||||
|
import { useTranslation } from '@/i18n.ts' |
||||
|
import { currentUserAtom } from '@/store/user.ts' |
||||
|
import { Avatar as AntAvatar, Dropdown, Spin } from 'antd' |
||||
|
import { useAtomValue } from 'jotai' |
||||
|
|
||||
|
const Avatar = () => { |
||||
|
|
||||
|
const { t } = useTranslation() |
||||
|
const { data, isLoading } = useAtomValue(currentUserAtom) |
||||
|
|
||||
|
return ( |
||||
|
<div> |
||||
|
<Dropdown |
||||
|
key={'user'} |
||||
|
placement="bottomRight" |
||||
|
menu={{ |
||||
|
items: [ |
||||
|
{ |
||||
|
key: 'logout', |
||||
|
icon: <Icon type={'park:Logout'}/>, |
||||
|
label: <span style={{ |
||||
|
marginInlineStart: 8, |
||||
|
userSelect: 'none' |
||||
|
}}>{t('app.header.logout')}</span>, |
||||
|
}, |
||||
|
], |
||||
|
}} |
||||
|
> |
||||
|
<Spin spinning={isLoading}> |
||||
|
<AntAvatar |
||||
|
key="avatar" |
||||
|
size={'small'} |
||||
|
src={data?.avatar || data?.nickname?.substring(0, 1)}> |
||||
|
{!data?.avatar && data?.nickname?.substring(0, 1)} |
||||
|
</AntAvatar> |
||||
|
<span key="name" |
||||
|
style={{ |
||||
|
marginInlineStart: 8, |
||||
|
userSelect: 'none' |
||||
|
}}> |
||||
|
{data?.nickname} |
||||
|
</span> |
||||
|
</Spin> |
||||
|
</Dropdown> |
||||
|
</div> |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
export default Avatar |
Write
Preview
Loading…
Cancel
Save
Reference in new issue