From 522ec422103dbc67c95fcddec8407d6bf8e75424 Mon Sep 17 00:00:00 2001 From: ddcat1115 Date: Tue, 13 Mar 2018 01:21:16 +0800 Subject: [PATCH] individual url #1072 --- src/common/router.js | 11 +- src/routes/Account/Center/Applications.js | 67 +++++++ src/routes/Account/Center/Articles.js | 57 ++++++ src/routes/Account/Center/Articles.less | 7 + src/routes/Account/Center/Center.js | 213 ++++++++++++++++++++++ src/routes/Account/Center/Center.less | 96 ++++++++++ src/routes/Account/Center/Projects.js | 47 +++++ 7 files changed, 497 insertions(+), 1 deletion(-) create mode 100644 src/routes/Account/Center/Applications.js create mode 100644 src/routes/Account/Center/Articles.js create mode 100644 src/routes/Account/Center/Articles.less create mode 100644 src/routes/Account/Center/Center.js create mode 100644 src/routes/Account/Center/Center.less create mode 100644 src/routes/Account/Center/Projects.js diff --git a/src/common/router.js b/src/common/router.js index fe822611..b90b9b24 100644 --- a/src/common/router.js +++ b/src/common/router.js @@ -164,7 +164,16 @@ export const getRouterData = (app) => { component: dynamicWrapper(app, [], () => import('../routes/User/RegisterResult')), }, '/account/center': { - component: dynamicWrapper(app, ['list', 'user', 'project'], () => import('../routes/Account/Center')), + component: dynamicWrapper(app, ['list', 'user', 'project'], () => import('../routes/Account/Center/Center')), + }, + '/account/center/articles': { + component: dynamicWrapper(app, [], () => import('../routes/Account/Center/Articles')), + }, + '/account/center/applications': { + component: dynamicWrapper(app, [], () => import('../routes/Account/Center/Applications')), + }, + '/account/center/projects': { + component: dynamicWrapper(app, [], () => import('../routes/Account/Center/Projects')), }, '/account/settings': { component: dynamicWrapper(app, ['geographic'], () => import('../routes/Account/Settings/Info')), diff --git a/src/routes/Account/Center/Applications.js b/src/routes/Account/Center/Applications.js new file mode 100644 index 00000000..2e042b7f --- /dev/null +++ b/src/routes/Account/Center/Applications.js @@ -0,0 +1,67 @@ +import React from 'react'; +import { List, Card, Icon, Dropdown, Menu, Avatar, Tooltip } from 'antd'; +import numeral from 'numeral'; +import { formatWan } from '../../../utils/utils'; +import stylesApplications from '../../List/Applications.less'; + +export default (props) => { + const { list } = props; + const itemMenu = ( + + + 1st menu item + + + 2nd menu item + + + 3d menu item + + + ); + const CardInfo = ({ activeUser, newUser }) => ( +
+
+

活跃用户

+

{activeUser}

+
+
+

新增用户

+

{newUser}

+
+
+ ); + return ( + ( + + , + , + , + , + ]} + > + } + title={item.title} + /> +
+ +
+
+
+ )} + /> + ); +}; diff --git a/src/routes/Account/Center/Articles.js b/src/routes/Account/Center/Articles.js new file mode 100644 index 00000000..98bbccef --- /dev/null +++ b/src/routes/Account/Center/Articles.js @@ -0,0 +1,57 @@ +import React from 'react'; +import { List, Icon, Avatar, Tag } from 'antd'; +import moment from 'moment'; +import stylesArticles from '../../List/Articles.less'; +import styles from './Articles.less'; + +export default (props) => { + const { list } = props; + const IconText = ({ type, text }) => ( + + + {text} + + ); + const ListContent = ({ data: { content, updatedAt, avatar, owner, href } }) => ( +
+
{content}
+
+ {owner} 发布在 {href} + {moment(updatedAt).format('YYYY-MM-DD HH:mm')} +
+
+ ); + return ( + ( + , + , + , + ]} + > + {item.title} + )} + description={ + + Ant Design + 设计语言 + 蚂蚁金服 + + } + /> + + + )} + /> + ); +}; diff --git a/src/routes/Account/Center/Articles.less b/src/routes/Account/Center/Articles.less new file mode 100644 index 00000000..36cdd0c3 --- /dev/null +++ b/src/routes/Account/Center/Articles.less @@ -0,0 +1,7 @@ +.articleList { + :global { + .ant-list-item:first-child { + padding-top: 0; + } + } +} diff --git a/src/routes/Account/Center/Center.js b/src/routes/Account/Center/Center.js new file mode 100644 index 00000000..28868d1c --- /dev/null +++ b/src/routes/Account/Center/Center.js @@ -0,0 +1,213 @@ +import React, { PureComponent } from 'react'; +import { connect } from 'dva'; +import { Link, routerRedux, Route, Switch, Redirect } from 'dva/router'; +import { Card, Row, Col, Icon, Avatar, Tag, Divider, Spin, Input } from 'antd'; +import { getRoutes } from '../../../utils/utils'; +import styles from './Center.less'; + +@connect(({ list, loading, user, project }) => ({ + list, + listLoading: loading.effects['list/fetch'], + currentUser: user.currentUser, + currentUserLoading: loading.effects['user/fetchCurrent'], + project, + projectLoading: loading.effects['project/fetchNotice'], +})) +export default class Center extends PureComponent { + state = { + newTags: [], + inputVisible: false, + inputValue: '', + } + + componentDidMount() { + const { dispatch } = this.props; + this.props.dispatch({ + type: 'user/fetchCurrent', + }); + dispatch({ + type: 'list/fetch', + payload: { + count: 8, + }, + }); + dispatch({ + type: 'project/fetchNotice', + }); + } + + onTabChange = (key) => { + const { dispatch, match } = this.props; + switch (key) { + case 'articles': + dispatch(routerRedux.push(`${match.url}/articles`)); + break; + case 'applications': + dispatch(routerRedux.push(`${match.url}/applications`)); + break; + case 'projects': + dispatch(routerRedux.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 { list: { list }, listLoading, currentUser, currentUserLoading, + project: { notice }, projectLoading, match, routerData, location } = this.props; + const routes = getRoutes(match.path, routerData); + + 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...' + } +
+ + + + + { + routes.map(item => + ( + ( + + )} + exact={item.exact} + /> + ) + ) + } + + + + + +
+
+ ); + } +} diff --git a/src/routes/Account/Center/Center.less b/src/routes/Account/Center/Center.less new file mode 100644 index 00000000..1d673838 --- /dev/null +++ b/src/routes/Account/Center/Center.less @@ -0,0 +1,96 @@ +@import '~antd/lib/style/themes/default.less'; +@import "../../../utils/utils.less"; + +.avatarHolder { + text-align: center; + margin-bottom: 24px; + + & > img { + width: 104px; + height: 104px; + margin-bottom: 20px; + } + + .name { + font-size: 20px; + line-height: 28px; + font-weight: 500; + color: @heading-color; + margin-bottom: 4px; + } +} + +.detail { + p { + margin-bottom: 8px; + padding-left: 26px; + position: relative; + + &:last-child { + margin-bottom: 0; + } + } + + i { + position: absolute; + height: 14px; + width: 14px; + left: 0; + top: 4px; + background: url(https://gw.alipayobjects.com/zos/rmsportal/pBjWzVAHnOOtAUvZmZfy.svg); + + &.title { + background-position: 0 0; + } + + &.group { + background-position: 0 -22px; + } + + &.address { + background-position: 0 -44px; + } + } +} + +.tagsTitle, .teamTitle { + font-weight: 500; + color: @heading-color; + margin-bottom: 12px; +} + +.tags { + :global { + .ant-tag { + margin-bottom: 8px; + } + } +} + +.team { + :global { + .ant-avatar { + margin-right: 12px; + } + } + + a { + display: block; + margin-bottom: 24px; + color: @text-color; + transition: color .3s; + .textOverflow(); + + &:hover { + color: @primary-color; + } + } +} + +.tabsCard { + :global { + .ant-card-head { + padding: 0 16px; + } + } +} diff --git a/src/routes/Account/Center/Projects.js b/src/routes/Account/Center/Projects.js new file mode 100644 index 00000000..cf1d9842 --- /dev/null +++ b/src/routes/Account/Center/Projects.js @@ -0,0 +1,47 @@ +import React from 'react'; +import { List, Card } from 'antd'; +import moment from 'moment'; +import AvatarList from '../../../components/AvatarList'; +import stylesProjects from '../../List/Projects.less'; + +export default (props) => { + const { list } = props; + return ( + ( + + } + > + {item.title}} + description={item.subDescription} + /> +
+ {moment(item.updatedAt).fromNow()} +
+ + { + item.members.map(member => ( + + )) + } + +
+
+
+
+ )} + /> + ); +}; -- GitLab