diff --git a/src/App.js b/src/App.js
index af53e93..c32aee4 100644
--- a/src/App.js
+++ b/src/App.js
@@ -6,14 +6,10 @@ import { Button, Layout, Menu, Tabs } from 'antd';
import 'antd/dist/antd.css';
import React, {useRef} from 'react';
-
import './App.less';
-import ChartsCount from './ChartsCount';
-import TableData from './TableData';
+import ContentTabs from './ContentTabs'
import TabsRoute from './Router';
-import { Link, Route, Router, HashRouter, Switch, useHistory } from 'react-router-dom';
-
-const { TabPane } = Tabs;
+
const { Header, Content, Footer, Sider } = Layout;
class App extends React.Component {
@@ -22,14 +18,11 @@ class App extends React.Component {
super(props)
this.state = {
platform: "openrec",
- collapsed: false,
- tkey: "content_table",
- location: null,
+ tab: "tabledata",
+ collapsed: false
}
}
-
-
toggleCollapsed = () => {
this.setState({
collapsed: !this.state.collapsed,
@@ -37,17 +30,17 @@ class App extends React.Component {
};
changePlatform = (p) => {
- // this.setState({ platform: p });
- // if (this.chartscount && this.chartscount.state.platform !== p) {
- // this.chartscount.changePlatform(p)
- // }
- // this.tabledata.changePlatform(p);
+ this.setState({platform: p}, () => {
+ this.refs.ctabs.changePlatform(this.state.platform);
+ })
+
}
render() {
+ const {tab, platform } = this.state;
+
return (
-
-
+
-
- {
- const history = useHistory();
-
- const { platform } = this.state;
- this.setState({ key: e })
-
- switch (e) {
- case "content_table":
- history.push("#/data")
- // this.props.history.push("#/data")
- if (this.refs.ctable) {
- this.refs.ctable.changePlatform(platform);
- }
- break;
- case "tag_count":
- history.push("#/count")
- // this.props.history.push("#/count")
- if (this.refs.tcharts) {
- this.refs.tcharts.changePlatform(platform);
- }
- break
- default:
- break;
- }
-
- }} >
-
-
-
-
-
-
-
- {
- return
- }} >
-
-
-
- {
- return
- }} >
-
-
-
-
+
-
+
);
}
}
-// ReactDOM.render(, mountNode);
-
export default App;
\ No newline at end of file
diff --git a/src/ChartsCount.js b/src/ChartsCount.js
index c93a7a2..3952379 100644
--- a/src/ChartsCount.js
+++ b/src/ChartsCount.js
@@ -83,7 +83,7 @@ function getOption(state = {}) {
class ChartsCount extends React.Component {
- constructor(props) {
+ constructor(props) { // platform
super(props)
this.state = {
option: {},
@@ -94,20 +94,23 @@ class ChartsCount extends React.Component {
}
}
- changePlatform = (p) => {
- this.setState({ platform: p }, () => {
- this.updateData();
- });
+ changePlatform = (platform) => {
+ this.updateData({ platform: platform, countkey: this.state.countkey })
};
- updateData = () => {
- const { countkey, platform } = this.state;
- fetch(`${apihost}/tag/count?platform=${platform}&countkey=${countkey}`, {
+ updateData = (params = {}) => {
+
+ const {platform, countkey, title} = params
+
+ fetch(`${apihost}/tag/count?platform=${platform?platform:this.state.platform}&countkey=${countkey?countkey:this.state.countkey}`, {
"mode": "cors"
}).then(
response => {
response.json().then(value => {
this.setState({
+ title: title?title:this.state.title,
+ platform: platform?platform:this.state.platform,
+ countkey: countkey?countkey:this.state.countkey,
data: parseData(value)
}, () => {
var ins = this.echarts_react.getEchartsInstance();
@@ -119,12 +122,8 @@ class ChartsCount extends React.Component {
)
};
- componentDidMount() {
- this.updateData();
- }
-
countMethod(countkey, title) {
- this.setState({ countkey: countkey, title: title }, () => { this.updateData() });
+ this.updateData({countkey: countkey, title: title});
}
render() {
diff --git a/src/ContentTabs.js b/src/ContentTabs.js
new file mode 100644
index 0000000..d0c0a72
--- /dev/null
+++ b/src/ContentTabs.js
@@ -0,0 +1,75 @@
+
+import React from 'react';
+import { Button, Layout, Menu, Tabs } from 'antd';
+import ChartsCount from './ChartsCount';
+import TableData from './TableData';
+
+const { TabPane } = Tabs;
+
+class ContentTabs extends React.Component {
+
+ constructor(props) {
+ super(props)
+ this.state = {
+ platform: this.props.platform,
+ tab: this.props.tab,
+ count: 1,
+ }
+ }
+
+ count = 1
+
+ componentDidMount() {
+
+ }
+
+ changeTab = (tab) => {
+ this.setState({tab: tab}, ()=>{ this.updateDate() })
+ }
+
+ updateDate() {
+
+ switch(this.state.tab) {
+ case "tabledata":
+ if (this.refs.tabledata) {
+ this.refs.tabledata.changePlatform(this.state.platform);
+ }
+ break;
+
+ case "chartscount":
+ if (this.refs.chartscount) {
+ this.refs.chartscount.changePlatform(this.state.platform);
+ }
+ break;
+
+ default:
+ }
+ }
+
+ changePlatform = (platform) => {
+ this.setState({platform: platform}, ()=>{ this.updateDate()})
+ }
+
+ render() {
+ this.count ++
+ return (
+
+
+
+
+
+
+
+
+
+
+
+ )
+ }
+}
+
+
+export default ContentTabs;
\ No newline at end of file
diff --git a/src/Router.js b/src/Router.js
index 067c886..a076eac 100644
--- a/src/Router.js
+++ b/src/Router.js
@@ -4,7 +4,7 @@ import { HashRouter, Route, Switch, BrowserRouter, Redirect } from 'react-router
import TableData from "./TableData";
import ChartsCount from "./ChartsCount";
import { Link } from 'react-router-dom';
-import { Button, Layout, Menu, Tabs } from 'antd';
+import { Button, Layout, Menu, Tabs, Result } from 'antd';
const { TabPane } = Tabs;
@@ -14,15 +14,20 @@ const MainRouter = () => {
return (
- {/* */}
-
-
-
+ } />
+
+
+ {
+ return Back Home}
+ />
+ }} />
+
)
diff --git a/src/index.js b/src/index.js
index e226e94..8fa05ff 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,15 +1,16 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
-import App from './App';
+import App from './Router';
import MainRouter from './Router';
import * as serviceWorker from './serviceWorker';
import { Route } from 'react-router-dom';
ReactDOM.render(
-
-
- ,
+ ,
+ //
+ //
+ // ,
document.getElementById('root')
);