import React, { PureComponent } from 'react'; import { connect } from 'dva'; import Link from 'umi/link'; import { Card, Row, Col, Icon, Avatar, Tag, Divider, Input } from 'antd'; import styles from './Center.less'; const operationTabList = [ { key: 'articles', tab: ( 文章 (8) ), }, { key: 'applications', tab: ( 应用 (8) ), }, { key: 'projects', tab: ( 项目 (8) ), }, ]; @connect(({ loading, BLOCK_NAME_CAMEL_CASE }) => ({ currentUser: BLOCK_NAME_CAMEL_CASE.currentUser, currentUserLoading: loading.effects['BLOCK_NAME_CAMEL_CASE/fetchCurrent'], })) class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent { static getDerivedStateFromProps(props, state) { const { match, location } = props; const { tabKey } = state; const urlTabKey = location.pathname.replace(`${match.path}/`, ''); if (urlTabKey && urlTabKey !== '/' && tabKey !== urlTabKey) { return { tabKey: urlTabKey, }; } return null; } state = { newTags: [], inputVisible: false, inputValue: '', tabKey: 'articles', }; componentDidMount() { const { dispatch } = this.props; dispatch({ type: 'BLOCK_NAME_CAMEL_CASE/fetchCurrent', }); } onTabChange = key => { // If you need to sync state to url // const { match } = this.props; // router.push(`${match.url}/${key}`); this.setState({ tabKey: key, }); }; showInput = () => { this.setState({ inputVisible: true }, () => this.input.focus()); }; saveInputRef = input => { this.input = input; }; handleInputChange = e => { this.setState({ inputValue: e.target.value }); }; handleInputConfirm = () => { const { state } = this; const { inputValue } = state; let { newTags } = state; if (inputValue && newTags.filter(tag => tag.label === inputValue).length === 0) { newTags = [...newTags, { key: `new-${newTags.length}`, label: inputValue }]; } this.setState({ newTags, inputVisible: false, inputValue: '', }); }; render() { const { newTags, inputVisible, inputValue, tabKey } = this.state; const { currentUser, currentUserLoading, children } = this.props; const dataLoading = currentUserLoading || !(currentUser && Object.keys(currentUser).length); return ( {!dataLoading ? ( {currentUser.name} {currentUser.signature} {currentUser.title} {currentUser.group} {currentUser.geographic.province.label} {currentUser.geographic.city.label} 标签 {currentUser.tags.concat(newTags).map(item => ( {item.label} ))} {inputVisible && ( )} {!inputVisible && ( )} 团队 {currentUser.notice.map(item => ( {item.member} ))} ) : null} {children || tabKey} ); } } export default PAGE_NAME_UPPER_CAMEL_CASE;
{currentUser.title}
{currentUser.group}
{currentUser.geographic.province.label} {currentUser.geographic.city.label}