Add renderAvatar().

This commit is contained in:
Yang Luo
2021-03-28 21:18:41 +08:00
parent d6c8bb87c2
commit cc8485a7db

View File

@ -142,7 +142,7 @@ class App extends Component {
account: null account: null
}); });
Setting.showMessage("success", `Successfully logged out, redirected to homepage`); Setting.showMessage("success", `Logged out successfully`);
Setting.goToLinkSoft(this, "/"); Setting.goToLinkSoft(this, "/");
} else { } else {
@ -159,6 +159,22 @@ class App extends Component {
} }
} }
renderAvatar() {
if (this.state.account.avatar === "") {
return (
<Avatar style={{ backgroundColor: Setting.getAvatarColor(this.state.account.name), verticalAlign: 'middle' }} size="large">
{Setting.getShortName(this.state.account.name)}
</Avatar>
)
} else {
return (
<Avatar src={this.state.account.avatar} style={{verticalAlign: 'middle' }} size="large">
{Setting.getShortName(this.state.account.name)}
</Avatar>
)
}
}
renderRightDropdown() { renderRightDropdown() {
const menu = ( const menu = (
<Menu onClick={this.handleRightDropdownClick.bind(this)}> <Menu onClick={this.handleRightDropdownClick.bind(this)}>
@ -176,9 +192,9 @@ class App extends Component {
return ( return (
<Dropdown key="200" overlay={menu} > <Dropdown key="200" overlay={menu} >
<div className="ant-dropdown-link" style={{float: 'right', cursor: 'pointer'}}> <div className="ant-dropdown-link" style={{float: 'right', cursor: 'pointer'}}>
<Avatar style={{ backgroundColor: Setting.getAvatarColor(this.state.account.name), verticalAlign: 'middle' }} size="large"> {
{Setting.getShortName(this.state.account.name)} this.renderAvatar()
</Avatar> }
&nbsp; &nbsp;
&nbsp; &nbsp;
{Setting.isMobile() ? null : Setting.getShortName(this.state.account.name)} &nbsp; <DownOutlined /> {Setting.isMobile() ? null : Setting.getShortName(this.state.account.name)} &nbsp; <DownOutlined />