|
|
@@ -6,6 +6,7 @@ import { stringify } from 'querystring'
|
|
|
import HeaderDropdown from '../HeaderDropdown'
|
|
|
import styles from './index.less'
|
|
|
// import { outLogin } from '@/services/ant-design-pro/api';
|
|
|
+import { outLogin } from '@/services/api/login'
|
|
|
import type { MenuInfo } from 'rc-menu/lib/interface'
|
|
|
|
|
|
export type GlobalHeaderRightProps = {
|
|
|
@@ -34,16 +35,21 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
|
|
|
const { initialState, setInitialState } = useModel('@@initialState')
|
|
|
|
|
|
const onMenuClick = useCallback(
|
|
|
- (event: MenuInfo) => {
|
|
|
+ (event: {
|
|
|
+ key: React.Key
|
|
|
+ keyPath: React.Key[]
|
|
|
+ item: React.ReactInstance
|
|
|
+ domEvent: React.MouseEvent<HTMLElement>
|
|
|
+ }) => {
|
|
|
const { key } = event
|
|
|
- if (key === 'logout') {
|
|
|
- setInitialState(s => ({ ...s, currentUser: undefined }))
|
|
|
+ if (key === 'logout' && initialState) {
|
|
|
+ setInitialState({ ...initialState, currentUser: undefined })
|
|
|
loginOut()
|
|
|
return
|
|
|
}
|
|
|
history.push(`/account/${key}`)
|
|
|
},
|
|
|
- [setInitialState]
|
|
|
+ [initialState, setInitialState]
|
|
|
)
|
|
|
|
|
|
const loading = (
|
|
|
@@ -64,7 +70,7 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
|
|
|
|
|
|
const { currentUser } = initialState
|
|
|
|
|
|
- if (!currentUser || !currentUser.name) {
|
|
|
+ if (!currentUser || !currentUser.ID) {
|
|
|
return loading
|
|
|
}
|
|
|
|
|
|
@@ -93,7 +99,7 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
|
|
|
return (
|
|
|
<HeaderDropdown overlay={menuHeaderDropdown}>
|
|
|
<span className={`${styles.action} ${styles.account}`}>
|
|
|
- <Avatar size="small" className={styles.avatar} src={currentUser.avatar} alt="avatar" />
|
|
|
+ {/* <Avatar size="small" className={styles.avatar} src={currentUser.avatar} alt="avatar" /> */}
|
|
|
<span className={`${styles.name} anticon`}>{currentUser.name}</span>
|
|
|
</span>
|
|
|
</HeaderDropdown>
|