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