Files
FreeERP.Antd.Admin/src/components/Header/HeaderUserInfo.tsx
2026-01-23 09:43:55 +08:00

70 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { DownOutlined } from '@ant-design/icons';
import { Button, Dropdown, Popconfirm, Space } from 'antd';
import { useUserStore } from '@/store/UserStore';
import { GapBox } from '../GapBox';
export const HeaderUserInfo: React.FC = () => {
const userInfo = useUserStore().user;
return (
<GapBox>
{/* 用户信息 Dropdown */}
<Dropdown
trigger={['click']}
placement='bottomRight'
arrow
menu={{
items: [
{
key: 'user-info',
disabled: true, // 只展示,不可操作
label: (
<Space size={8} style={{ color: 'rgba(0,0,0,0.88)' }}>
<span>
{userInfo.username} ({userInfo.nickname})
</span>
</Space>
),
},
],
}}
>
<div style={{ cursor: 'pointer' }}>
<Space size={4}>
<span></span>
<span
style={{
maxWidth: 120,
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
overflow: 'hidden',
}}
>
{userInfo.username}
</span>
<DownOutlined
style={{
fontSize: 10,
marginTop: 2,
color: '#666',
}}
/>
</Space>
</div>
</Dropdown>
{/* 退出登录 */}
<Popconfirm
title='确定要退出登录吗?'
onConfirm={() => {
location.hash = '#/login';
}}
>
<Button size='small' variant='text' color='primary'>
退
</Button>
</Popconfirm>
</GapBox>
);
};