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

@@ -1,29 +1,23 @@
import React, { Component } from 'react'
export default class Container extends Component {
getMode(mode) {
const c = 'container'
switch (mode) {
case 'sm':
return c + '-sm'
case 'md':
return c + '-md'
case 'fluid':
return c + '-fluid'
default:
return c
const modes = ['xxs', 'xs', 'sm', 'md', 'fluid']
if (modes.includes(mode)) {
return `${c}-${mode}`
}
return c
}
render() {
let className = this.getMode(this.props.mode)
if (this.props.className) {
className += ` ${this.props.className}`
const { mode, className, children } = this.props
let containerName = this.getMode(mode)
if (className) {
containerName = [containerName, className].join(' ')
}
return (
<section className={className}>{this.props.children}</section>
)
return <section className={containerName}>{children}</section>
}
}

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="" />
}
}
}

View File

@@ -1,4 +1,4 @@
export { default as AntIcon } from 'components/ant-icon'
export { default as AntIcon } from './ant-icon'
export { default as AuthorityView } from './authority-view'
export { default as Auth } from './authorized'
export { default as ColorSelector } from './form/color-selector'