|
|
@@ -25,10 +25,14 @@ export default function UserCenter(props: UserCenterProps) { |
|
|
|
setPopVisible(nextVisible); |
|
|
|
}, []); |
|
|
|
|
|
|
|
const onLogoutBtnClick = useCallback(() => { |
|
|
|
setPopVisible(false); |
|
|
|
}, []); |
|
|
|
|
|
|
|
return ( |
|
|
|
<Popover |
|
|
|
overlayClassName={styles.popWrapper} |
|
|
|
content={<PopContent />} |
|
|
|
content={<PopContent onLogoutBtnClick={onLogoutBtnClick} />} |
|
|
|
trigger="click" |
|
|
|
visible={popVisible} |
|
|
|
onVisibleChange={onVisibleChange} |
|
|
@@ -45,15 +49,20 @@ export default function UserCenter(props: UserCenterProps) { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
function PopContent(props) { |
|
|
|
interface PopContentProps { |
|
|
|
onLogoutBtnClick: () => void; |
|
|
|
} |
|
|
|
|
|
|
|
function PopContent(props: PopContentProps) { |
|
|
|
const { onLogoutBtnClick } = props; |
|
|
|
const { |
|
|
|
refresh, |
|
|
|
initialState: { currentUser } = {}, |
|
|
|
setInitialState, |
|
|
|
} = useModel('@@initialState'); |
|
|
|
console.log(currentUser); |
|
|
|
|
|
|
|
const tryLogout = useCallback(() => { |
|
|
|
if (onLogoutBtnClick) onLogoutBtnClick(); |
|
|
|
confirm({ |
|
|
|
onOk() { |
|
|
|
logout(); |
|
|
|