解决关闭服务监控页面后还会继续请求数据
This commit is contained in:
parent
27870f5f62
commit
8e692a97b8
@ -1,22 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :lg="24" class="card-box">
|
<el-col :lg="24" class="card-box" v-if="server.cpu">
|
||||||
<el-card class="box-card">
|
<el-card class="box-card">
|
||||||
<template #header>
|
<template #header>
|
||||||
<span>状态</span>
|
<span>状态</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<el-col :xs="24" :sm="24" :md="6" :lg="6" :xl="6">
|
<el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8" class="mr20">
|
||||||
<div class="title">CPU使用率</div>
|
<div class="title">CPU使用率</div>
|
||||||
<el-tooltip placement="top-end">
|
<div class="content">
|
||||||
<div class="content" v-if="server.cpu">
|
|
||||||
<el-progress type="dashboard" :percentage="parseFloat(server.cpu.cpuRate)" />
|
<el-progress type="dashboard" :percentage="parseFloat(server.cpu.cpuRate)" />
|
||||||
</div>
|
</div>
|
||||||
</el-tooltip>
|
|
||||||
<div class="footer" v-if="server.sys">{{ server.sys.cpuNum }} 核心</div>
|
<div class="footer" v-if="server.sys">{{ server.sys.cpuNum }} 核心</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :xs="24" :sm="24" :md="6" :lg="6" :xl="6" v-if="server.cpu">
|
|
||||||
|
<el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
|
||||||
<div class="title">内存使用率</div>
|
<div class="title">内存使用率</div>
|
||||||
<el-tooltip placement="top-end">
|
<el-tooltip placement="top-end">
|
||||||
<template #content>
|
<template #content>
|
||||||
@ -193,66 +192,50 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup name="server">
|
||||||
import { getServer } from '@/api/monitor/server'
|
import { getServer } from '@/api/monitor/server'
|
||||||
|
import { onBeforeRouteLeave } from 'vue-router'
|
||||||
export default {
|
onBeforeRouteLeave((to) => {
|
||||||
name: 'Server',
|
clear()
|
||||||
data() {
|
})
|
||||||
return {
|
// 服务器信息
|
||||||
// 加载层信息
|
const server = ref([])
|
||||||
loading: [],
|
const intervalId = ref(null)
|
||||||
// 服务器信息
|
const { proxy } = getCurrentInstance()
|
||||||
server: [],
|
/** 查询服务器信息 */
|
||||||
intervalId: null,
|
function getList() {
|
||||||
}
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.getList()
|
|
||||||
this.openLoading()
|
|
||||||
this.dataRefreh()
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
/** 查询服务器信息 */
|
|
||||||
getList() {
|
|
||||||
getServer()
|
getServer()
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.server = response.data
|
server.value = response.data
|
||||||
this.loading.close()
|
proxy.$modal.closeLoading()
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
this.loading.close()
|
proxy.$modal.closeLoading()
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
// 打开加载层
|
// 打开加载层
|
||||||
openLoading() {
|
function openLoading() {
|
||||||
this.loading = this.$loading({
|
proxy.$modal.loading('拼命读取中')
|
||||||
lock: true,
|
}
|
||||||
text: '拼命读取中',
|
function dataRefreh() {
|
||||||
spinner: 'el-icon-loading',
|
if (intervalId.value != null) {
|
||||||
background: 'rgba(0, 0, 0, 0.7)',
|
|
||||||
})
|
|
||||||
},
|
|
||||||
dataRefreh() {
|
|
||||||
if (this.intervalId != null) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.intervalId = setInterval(() => {
|
intervalId.value = setInterval(() => {
|
||||||
this.getList()
|
getList()
|
||||||
}, 10000)
|
}, 10000)
|
||||||
},
|
}
|
||||||
/**
|
/**
|
||||||
* 停止定时器
|
* 停止定时器
|
||||||
*/
|
*/
|
||||||
clear() {
|
function clear() {
|
||||||
clearInterval(this.intervalId)
|
clearInterval(intervalId.value)
|
||||||
this.intervalId = null
|
intervalId.value = null
|
||||||
},
|
|
||||||
},
|
|
||||||
destroyed() {
|
|
||||||
this.clear()
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getList()
|
||||||
|
openLoading()
|
||||||
|
dataRefreh()
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
table tr {
|
table tr {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user