This commit is contained in:
qiangyanwen 2022-12-17 12:43:13 +08:00
parent 99a550929b
commit 99f5964d94
1 changed files with 10 additions and 18 deletions

View File

@ -29,7 +29,7 @@
</template>
<script setup>
import {onMounted, reactive} from "vue";
import {onMounted, reactive,watch} from "vue";
let sysparams = reactive({
count: 0,
@ -101,36 +101,27 @@ const columns = [{
];
onMounted(() => {
setInterval(() => {
GetSytem()
}, 5000)
})
const disk = reactive({
data:[]
})
function GetSytem(){
console.log("开始连接websocket......")
const ws = new WebSocket("ws://127.0.0.1:8000/api/ws")
ws.onopen = function () { ws.send("")};
ws.onmessage = function (e){
const data = JSON.parse(e.data)
ws.onmessage = function (msg){
console.log("开始接受数据.............")
const data = JSON.parse(msg.data)
console.log(data)
let {cpu_percent} = data.cpu_info
let {percent} = data.memory_info
// cpu
option.series.forEach((data) => {
data.data.forEach((key) => {
key.value = cpu_percent
})
})
option.series[0].data[0].value = cpu_percent
//
memory.series.forEach((data) => {
data.data.forEach((key) => {
key.value = percent
})
})
memory.series[0].data[0].value = percent
//
let {count, name, current_time, start_time} = data.sys_info
sysparams.count = count
@ -157,6 +148,7 @@ function GetSytem(){
}
</script>