update 个人中心

This commit is contained in:
2021-06-30 20:16:35 +08:00
parent 3b9def0895
commit 8d3352a55a
18 changed files with 1277 additions and 1220 deletions

View File

@@ -3,7 +3,7 @@ import { Avatar } from 'antd'
import { isEqual } from 'lodash'
import { PreviewFileBase64 } from 'util/file'
const getSrc = async (id) => {
const getSrc = async id => {
if (id) {
const base64 = await PreviewFileBase64(id)
return base64
@@ -12,9 +12,8 @@ const getSrc = async (id) => {
}
export default class Image extends Component {
state = {
src: ''
src: '',
}
id = ''
@@ -25,9 +24,9 @@ export default class Image extends Component {
this.setSrc()
}
shouldComponentUpdate(props) {
shouldComponentUpdate(props, state) {
// props变更或state.src变更时进行渲染
return !isEqual(this.props, props) || !this.state.src
return !isEqual(this.props, props) || this.state.src !== state.src
}
componentDidUpdate() {
@@ -46,13 +45,9 @@ export default class Image extends Component {
render() {
if (this.props.type === 'avatar') {
return (
<Avatar src={this.state.src} {...this.props} />
)
return <Avatar src={this.state.src} {...this.props} />
} else {
return (
<img src={this.state.src} {...this.props} alt="" />
)
return <img src={this.state.src} {...this.props} alt="" />
}
}
}