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

fix ts error

parent c08aa5ba
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<any>;
}
class EditableLinkGroup extends PureComponent<EditableLinkGroupProps> {
static propTypes = {
links: PropTypes.array,
onAdd: PropTypes.func,
linkElement: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
};
static defaultProps = {
links: [],
onAdd: () => {},
......
......@@ -12,7 +12,7 @@ export interface IRadarProps {
data: Array<{
name: string;
label: string;
value: string;
value: string | number;
}>;
colors?: string[];
animate?: boolean;
......
......@@ -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;
......
......@@ -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<BLOCK_NAME_CAMEL_CASEProps> {
componentDidMount() {
const { dispatch } = this.props;
......@@ -82,46 +83,42 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent<BLOCK_NAME_CAMEL_CASEProp
});
}
renderActivities() {
const {
activities,
} = this.props;
return activities.map(item => {
const events = item.template.split(/@\{([^{}]*)\}/gi).map(key => {
if (item[key]) {
return (
<a href={item[key].link} key={item[key].name}>
{item[key].name}
</a>
);
}
return key;
});
return (
<List.Item key={item.id}>
<List.Item.Meta
avatar={<Avatar src={item.user.avatar} />}
title={
<span>
<a className={styles.username}>{item.user.name}</a>
&nbsp;
<span className={styles.event}>{events}</span>
</span>
}
description={
<span className={styles.datetime} title={item.updatedAt}>
{moment(item.updatedAt).fromNow()}
</span>
}
/>
</List.Item>
);
renderActivities(item: IActivities) {
const events = item.template.split(/@\{([^{}]*)\}/gi).map(key => {
if (item[key]) {
return (
<a href={item[key].link} key={item[key].name}>
{item[key].name}
</a>
);
}
return key;
});
return (
<List.Item key={item.id}>
<List.Item.Meta
avatar={<Avatar src={item.user.avatar} />}
title={
<span>
<a className={styles.username}>{item.user.name}</a>
&nbsp;
<span className={styles.event}>{events}</span>
</span>
}
description={
<span className={styles.datetime} title={item.updatedAt}>
{moment(item.updatedAt).fromNow()}
</span>
}
/>
</List.Item>
);
}
render() {
const {
currentUser,
activities,
projectNotice,
projectLoading,
activitiesLoading,
......@@ -167,10 +164,7 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent<BLOCK_NAME_CAMEL_CASEProp
);
return (
<PageHeaderWrapper
content={pageHeaderContent}
extraContent={extraContent}
>
<PageHeaderWrapper content={pageHeaderContent} extraContent={extraContent}>
<Row gutter={24}>
<Col xl={16} lg={24} md={24} sm={24} xs={24}>
<Card
......@@ -213,9 +207,15 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent<BLOCK_NAME_CAMEL_CASEProp
title="动态"
loading={activitiesLoading}
>
<List loading={activitiesLoading} size="large">
<div className={styles.activitiesList}>{this.renderActivities()}</div>
</List>
<List<IActivities>
loading={activitiesLoading}
renderItem={item => {
return this.renderActivities(item);
}}
dataSource={activities}
className={styles.activitiesList}
size="large"
/>
</Card>
</Col>
<Col xl={8} lg={24} md={24} sm={24} xs={24}>
......
{
"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",
......
......@@ -22,6 +22,6 @@
"@/*": ["./src/*"]
}
},
"include": ["."],
"include": [".", "./typings.d"],
"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