diff --git a/Workplace/src/components/EditableLinkGroup/index.tsx b/Workplace/src/components/EditableLinkGroup/index.tsx index 122a0186801bc37bdc8193d00637f34357e9acf7..3e3462047c4624aa4cb350cfef8f552873f14686 100644 --- a/Workplace/src/components/EditableLinkGroup/index.tsx +++ b/Workplace/src/components/EditableLinkGroup/index.tsx @@ -1,26 +1,20 @@ import React, { PureComponent, createElement } from 'react'; -import PropTypes, { string } from 'prop-types'; import { Button } from 'antd'; import styles from './index.less'; export interface EditableLink { title: string; href: string; + id?: string; } interface EditableLinkGroupProps { onAdd: () => void; links: EditableLink[]; - linkElement: React.Component; + linkElement: React.ComponentClass; } class EditableLinkGroup extends PureComponent { - static propTypes = { - links: PropTypes.array, - onAdd: PropTypes.func, - linkElement: PropTypes.oneOfType([PropTypes.func, PropTypes.string]), - }; - static defaultProps = { links: [], onAdd: () => {}, diff --git a/Workplace/src/components/Radar/index.tsx b/Workplace/src/components/Radar/index.tsx index 555da2da57a93a26f7fb9e64113b8f98e60f5529..76cdc52087758633bd7df9e0a0da8517046ce374 100644 --- a/Workplace/src/components/Radar/index.tsx +++ b/Workplace/src/components/Radar/index.tsx @@ -12,7 +12,7 @@ export interface IRadarProps { data: Array<{ name: string; label: string; - value: string; + value: string | number; }>; colors?: string[]; animate?: boolean; diff --git a/Workplace/src/data.d.ts b/Workplace/src/data.d.ts index 36514554b311ab6b2f51fc68c5715d4559bf9f74..b2bf5317e55bc23fcedf0b133951a6bdcc69b2d1 100644 --- a/Workplace/src/data.d.ts +++ b/Workplace/src/data.d.ts @@ -3,22 +3,22 @@ export interface ITag { label: string; } -export interface Province { +export interface IProvince { label: string; key: string; } -export interface City { +export interface ICity { label: string; key: string; } export interface Geographic { - province: Province; - city: City; + province: IProvince; + city: ICity; } -export interface Notice { +export interface INotice { id: string; title: string; logo: string; @@ -29,11 +29,11 @@ export interface Notice { memberLink: string; } -export interface CurrentUser { +export interface ICurrentUser { name: string; avatar: string; userid: string; - notice: Notice[]; + notice: INotice[]; email: string; signature: string; title: string; @@ -47,31 +47,31 @@ export interface CurrentUser { phone: string; } -export interface Member { +export interface IMember { avatar: string; name: string; id: string; } -export interface Activeties { - id: string, - updatedAt: string, +export interface IActivities { + id: string; + updatedAt: string; user: { - name: string, - avatar: string, - }, + name: string; + avatar: string; + }; group: { - name: string, - link: string, - }, + name: string; + link: string; + }; project: { - name: string, - link: string, - }, - template: string, + name: string; + link: string; + }; + template: string; } -export interface RadarData { +export interface IRadarData { label: string; name: string; value: number; diff --git a/Workplace/src/index.tsx b/Workplace/src/index.tsx index 5eb1d9867c7167eb9b283a1c31d96ebe86361e92..4b98fb6ec5c5e793e328e18b755e38ee17a23604 100644 --- a/Workplace/src/index.tsx +++ b/Workplace/src/index.tsx @@ -5,12 +5,11 @@ import Link from 'umi/link'; import { Row, Col, Card, List, Avatar } from 'antd'; import { Dispatch } from 'redux'; - import EditableLinkGroup from './components/EditableLinkGroup'; import PageHeaderWrapper from './components/PageHeaderWrapper'; import Radar from './components/Radar'; import { ModalState } from './model'; -import { CurrentUser, Activeties, RadarData, Notice } from './data'; +import { ICurrentUser, IActivities, IRadarData, INotice } from './data'; import styles from './style.less'; @@ -42,31 +41,33 @@ const links = [ ]; interface BLOCK_NAME_CAMEL_CASEProps { - currentUser: CurrentUser; - projectNotice: Notice[]; - activities: Activeties[]; - radarData: RadarData[]; + currentUser: ICurrentUser; + projectNotice: INotice[]; + activities: IActivities[]; + radarData: IRadarData[]; dispatch: Dispatch; currentUserLoading: boolean; projectLoading: boolean; activitiesLoading: boolean; } -@connect(({ - BLOCK_NAME_CAMEL_CASE: { currentUser, projectNotice, activities, radarData }, - loading, -}: { - BLOCK_NAME_CAMEL_CASE: ModalState, - loading: { effects: any }, -}) => ({ - currentUser, - projectNotice, - activities, - radarData, - currentUserLoading: loading.effects['BLOCK_NAME_CAMEL_CASE/fetchUserCurrent'], - projectLoading: loading.effects['BLOCK_NAME_CAMEL_CASE/fetchProjectNotice'], - activitiesLoading: loading.effects['BLOCK_NAME_CAMEL_CASE/fetchActivitiesList'], -})) +@connect( + ({ + BLOCK_NAME_CAMEL_CASE: { currentUser, projectNotice, activities, radarData }, + loading, + }: { + BLOCK_NAME_CAMEL_CASE: ModalState; + loading: { effects: any }; + }) => ({ + currentUser, + projectNotice, + activities, + radarData, + currentUserLoading: loading.effects['BLOCK_NAME_CAMEL_CASE/fetchUserCurrent'], + projectLoading: loading.effects['BLOCK_NAME_CAMEL_CASE/fetchProjectNotice'], + activitiesLoading: loading.effects['BLOCK_NAME_CAMEL_CASE/fetchActivitiesList'], + }) +) class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent { componentDidMount() { const { dispatch } = this.props; @@ -82,46 +83,42 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent { - const events = item.template.split(/@\{([^{}]*)\}/gi).map(key => { - if (item[key]) { - return ( - - {item[key].name} - - ); - } - return key; - }); - return ( - - } - title={ - - {item.user.name} -   - {events} - - } - description={ - - {moment(item.updatedAt).fromNow()} - - } - /> - - ); + renderActivities(item: IActivities) { + const events = item.template.split(/@\{([^{}]*)\}/gi).map(key => { + if (item[key]) { + return ( + + {item[key].name} + + ); + } + return key; }); + return ( + + } + title={ + + {item.user.name} +   + {events} + + } + description={ + + {moment(item.updatedAt).fromNow()} + + } + /> + + ); } render() { const { currentUser, + activities, projectNotice, projectLoading, activitiesLoading, @@ -167,10 +164,7 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent + - -
{this.renderActivities()}
-
+ + loading={activitiesLoading} + renderItem={item => { + return this.renderActivities(item); + }} + dataSource={activities} + className={styles.activitiesList} + size="large" + />
diff --git a/package.json b/package.json index 4bf8aeb4dcded02a66dc6bc55c5aa5c415560346..1fcefc334414b5a97d382c8c4859ea685636df7b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "scripts": { - "dev": "cross-env PAGES_PATH='UserRegister/src' umi dev", + "dev": "cross-env PAGES_PATH='Workplace/src' umi dev", "lint": "eslint --ext .js src mock tests && npm run lint:style", "lint-staged": "lint-staged", "lint-staged:js": "eslint --ext .js", diff --git a/tsconfig.json b/tsconfig.json index c9377ebce581fde074c1a4619c24e5673f6523a6..cb01f0cbcd3d6b3ac5f9cbb73a515227ba67a3f1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,6 +22,6 @@ "@/*": ["./src/*"] } }, - "include": ["."], + "include": [".", "./typings.d"], "exclude": ["node_modules", "_scripts", "jest", "tslint:latest", "tslint-config-prettier"] }