import { LogoutOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons'; import { Avatar, Menu, Spin } from 'antd'; import React from 'react'; import type { ConnectProps } from 'umi'; import { history, connect } from 'umi'; import type { ConnectState } from '@/models/connect'; import type { CurrentUser } from '@/models/user'; import HeaderDropdown from '../HeaderDropdown'; import styles from './index.less'; export type GlobalHeaderRightProps = { currentUser?: CurrentUser; menu?: boolean; } & Partial; class AvatarDropdown extends React.Component { onMenuClick = (event: { key: React.Key; keyPath: React.Key[]; item: React.ReactInstance }) => { const { key } = event; if (key === 'logout') { const { dispatch } = this.props; if (dispatch) { dispatch({ type: 'login/logout', }); } return; } history.push(`/account/${key}`); }; render(): React.ReactNode { const { currentUser = { avatar: '', name: '', }, menu, } = this.props; const menuHeaderDropdown = ( {menu && ( 个人中心 )} {menu && ( 个人设置 )} {menu && } 退出登录 ); return currentUser && currentUser.name ? ( {currentUser.name} ) : ( ); } } export default connect(({ user }: ConnectState) => ({ currentUser: user.currentUser, }))(AvatarDropdown);