提交 4d6c7c8d82ff56c9ba60cccf08bb5c3f37ce023d

作者 愚道
1 个父辈 297fd08d

improve monitor block code

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