提交 9873d3fc197933f063f186c87932af79e51d5028

作者 愚道
1 个父辈 2a7bf1bd

improve workspace code

@@ -244,13 +244,13 @@ radarOriginData.forEach(item => { @@ -244,13 +244,13 @@ radarOriginData.forEach(item => {
244 }); 244 });
245 245
246 export default { 246 export default {
247 - 'GET /api/project/notice': getNotice,  
248 - 'GET /api/activities': getActivities,  
249 - 'GET /api/fake_chart_data': { 247 + 'GET /api/BLOCK_NAME/project/notice': getNotice,
  248 + 'GET /api/BLOCK_NAME/activities': getActivities,
  249 + 'GET /api/BLOCK_NAME/fake_chart_data': {
250 radarData, 250 radarData,
251 }, 251 },
252 252
253 - 'GET /api/currentUser': { 253 + 'GET /api/BLOCK_NAME/currentUser': {
254 name: 'Serati Ma', 254 name: 'Serati Ma',
255 avatar: 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png', 255 avatar: 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png',
256 userid: '00000001', 256 userid: '00000001',
@@ -4,9 +4,8 @@ import Link from 'umi/link'; @@ -4,9 +4,8 @@ import Link from 'umi/link';
4 import { PageHeader } from 'ant-design-pro'; 4 import { PageHeader } from 'ant-design-pro';
5 import styles from './index.less'; 5 import styles from './index.less';
6 6
7 -const PageHeaderWrapper = ({ children, contentWidth, wrapperClassName, top, ...restProps }) => ( 7 +const PageHeaderWrapper = ({ children, contentWidth, wrapperClassName, ...restProps }) => (
8 <div style={{ margin: '-24px -24px 0' }} className={wrapperClassName}> 8 <div style={{ margin: '-24px -24px 0' }} className={wrapperClassName}>
9 - {top}  
10 <PageHeader 9 <PageHeader
11 wide={contentWidth === 'Fixed'} 10 wide={contentWidth === 'Fixed'}
12 home={<FormattedMessage id="menu.home" defaultMessage="Home" />} 11 home={<FormattedMessage id="menu.home" defaultMessage="Home" />}
@@ -39,27 +39,27 @@ const links = [ @@ -39,27 +39,27 @@ const links = [
39 }, 39 },
40 ]; 40 ];
41 41
42 -@connect(({ workplace: { user, project, activities, chart }, loading }) => ({ 42 +@connect(({ BLOCK_NAME_CAMEL_CASE: { user, project, activities, chart }, loading }) => ({
43 currentUser: user.currentUser, 43 currentUser: user.currentUser,
44 project, 44 project,
45 activities, 45 activities,
46 chart, 46 chart,
47 - currentUserLoading: loading.effects['workplace/fetchUserCurrent'],  
48 - projectLoading: loading.effects['workplace/fetchProjectNotice'],  
49 - activitiesLoading: loading.effects['workplace/fetchActivitiesList'], 47 + currentUserLoading: loading.effects['BLOCK_NAME_CAMEL_CASE/fetchUserCurrent'],
  48 + projectLoading: loading.effects['BLOCK_NAME_CAMEL_CASE/fetchProjectNotice'],
  49 + activitiesLoading: loading.effects['BLOCK_NAME_CAMEL_CASE/fetchActivitiesList'],
50 })) 50 }))
51 -class Workplace extends PureComponent { 51 +class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent {
52 componentDidMount() { 52 componentDidMount() {
53 const { dispatch } = this.props; 53 const { dispatch } = this.props;
54 dispatch({ 54 dispatch({
55 - type: 'workplace/init', 55 + type: 'BLOCK_NAME_CAMEL_CASE/init',
56 }); 56 });
57 } 57 }
58 58
59 componentWillUnmount() { 59 componentWillUnmount() {
60 const { dispatch } = this.props; 60 const { dispatch } = this.props;
61 dispatch({ 61 dispatch({
62 - type: 'chart/clear', 62 + type: 'BLOCK_NAME_CAMEL_CASE/clear',
63 }); 63 });
64 } 64 }
65 65
@@ -246,4 +246,4 @@ class Workplace extends PureComponent { @@ -246,4 +246,4 @@ class Workplace extends PureComponent {
246 } 246 }
247 } 247 }
248 248
249 -export default Workplace; 249 +export default PAGE_NAME_UPPER_CAMEL_CASE;
1 import { queryCurrent, queryProjectNotice, queryActivities, fakeChartData } from './service'; 1 import { queryCurrent, queryProjectNotice, queryActivities, fakeChartData } from './service';
2 2
3 export default { 3 export default {
4 - namespace: 'workplace', 4 + namespace: 'BLOCK_NAME_CAMEL_CASE',
5 state: { 5 state: {
6 user: { 6 user: {
7 currentUser: {}, 7 currentUser: {},
1 import request from 'umi-request'; 1 import request from 'umi-request';
2 2
3 export async function queryProjectNotice() { 3 export async function queryProjectNotice() {
4 - return request('/api/project/notice'); 4 + return request('/api/BLOCK_NAME/project/notice');
5 } 5 }
6 6
7 export async function queryActivities() { 7 export async function queryActivities() {
8 - return request('/api/activities'); 8 + return request('/api/BLOCK_NAME/activities');
9 } 9 }
10 10
11 export async function fakeChartData() { 11 export async function fakeChartData() {
12 - return request('/api/fake_chart_data'); 12 + return request('/api/BLOCK_NAME/fake_chart_data');
13 } 13 }
14 14
15 export async function queryCurrent() { 15 export async function queryCurrent() {
16 - return request('/api/currentUser'); 16 + return request('/api/BLOCK_NAME/currentUser');
17 } 17 }
注册登录 后发表评论