// 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 RenderDropDown = (menu: any) => {
  console.log(menu);
  return <div className={styles.dropdown}>
    <a key='1'>
      修改密码
    </a>

    <a key='2' href='/login'>
      退出登录
    </a>
  </div>
}

export default function UserDropdown(props: any) {
  const { initialState: { user } } = useModel('@@initialState');
  return (
    <div className={styles.root}>
      <Dropdown placement="top" dropdownRender={(menu) => RenderDropDown(menu)}>
        <a className={styles.action} onClick={(e) => e.preventDefault()}>
          <span className={styles.name}>{user?.CName}</span>
          <div className={styles.userIcon}></div>
        </a>
      </Dropdown>
    </div>
  );
}
