Kaynağa Gözat

'UserCenter头像增加fallback'

main
郑州 3 yıl önce
ebeveyn
işleme
64c392a5c8
1 değiştirilmiş dosya ile 21 ekleme ve 10 silme
  1. +21
    -10
      src/components/AppHeader/components/userCenter/UserCenter.tsx

+ 21
- 10
src/components/AppHeader/components/userCenter/UserCenter.tsx Dosyayı Görüntüle

@@ -1,4 +1,4 @@
import { useModel } from '@/.umi/plugin-model/useModel';
import { useModel } from 'umi';
import { confirm } from '@/components/AModal'; import { confirm } from '@/components/AModal';
import OssImage from '@/components/OssImage'; import OssImage from '@/components/OssImage';
import SvgIcon from '@/components/SvgIcon'; import SvgIcon from '@/components/SvgIcon';
@@ -10,6 +10,7 @@ import React, { CSSProperties } from 'react';
import { useCallback } from 'react'; import { useCallback } from 'react';
import { useState } from 'react'; import { useState } from 'react';
import styles from './UserCenter.less'; import styles from './UserCenter.less';
import defaultAvatorImg from '@/assets/avator_default.svg';


interface UserCenterProps { interface UserCenterProps {
className?: string; className?: string;
@@ -22,7 +23,7 @@ export default function UserCenter(props: UserCenterProps) {


const onVisibleChange = useCallback((nextVisible) => { const onVisibleChange = useCallback((nextVisible) => {
setPopVisible(nextVisible); setPopVisible(nextVisible);
}, [])
}, []);


return ( return (
<Popover <Popover
@@ -35,10 +36,13 @@ export default function UserCenter(props: UserCenterProps) {
arrowContent={() => null} arrowContent={() => null}
> >
<Button type="link" className={classNames(styles.btn, className)}> <Button type="link" className={classNames(styles.btn, className)}>
<SvgIcon className={classNames(styles.icon, popVisible ? styles.active : '')} xlinkHref="usercenter" />
<SvgIcon
className={classNames(styles.icon, popVisible ? styles.active : '')}
xlinkHref="usercenter"
/>
</Button> </Button>
</Popover> </Popover>
)
);
} }


function PopContent(props) { function PopContent(props) {
@@ -51,8 +55,8 @@ function PopContent(props) {
logout(); logout();
}, },
content: '确实退出登录?', content: '确实退出登录?',
})
}, [])
});
}, []);
return ( return (
<div className={styles.popView}> <div className={styles.popView}>
<div className={styles.popHeader}> <div className={styles.popHeader}>
@@ -61,7 +65,12 @@ function PopContent(props) {
<div className={styles.phone}>{currentUser?.phone}</div> <div className={styles.phone}>{currentUser?.phone}</div>
</div> </div>
<div className={styles.right}> <div className={styles.right}>
<OssImage className={styles.avator} src={currentUser?.headImgUrl} preview={false} />
<OssImage
className={styles.avator}
src={currentUser?.headImgUrl}
preview={false}
fallback={defaultAvatorImg}
/>
</div> </div>
</div> </div>
<div className={styles.popContent}> <div className={styles.popContent}>
@@ -84,9 +93,11 @@ function PopContent(props) {
<RightOutlined color="#8E909F" /> <RightOutlined color="#8E909F" />
</div> */} </div> */}
<div className={styles.btnGroup}> <div className={styles.btnGroup}>
<Button className={styles.logout} type="link" onClick={tryLogout}>退出登录</Button>
<Button className={styles.logout} type="link" onClick={tryLogout}>
退出登录
</Button>
</div> </div>
</div> </div>
</div> </div>
)
}
);
}

Yükleniyor…
İptal
Kaydet