LoongPanel-Asp/web/pages/host/network/[[id]].vue

207 lines
4.0 KiB
Vue

<script lang="ts" setup>
import {useMainLayoutStore} from "~/strores/UseMainLayoutStore";
import {useDataStore} from "~/strores/DataStore";
import AreaChart2 from "~/components/Charts/AreaChart2.vue";
const id = toRef(useRoute().params.id);
const lsNet = ref<string[]>([])
const mainLayoutStore = useMainLayoutStore()
const dataStore = useDataStore()
onMounted(() => {
$fetch('/Api/Server/GetServerNetworkEquipmentInfo', {
method: 'GET',
params: {
ServerId: mainLayoutStore.SelectServer.value,
NetworkId: id.value
},
headers: {
'Content-Type': 'application/json',
'Authorization': "Bearer " + useCookie('token').value
},
baseURL: useRuntimeConfig().public.baseUrl
}).then(res => {
lsNet.value = res as string[]
})
})
</script>
<template>
<div class="net-layout">
<div class="left-chart">
<div class="net-title">
<h1>网络设备 {{ $route.params.id }}</h1>
</div>
<div class="net-chart-top">
<p>活动时间</p>
<p>100%</p>
</div>
<div class="net-chart">
<AreaChart2 :bg-color="'rgba(208,157,209,0.3)'" :colors="['#d09dd1']" :value-ids="[`ReceivedPacketsPerSecond-${id}`,`TransmittedPacketsPerSecond-${id}`]"
:configs="[
{
},{
lineStyle: {
type: 'dashed' }
}]"
:value-names="['每秒收包数','每秒发包数']"/>
</div>
<div class="net-chat-bottom">
<p>更早</p>
<p>0</p>
</div>
</div>
<div class="right-info">
<div class="info-title-box">
<div class="infos">
<div class="info2">
<div></div>
<p>接受</p>
<h2>{{ dataStore.data[`ReceivedPacketsPerSecond-${id}`] }} KiB/s</h2>
</div>
<div class="info2">
<div></div>
<p>发送</p>
<h2>{{ dataStore.data[`TransmittedPacketsPerSecond-${id}`] }} KiB/s</h2>
</div>
</div>
</div>
<div class="other-info-box">
<div v-for="value in lsNet" class="other-info">
<p>{{ value}}</p>
</div>
</div>
</div>
</div>
</template>
<style lang="scss" scoped>
@import "base";
.net-layout {
padding: $padding*1.5;
display: grid;
grid-template-columns: 1fr 300px;
grid-template-rows: 1fr;
gap: $gap*4;
}
.left-chart {
display: flex;
flex-direction: column;
gap: $gap;
.net-title {
display: flex;
justify-content: space-between;
align-items: center;
.dark-mode & {
h1, h2 {
color: $dark-text-color;
}
}
h1, h2 {
color: $light-text-color;
}
h1 {
font-size: 32px;
}
}
}
.net-chart-top {
display: flex;
justify-content: space-between;
align-items: center;
}
.net-chart {
flex: 1;
border: 4px solid #d09dd1;
border-radius: $radius*2;
height: min-content;
max-height: 32rem;
min-height: 24rem;
overflow: hidden;
}
.net-chat-bottom {
display: flex;
justify-content: space-between;
align-items: center;
}
.info-title-box {
display: flex;
flex-wrap: wrap;
gap: $gap*2;
.info-title {
display: flex;
flex-direction: column;
gap: $gap*.5;
}
.info-title:nth-of-type(2) {
width: 60%;
}
}
.other-info-box {
display: flex;
flex-direction: column;
gap: $gap*.5;
.other-info {
display: flex;
gap: $gap;
p:first-of-type {
font-weight: 500;
}
p {
flex: 1;
//文本换行
word-wrap: break-word;
}
}
}
.right-info {
display: flex;
flex-direction: column;
gap: $gap*2;
}
.infos {
display: flex;
flex-direction: column;
gap: $gap*2;
.info2 {
display: grid;
grid-template-columns: 4px 1fr;
grid-template-rows: 1fr 1fr;
grid-column-gap: $gap*2;
& > div {
height: 100%;
border: 3px solid #d09dd1;
grid-row: 1/3;
}
}
.info2:last-of-type {
& > div {
height: 100%;
border: 3px dashed #d09dd1;
grid-row: 1/3;
}
}
}
</style>