提交 4d6c7c8d82ff56c9ba60cccf08bb5c3f37ce023d

作者 愚道
1 个父辈 297fd08d

improve monitor block code

@@ -14,12 +14,8 @@ @@ -14,12 +14,8 @@
14 "ant-design-pro": "^2.1.1", 14 "ant-design-pro": "^2.1.1",
15 "antd": "^3.10.9", 15 "antd": "^3.10.9",
16 "dva": "^2.4.0", 16 "dva": "^2.4.0",
17 - "hash.js": "^1.1.5",  
18 "mockjs": "^1.0.1-beta3", 17 "mockjs": "^1.0.1-beta3",
19 - "moment": "^2.22.2",  
20 "numeral": "^2.0.6", 18 "numeral": "^2.0.6",
21 - "nzh": "^1.0.3",  
22 - "qs": "^6.6.0",  
23 "react": "^16.6.3", 19 "react": "^16.6.3",
24 "umi-request": "^1.0.0" 20 "umi-request": "^1.0.0"
25 }, 21 },
1 import mockjs from 'mockjs'; 1 import mockjs from 'mockjs';
2 2
3 export default { 3 export default {
4 - 'GET /api/tags': mockjs.mock({ 4 + 'GET /api/BLOCK_NAME/tags': mockjs.mock({
5 'list|100': [{ name: '@city', 'value|1-100': 150, 'type|0-2': 1 }], 5 'list|100': [{ name: '@city', 'value|1-100': 150, 'type|0-2': 1 }],
6 }), 6 }),
7 }; 7 };
1 import React, { Component } from 'react'; 1 import React, { Component } from 'react';
2 -import { MiniArea } from 'ant-design-pro/lib/Charts';  
3 -import NumberInfo from 'ant-design-pro/lib/NumberInfo'; 2 +import { Charts, NumberInfo } from 'ant-design-pro';
4 3
5 import styles from './index.less'; 4 import styles from './index.less';
6 5
  6 +const { MiniArea } = Charts;
  7 +
7 function fixedZero(val) { 8 function fixedZero(val) {
8 return val * 1 < 10 ? `0${val}` : val; 9 return val * 1 < 10 ? `0${val}` : val;
9 } 10 }
@@ -4,8 +4,8 @@ import { formatMessage, FormattedMessage } from 'umi/locale'; @@ -4,8 +4,8 @@ import { formatMessage, FormattedMessage } from 'umi/locale';
4 import { Row, Col, Card, Tooltip } from 'antd'; 4 import { Row, Col, Card, Tooltip } from 'antd';
5 import { NumberInfo, Charts } from 'ant-design-pro'; 5 import { NumberInfo, Charts } from 'ant-design-pro';
6 import CountDown from 'ant-design-pro/lib/CountDown'; 6 import CountDown from 'ant-design-pro/lib/CountDown';
7 -import ActiveChart from '@/components/ActiveChart';  
8 import numeral from 'numeral'; 7 import numeral from 'numeral';
  8 +import ActiveChart from './components/ActiveChart';
9 9
10 import styles from './style.less'; 10 import styles from './style.less';
11 11
@@ -13,21 +13,21 @@ const { Pie, WaterWave, Gauge, TagCloud } = Charts; @@ -13,21 +13,21 @@ const { Pie, WaterWave, Gauge, TagCloud } = Charts;
13 13
14 const targetTime = new Date().getTime() + 3900000; 14 const targetTime = new Date().getTime() + 3900000;
15 15
16 -@connect(({ monitor, loading }) => ({  
17 - monitor, 16 +@connect(({ BLOCK_NAME, loading }) => ({
  17 + BLOCK_NAME,
18 loading: loading.models.monitor, 18 loading: loading.models.monitor,
19 })) 19 }))
20 -class Monitor extends PureComponent { 20 +class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent {
21 componentDidMount() { 21 componentDidMount() {
22 const { dispatch } = this.props; 22 const { dispatch } = this.props;
23 dispatch({ 23 dispatch({
24 - type: 'monitor/fetchTags', 24 + type: 'BLOCK_NAME/fetchTags',
25 }); 25 });
26 } 26 }
27 27
28 render() { 28 render() {
29 - const { monitor, loading } = this.props;  
30 - const { tags } = monitor; 29 + const { BLOCK_NAME, loading } = this.props;
  30 + const { tags } = BLOCK_NAME;
31 31
32 return ( 32 return (
33 <React.Fragment> 33 <React.Fragment>
@@ -232,4 +232,4 @@ class Monitor extends PureComponent { @@ -232,4 +232,4 @@ class Monitor extends PureComponent {
232 } 232 }
233 } 233 }
234 234
235 -export default Monitor; 235 +export default PAGE_NAME_UPPER_CAMEL_CASE;
1 import { queryTags } from './service'; 1 import { queryTags } from './service';
2 2
3 export default { 3 export default {
4 - namespace: 'monitor', 4 + namespace: 'BLOCK_NAME',
5 5
6 state: { 6 state: {
7 tags: [], 7 tags: [],
1 import request from 'umi-request'; 1 import request from 'umi-request';
2 2
3 export async function queryTags() { 3 export async function queryTags() {
4 - return request('/api/tags'); 4 + return request('/api/BLOCK_NAME/tags');
5 } 5 }
注册登录 后发表评论