/* * @Author: your name * @Date: 2021-09-03 14:28:27 * @LastEditTime: 2021-09-29 18:32:49 * @LastEditors: Please set LastEditors * @Description: In User Settings Edit * @FilePath: /MedicalWisdomCheckSys/src/components/RightContent/AvatarDropdown.tsx */ import React, { useCallback } from 'react'; import { LogoutOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons'; import { Avatar, Menu, Spin } from 'antd'; import { history, useModel } from 'umi'; import HeaderDropdown from '../HeaderDropdown'; import styles from './index.less'; // import { outLogin } from '@/services/ant-design-pro/api'; import type { MenuInfo } from 'rc-menu/lib/interface'; import {loginOut} from '@/utils'; export type GlobalHeaderRightProps = { menu?: boolean; }; const AvatarDropdown: React.FC = ({ menu }) => { const { initialState, setInitialState } = useModel('@@initialState'); const onMenuClick = useCallback( (event: MenuInfo) => { const { key } = event; if (key === 'logout') { setInitialState((s) => ({ ...s, currentUser: undefined })); localStorage.removeItem('userData'); loginOut(); return; } history.push(`/account/${key}`); }, [setInitialState], ); const loading = ( ); if (!initialState) { return loading; } const { currentUser } = initialState; if (!currentUser || !currentUser.name) { return loading; } const menuHeaderDropdown = ( {/* {menu && ( 个人中心 )} */} {menu && ( 个人设置 )} {menu && } 退出登录 ); return ( {currentUser.name} ); }; export default AvatarDropdown;