fix 服务监控
This commit is contained in:
@@ -13,7 +13,7 @@ export default class base extends Component {
|
|||||||
<Card bordered={false}>
|
<Card bordered={false}>
|
||||||
<Descriptions
|
<Descriptions
|
||||||
column={2}
|
column={2}
|
||||||
labelStyle={{ fontSize: '14px', color: 'rgba(0,0,0,.45)' }}
|
labelStyle={{ fontSize: '14px', opacity: 0.45 }}
|
||||||
contentStyle={{ fontSize: '14px' }}
|
contentStyle={{ fontSize: '14px' }}
|
||||||
>
|
>
|
||||||
<Descriptions.Item label="主机名称">{hostName}</Descriptions.Item>
|
<Descriptions.Item label="主机名称">{hostName}</Descriptions.Item>
|
||||||
|
|||||||
@@ -21,8 +21,10 @@ export default class index extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
const { data: base } = await api.sysMachineBase()
|
try {
|
||||||
this.setState({ loading: false, base })
|
const { data: base } = await api.sysMachineBase()
|
||||||
|
this.setState({ loading: false, base })
|
||||||
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ export default class useCharts extends Component {
|
|||||||
timer = null
|
timer = null
|
||||||
timerMoment = null
|
timerMoment = null
|
||||||
|
|
||||||
|
actived = true
|
||||||
|
|
||||||
systemStart = moment()
|
systemStart = moment()
|
||||||
|
|
||||||
now = Date.now()
|
now = Date.now()
|
||||||
@@ -27,6 +29,7 @@ export default class useCharts extends Component {
|
|||||||
shouldComponentUpdate(props) {
|
shouldComponentUpdate(props) {
|
||||||
// 当前页签未选中时停止获取状态
|
// 当前页签未选中时停止获取状态
|
||||||
if (this.props.actived !== props.actived) {
|
if (this.props.actived !== props.actived) {
|
||||||
|
this.actived = props.actived
|
||||||
if (props.actived) {
|
if (props.actived) {
|
||||||
this.start()
|
this.start()
|
||||||
} else {
|
} else {
|
||||||
@@ -53,9 +56,7 @@ export default class useCharts extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
this.timer = setInterval(() => {
|
this.actived = true
|
||||||
this.refreshData()
|
|
||||||
}, 3000)
|
|
||||||
this.refreshData()
|
this.refreshData()
|
||||||
this.timerMoment = setInterval(() => {
|
this.timerMoment = setInterval(() => {
|
||||||
this.setState({ nowMoment: moment() })
|
this.setState({ nowMoment: moment() })
|
||||||
@@ -63,7 +64,8 @@ export default class useCharts extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
clearInterval(this.timer)
|
this.actived = false
|
||||||
|
clearTimeout(this.timer)
|
||||||
clearInterval(this.timerMoment)
|
clearInterval(this.timerMoment)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,6 +93,11 @@ export default class useCharts extends Component {
|
|||||||
})
|
})
|
||||||
|
|
||||||
this.setState({ use })
|
this.setState({ use })
|
||||||
|
|
||||||
|
if (this.actived)
|
||||||
|
this.timer = setTimeout(() => {
|
||||||
|
this.refreshData()
|
||||||
|
}, 3000)
|
||||||
}
|
}
|
||||||
|
|
||||||
initCpuChart() {
|
initCpuChart() {
|
||||||
|
|||||||
Reference in New Issue
Block a user