import React, { PureComponent } from 'react'; import { connect } from 'dva'; import Link from 'umi/link'; import router from 'umi/router'; import { Card, Row, Col, Icon, Avatar, Tag, Divider, Spin, Input } from 'antd'; import GridContent from '@/components/PageHeaderWrapper/GridContent'; import styles from './Center.less'; @connect(({ loading, user, project }) => ({ listLoading: loading.effects['list/fetch'], currentUser: user.currentUser, currentUserLoading: loading.effects['user/fetchCurrent'], project, projectLoading: loading.effects['project/fetchNotice'], })) class Center extends PureComponent { state = { newTags: [], inputVisible: false, inputValue: '', }; componentDidMount() { const { dispatch } = this.props; dispatch({ type: 'user/fetchCurrent', }); dispatch({ type: 'list/fetch', payload: { count: 8, }, }); dispatch({ type: 'project/fetchNotice', }); } onTabChange = key => { const { match } = this.props; switch (key) { case 'articles': router.push(`${match.url}/articles`); break; case 'applications': router.push(`${match.url}/applications`); break; case 'projects': router.push(`${match.url}/projects`); break; default: break; } }; 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 } = this.state; const { listLoading, currentUser, currentUserLoading, project: { notice }, projectLoading, match, location, children, } = this.props; const operationTabList = [ { key: 'articles', tab: ( 文章 (8) ), }, { key: 'applications', tab: ( 应用 (8) ), }, { key: 'projects', tab: ( 项目 (8) ), }, ]; return ( {currentUser && Object.keys(currentUser).length ? ( {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 && ( )} 团队 {notice.map(item => ( {item.member} ))} ) : ( 'loading...' )} {children} ); } } export default Center;
{currentUser.title}
{currentUser.group}
{currentUser.geographic.province.label} {currentUser.geographic.city.label}