From 293ea3d52ee07c4ac2a58a8e57f7f4fe8ca44898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Tue, 30 Apr 2019 11:03:22 +0800 Subject: [PATCH] fix ts error --- .../components/EditableLinkGroup/index.tsx | 10 +- Workplace/src/components/Radar/index.tsx | 2 +- Workplace/src/data.d.ts | 44 +++---- Workplace/src/index.tsx | 124 +++++++++--------- package.json | 2 +- tsconfig.json | 2 +- 6 files changed, 89 insertions(+), 95 deletions(-) diff --git a/Workplace/src/components/EditableLinkGroup/index.tsx b/Workplace/src/components/EditableLinkGroup/index.tsx index 122a0186..3e346204 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 555da2da..76cdc520 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 36514554..b2bf5317 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 5eb1d986..4b98fb6e 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 4bf8aeb4..1fcefc33 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 c9377ebc..cb01f0cb 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"] } -- GitLab