// src/layouts/index.tsx
import React from 'react';
import { Link } from 'umi';
import { Avatar, Dropdown, Menu, MenuProps } from 'antd';
import { LogoutOutlined, UserOutlined } from '@ant-design/icons';
import styles from './index.less';
import { useModel } from '@umijs/max';

const items: MenuProps['items'] = [
  {
    key: '1',
    label: <a href="/login">退出登录</a>,
    icon: <LogoutOutlined />,
  },
];

export default function UserDropdown(props: any) {
  const { user } = useModel('userInfo');
  return (
    <Dropdown placement="top" menu={{ items }}>
      <a className={styles.action} onClick={(e) => e.preventDefault()}>
        <Avatar icon={<UserOutlined />} />
        <span className={styles.name}>{user?.CName}</span>
      </a>
    </Dropdown>
  );
}
