Commit 293ea3d5 authored by 陈帅's avatar 陈帅

fix ts error

parent c08aa5ba
import React, { PureComponent, createElement } from 'react'; import React, { PureComponent, createElement } from 'react';
import PropTypes, { string } from 'prop-types';
import { Button } from 'antd'; import { Button } from 'antd';
import styles from './index.less'; import styles from './index.less';
export interface EditableLink { export interface EditableLink {
title: string; title: string;
href: string; href: string;
id?: string;
} }
interface EditableLinkGroupProps { interface EditableLinkGroupProps {
onAdd: () => void; onAdd: () => void;
links: EditableLink[]; links: EditableLink[];
linkElement: React.Component; linkElement: React.ComponentClass<any>;
} }
class EditableLinkGroup extends PureComponent<EditableLinkGroupProps> { class EditableLinkGroup extends PureComponent<EditableLinkGroupProps> {
static propTypes = {
links: PropTypes.array,
onAdd: PropTypes.func,
linkElement: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
};
static defaultProps = { static defaultProps = {
links: [], links: [],
onAdd: () => {}, onAdd: () => {},
......
...@@ -12,7 +12,7 @@ export interface IRadarProps { ...@@ -12,7 +12,7 @@ export interface IRadarProps {
data: Array<{ data: Array<{
name: string; name: string;
label: string; label: string;
value: string; value: string | number;
}>; }>;
colors?: string[]; colors?: string[];
animate?: boolean; animate?: boolean;
......
...@@ -3,22 +3,22 @@ export interface ITag { ...@@ -3,22 +3,22 @@ export interface ITag {
label: string; label: string;
} }
export interface Province { export interface IProvince {
label: string; label: string;
key: string; key: string;
} }
export interface City { export interface ICity {
label: string; label: string;
key: string; key: string;
} }
export interface Geographic { export interface Geographic {
province: Province; province: IProvince;
city: City; city: ICity;
} }
export interface Notice { export interface INotice {
id: string; id: string;
title: string; title: string;
logo: string; logo: string;
...@@ -29,11 +29,11 @@ export interface Notice { ...@@ -29,11 +29,11 @@ export interface Notice {
memberLink: string; memberLink: string;
} }
export interface CurrentUser { export interface ICurrentUser {
name: string; name: string;
avatar: string; avatar: string;
userid: string; userid: string;
notice: Notice[]; notice: INotice[];
email: string; email: string;
signature: string; signature: string;
title: string; title: string;
...@@ -47,31 +47,31 @@ export interface CurrentUser { ...@@ -47,31 +47,31 @@ export interface CurrentUser {
phone: string; phone: string;
} }
export interface Member { export interface IMember {
avatar: string; avatar: string;
name: string; name: string;
id: string; id: string;
} }
export interface Activeties { export interface IActivities {
id: string, id: string;
updatedAt: string, updatedAt: string;
user: { user: {
name: string, name: string;
avatar: string, avatar: string;
}, };
group: { group: {
name: string, name: string;
link: string, link: string;
}, };
project: { project: {
name: string, name: string;
link: string, link: string;
}, };
template: string, template: string;
} }
export interface RadarData { export interface IRadarData {
label: string; label: string;
name: string; name: string;
value: number; value: number;
......
...@@ -5,12 +5,11 @@ import Link from 'umi/link'; ...@@ -5,12 +5,11 @@ import Link from 'umi/link';
import { Row, Col, Card, List, Avatar } from 'antd'; import { Row, Col, Card, List, Avatar } from 'antd';
import { Dispatch } from 'redux'; import { Dispatch } from 'redux';
import EditableLinkGroup from './components/EditableLinkGroup'; import EditableLinkGroup from './components/EditableLinkGroup';
import PageHeaderWrapper from './components/PageHeaderWrapper'; import PageHeaderWrapper from './components/PageHeaderWrapper';
import Radar from './components/Radar'; import Radar from './components/Radar';
import { ModalState } from './model'; import { ModalState } from './model';
import { CurrentUser, Activeties, RadarData, Notice } from './data'; import { ICurrentUser, IActivities, IRadarData, INotice } from './data';
import styles from './style.less'; import styles from './style.less';
...@@ -42,23 +41,24 @@ const links = [ ...@@ -42,23 +41,24 @@ const links = [
]; ];
interface BLOCK_NAME_CAMEL_CASEProps { interface BLOCK_NAME_CAMEL_CASEProps {
currentUser: CurrentUser; currentUser: ICurrentUser;
projectNotice: Notice[]; projectNotice: INotice[];
activities: Activeties[]; activities: IActivities[];
radarData: RadarData[]; radarData: IRadarData[];
dispatch: Dispatch; dispatch: Dispatch;
currentUserLoading: boolean; currentUserLoading: boolean;
projectLoading: boolean; projectLoading: boolean;
activitiesLoading: boolean; activitiesLoading: boolean;
} }
@connect(({ @connect(
({
BLOCK_NAME_CAMEL_CASE: { currentUser, projectNotice, activities, radarData }, BLOCK_NAME_CAMEL_CASE: { currentUser, projectNotice, activities, radarData },
loading, loading,
}: { }: {
BLOCK_NAME_CAMEL_CASE: ModalState, BLOCK_NAME_CAMEL_CASE: ModalState;
loading: { effects: any }, loading: { effects: any };
}) => ({ }) => ({
currentUser, currentUser,
projectNotice, projectNotice,
activities, activities,
...@@ -66,7 +66,8 @@ interface BLOCK_NAME_CAMEL_CASEProps { ...@@ -66,7 +66,8 @@ interface BLOCK_NAME_CAMEL_CASEProps {
currentUserLoading: loading.effects['BLOCK_NAME_CAMEL_CASE/fetchUserCurrent'], currentUserLoading: loading.effects['BLOCK_NAME_CAMEL_CASE/fetchUserCurrent'],
projectLoading: loading.effects['BLOCK_NAME_CAMEL_CASE/fetchProjectNotice'], projectLoading: loading.effects['BLOCK_NAME_CAMEL_CASE/fetchProjectNotice'],
activitiesLoading: loading.effects['BLOCK_NAME_CAMEL_CASE/fetchActivitiesList'], activitiesLoading: loading.effects['BLOCK_NAME_CAMEL_CASE/fetchActivitiesList'],
})) })
)
class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent<BLOCK_NAME_CAMEL_CASEProps> { class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent<BLOCK_NAME_CAMEL_CASEProps> {
componentDidMount() { componentDidMount() {
const { dispatch } = this.props; const { dispatch } = this.props;
...@@ -82,11 +83,7 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent<BLOCK_NAME_CAMEL_CASEProp ...@@ -82,11 +83,7 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent<BLOCK_NAME_CAMEL_CASEProp
}); });
} }
renderActivities() { renderActivities(item: IActivities) {
const {
activities,
} = this.props;
return activities.map(item => {
const events = item.template.split(/@\{([^{}]*)\}/gi).map(key => { const events = item.template.split(/@\{([^{}]*)\}/gi).map(key => {
if (item[key]) { if (item[key]) {
return ( return (
...@@ -116,12 +113,12 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent<BLOCK_NAME_CAMEL_CASEProp ...@@ -116,12 +113,12 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent<BLOCK_NAME_CAMEL_CASEProp
/> />
</List.Item> </List.Item>
); );
});
} }
render() { render() {
const { const {
currentUser, currentUser,
activities,
projectNotice, projectNotice,
projectLoading, projectLoading,
activitiesLoading, activitiesLoading,
...@@ -167,10 +164,7 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent<BLOCK_NAME_CAMEL_CASEProp ...@@ -167,10 +164,7 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent<BLOCK_NAME_CAMEL_CASEProp
); );
return ( return (
<PageHeaderWrapper <PageHeaderWrapper content={pageHeaderContent} extraContent={extraContent}>
content={pageHeaderContent}
extraContent={extraContent}
>
<Row gutter={24}> <Row gutter={24}>
<Col xl={16} lg={24} md={24} sm={24} xs={24}> <Col xl={16} lg={24} md={24} sm={24} xs={24}>
<Card <Card
...@@ -213,9 +207,15 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent<BLOCK_NAME_CAMEL_CASEProp ...@@ -213,9 +207,15 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent<BLOCK_NAME_CAMEL_CASEProp
title="动态" title="动态"
loading={activitiesLoading} loading={activitiesLoading}
> >
<List loading={activitiesLoading} size="large"> <List<IActivities>
<div className={styles.activitiesList}>{this.renderActivities()}</div> loading={activitiesLoading}
</List> renderItem={item => {
return this.renderActivities(item);
}}
dataSource={activities}
className={styles.activitiesList}
size="large"
/>
</Card> </Card>
</Col> </Col>
<Col xl={8} lg={24} md={24} sm={24} xs={24}> <Col xl={8} lg={24} md={24} sm={24} xs={24}>
......
{ {
"private": true, "private": true,
"scripts": { "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": "eslint --ext .js src mock tests && npm run lint:style",
"lint-staged": "lint-staged", "lint-staged": "lint-staged",
"lint-staged:js": "eslint --ext .js", "lint-staged:js": "eslint --ext .js",
......
...@@ -22,6 +22,6 @@ ...@@ -22,6 +22,6 @@
"@/*": ["./src/*"] "@/*": ["./src/*"]
} }
}, },
"include": ["."], "include": [".", "./typings.d"],
"exclude": ["node_modules", "_scripts", "jest", "tslint:latest", "tslint-config-prettier"] "exclude": ["node_modules", "_scripts", "jest", "tslint:latest", "tslint-config-prettier"]
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment