2024-06-22 10:54:02 +08:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import {useMainLayoutStore} from "~/strores/UseMainLayoutStore";
|
|
|
|
|
|
|
|
definePageMeta({
|
|
|
|
layout: 'main',
|
|
|
|
middleware: ['auth']
|
|
|
|
})
|
|
|
|
type RouteType = {
|
|
|
|
label: string,
|
|
|
|
icon: string,
|
|
|
|
route: string
|
|
|
|
}
|
|
|
|
const mainLayoutStore = useMainLayoutStore()
|
|
|
|
const diskRoute = ref<RouteType[]>([])
|
|
|
|
const netRoute = ref<RouteType[]>([])
|
2024-06-29 18:16:29 +08:00
|
|
|
const reLoad=ref<boolean>(false)
|
2024-06-22 10:54:02 +08:00
|
|
|
|
|
|
|
const headers = computed(() => {
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
label: 'CPU',
|
|
|
|
icon: 'Cpu',
|
|
|
|
route: '/host/cpu'
|
|
|
|
}, {
|
|
|
|
label: '内存',
|
2024-07-22 21:05:18 +08:00
|
|
|
icon: 'MemoryStick',
|
2024-06-22 10:54:02 +08:00
|
|
|
route: '/host/memory'
|
|
|
|
},
|
|
|
|
...diskRoute.value.map(x => {
|
|
|
|
return {
|
|
|
|
label: x.label,
|
|
|
|
icon: x.icon,
|
|
|
|
route: x.route
|
|
|
|
}
|
|
|
|
}), ...netRoute.value.map(x => {
|
|
|
|
return {
|
|
|
|
label: x.label,
|
|
|
|
icon: x.icon,
|
|
|
|
route: x.route
|
|
|
|
}
|
|
|
|
}),
|
2024-06-29 18:16:29 +08:00
|
|
|
{
|
|
|
|
label:'进程',
|
|
|
|
icon:'LayoutList',
|
|
|
|
route:'/host/process'
|
|
|
|
},{
|
|
|
|
label:'网络连接',
|
|
|
|
icon:'Waypoints',
|
|
|
|
route:'/host/networkList'
|
|
|
|
}
|
2024-06-22 10:54:02 +08:00
|
|
|
]
|
|
|
|
}
|
|
|
|
})
|
|
|
|
onMounted(() => {
|
|
|
|
getRote()
|
|
|
|
})
|
|
|
|
const getRote = () => {
|
|
|
|
$fetch('/Api/Server/GetServerDiskList', {
|
|
|
|
method: 'GET',
|
|
|
|
params: {
|
2024-07-22 21:05:18 +08:00
|
|
|
ServerId: mainLayoutStore.SelectServer.value
|
2024-06-22 10:54:02 +08:00
|
|
|
},
|
|
|
|
baseURL: useRuntimeConfig().public.baseUrl,
|
|
|
|
headers: {
|
|
|
|
'Authorization': 'Bearer ' + useCookie('token').value
|
|
|
|
}
|
|
|
|
}).then(res => {
|
|
|
|
const data = res as any[]
|
|
|
|
console.log(data)
|
|
|
|
diskRoute.value = data.map((x, index) => {
|
|
|
|
return {
|
|
|
|
label: `驱动器 ${index} (${x.name.replace('/dev/', '')}) - ${x.size}GB`,
|
|
|
|
icon: 'HardDrive',
|
|
|
|
route: '/host/disk/' + x.name.replace('/dev/', '').replace('/', '_')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
$fetch('/Api/Server/GetServerNetworkEquipmentList', {
|
|
|
|
method: 'GET',
|
|
|
|
params: {
|
2024-07-22 21:05:18 +08:00
|
|
|
ServerId: mainLayoutStore.SelectServer.value
|
2024-06-22 10:54:02 +08:00
|
|
|
},
|
|
|
|
baseURL: useRuntimeConfig().public.baseUrl,
|
|
|
|
headers: {
|
|
|
|
'Authorization': 'Bearer ' + useCookie('token').value
|
|
|
|
}
|
|
|
|
}).then(res => {
|
|
|
|
const data = res as string[]
|
|
|
|
netRoute.value = data.map((x, index) => {
|
|
|
|
return {
|
|
|
|
label: `网络设备 ${index} (${x})`,
|
|
|
|
icon: 'Network',
|
|
|
|
route: '/host/network/' + x
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
2024-07-22 21:05:18 +08:00
|
|
|
watch(() => mainLayoutStore.SelectServer.value, () => {
|
2024-06-29 18:16:29 +08:00
|
|
|
getRote()
|
|
|
|
navigateTo('/host/cpu')
|
|
|
|
reLoad.value = true
|
|
|
|
nextTick(() => {
|
|
|
|
reLoad.value = false
|
|
|
|
})
|
|
|
|
})
|
2024-06-22 10:54:02 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="Host-Layout">
|
|
|
|
<XScroll>
|
|
|
|
<div class="header">
|
|
|
|
<div v-for="header in headers" :class="{
|
|
|
|
'header-item':true,'header-item-activated': $route.path === header.route,
|
|
|
|
}" @click="navigateTo(header.route)">
|
|
|
|
<Icon :name="header.icon" :stroke-width="1.6"/>
|
|
|
|
<p>{{ header.label }}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</XScroll>
|
2024-06-29 18:16:29 +08:00
|
|
|
<NuxtPage v-if="!reLoad" />
|
2024-06-22 10:54:02 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import "base";
|
|
|
|
|
|
|
|
|
|
|
|
.Host-Layout {
|
|
|
|
background: $light-bg-color;
|
|
|
|
width: 100%;
|
|
|
|
border-radius: $radius*2;
|
|
|
|
box-shadow: 0 0 10px rgba(0, 0, 0, .1);
|
|
|
|
display: grid;
|
|
|
|
grid-template-rows: auto 1fr;
|
|
|
|
grid-template-columns:1fr;
|
|
|
|
|
|
|
|
.dark-mode & {
|
|
|
|
background: $dark-bg-color;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.header {
|
|
|
|
display: flex;
|
|
|
|
min-height: 50px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.header-item {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
padding: $padding;
|
|
|
|
gap: $gap;
|
|
|
|
//禁止文本换行
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
|
|
&:not(.header-item-activated):hover, &:active {
|
|
|
|
background: rgba($primary-color, 0.1);
|
|
|
|
box-shadow: 0 0 200px 10px rgba($primary-color, .3);
|
|
|
|
}
|
|
|
|
|
|
|
|
p, svg {
|
|
|
|
font-weight: 500;
|
|
|
|
color: $light-text-color;
|
|
|
|
}
|
|
|
|
|
|
|
|
.dark-mode & {
|
|
|
|
p, svg {
|
|
|
|
color: $dark-text-color;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.header-item-activated {
|
|
|
|
background: $primary-color;
|
|
|
|
|
|
|
|
p, svg {
|
|
|
|
color: #FFF;
|
|
|
|
stroke: #FFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
</style>
|