From 8a59fa4dd4a91980320da1ba508fc67efb3ec07f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=8E=89=E5=9D=A1?= Date: Tue, 26 Nov 2019 22:55:54 +0800 Subject: [PATCH] =?UTF-8?q?A=20-=20=E6=B7=BB=E5=8A=A0home=20=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spug_web/package.json | 2 + spug_web/src/components/index.module.css | 2 +- spug_web/src/pages/home/index.js | 200 ++++++++++++++++++++++- spug_web/src/pages/home/store.js | 17 ++ 4 files changed, 214 insertions(+), 7 deletions(-) create mode 100644 spug_web/src/pages/home/store.js diff --git a/spug_web/package.json b/spug_web/package.json index 7d320c0..5115901 100644 --- a/spug_web/package.json +++ b/spug_web/package.json @@ -3,9 +3,11 @@ "version": "0.1.0", "private": true, "dependencies": { + "@antv/data-set": "^0.10.2", "ace-builds": "^1.4.7", "antd": "^3.25.0", "axios": "^0.19.0", + "bizcharts": "^3.5.6", "history": "^4.10.1", "http-proxy-middleware": "^0.20.0", "lodash": "^4.17.15", diff --git a/spug_web/src/components/index.module.css b/spug_web/src/components/index.module.css index f6fc215..4555710 100644 --- a/spug_web/src/components/index.module.css +++ b/spug_web/src/components/index.module.css @@ -23,7 +23,7 @@ } .statisticsCard p { - font-size: 24px; + font-size: 32px; line-height: 32px; margin: 0; } diff --git a/spug_web/src/pages/home/index.js b/spug_web/src/pages/home/index.js index a5853e5..65d355d 100644 --- a/spug_web/src/pages/home/index.js +++ b/spug_web/src/pages/home/index.js @@ -1,13 +1,201 @@ import React from 'react'; -import { Card } from 'antd'; +import {observer} from 'mobx-react'; +import { Card, Row, Col } from 'antd'; +import { StatisticsCard } from "../../components"; +import { Chart, Geom, Axis, Tooltip, Coord, Guide, Label } from 'bizcharts'; +import DataSet from "@antv/data-set"; +import store from './store'; +@observer +class HomeIndex extends React.Component { + constructor(props) { + super(props); + this.state = { + failure: 0 + }; + this.data = [ + {region: '北京机房', count: 275}, + {region: '上海机房', count: 115}, + {region: '杭州机房', count: 350}, + ]; + this.cols = { + region: {alias: '机房'}, + count: {alias: '服务器数量'} + }; + this.data2 = [ + {item: 'RPC-User', count: 5}, + {item: 'SOA', count: 2}, + {item: 'RPC-Order', count: 10}, + {item: 'RPC-Goods', count: 10}, + {item: 'WebServer', count: 5}, + ]; + this.dv = new DataSet.DataView(); + this.dv.source(this.data2).transform({ + type: "percent", + field: "count", + dimension: "item", + as: "percent" + }); + this.cols2 = { + percent: { + formatter: val => { + val = (val * 100).toFixed(0) + "%"; + return val; + } + } + }; + + } + + componentDidMount() { + store.fetchInfo() + } -export default class extends React.Component { render() { + const data = [ + { + year: "1991", + value: 3 + }, + { + year: "1992", + value: 4 + }, + { + year: "1993", + value: 3.5 + }, + { + year: "1994", + value: 5 + }, + { + year: "1995", + value: 4.9 + }, + { + year: "1996", + value: 6 + }, + { + year: "1997", + value: 7 + }, + { + year: "1998", + value: 9 + }, + { + year: "1999", + value: 13 + } + ]; + const cols = { + value: { + min: 0 + }, + year: { + range: [0, 1] + } + }; return ( - - The home page - + + + + + 99}/> + 1}/> + {/*value={{store.info.failure}}/>*/} + +
+ + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + { + percent = percent * 100 + "%"; + return { + name: item, + value: percent + }; + } + ]} + style={{lineWidth: 1, stroke: "#fff"}}> + + + + + +
+
) } -} \ No newline at end of file +} + +export default HomeIndex diff --git a/spug_web/src/pages/home/store.js b/spug_web/src/pages/home/store.js new file mode 100644 index 0000000..722ea45 --- /dev/null +++ b/spug_web/src/pages/home/store.js @@ -0,0 +1,17 @@ +import {observable} from "mobx"; +import http from '../../libs/http'; + +class Store { + @observable info = {}; + @observable isFetching = false; + + fetchInfo =() => { + this.isFetching = true; + http.get('/api/home/') + .then(res => this.info = res) + .finally(() => this.isFetching = false) + }; + +} + +export default new Store()