Update network.html

This commit is contained in:
xykt 2024-03-24 09:24:23 +08:00 committed by GitHub
parent 800af7ce4e
commit 9a8c0e7118
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -113,15 +113,14 @@
if (MaxTCPPingValue == null) { if (MaxTCPPingValue == null) {
MaxTCPPingValue = 1000; MaxTCPPingValue = 1000;
} }
// 基于准备好的dom初始化echarts实例 new Vue({
var myChart = echarts.init(document.getElementById('monitor-info-container')); el: '#app',
// 使用刚指定的配置项和数据显示图表。
var statusCards = new Vue({
el: '#network',
delimiters: ['@#', '#@'], delimiters: ['@#', '#@'],
data: { data: {
page: 'network',
defaultTemplate: {{.Conf.Site.Theme}},
templates: {{.Themes}},
servers: initData, servers: initData,
cache: [],
option: { option: {
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -150,6 +149,11 @@
fontSize: 14 fontSize: 14
} }
}, },
grid: {
left: '8%',
right: '8%',
},
backgroundColor: 'rgba(255, 255, 255, 0.8)',
toolbox: { toolbox: {
feature: { feature: {
dataZoom: { dataZoom: {
@ -161,7 +165,7 @@
}, },
dataZoom: [ dataZoom: [
{ {
start: 94, start: 0,
end: 100 end: 100
} }
], ],
@ -171,13 +175,15 @@
}, },
yAxis: { yAxis: {
type: 'value', type: 'value',
boundaryGap: [0, '100%'] boundaryGap: false
}, },
series: [], series: [],
}
}, },
chartOnOff: true,
},
mixins: [mixinsVue],
mounted() { mounted() {
this.DarkMode(); this.renderChart();
this.parseMonitorInfo(monitorInfo); this.parseMonitorInfo(monitorInfo);
window.addEventListener('resize', this.resizeHandle); window.addEventListener('resize', this.resizeHandle);
}, },
@ -185,18 +191,67 @@
window.removeEventListener('resize', this.resizeHandle) window.removeEventListener('resize', this.resizeHandle)
}, },
methods: { methods: {
DarkMode() { getFontLogoClass(str) {
const hour = new Date(Date.now()).getHours() if (["almalinux",
if (hour > 17 || hour < 4) { "alpine",
document.querySelector("input[name=theme]").checked = true; "aosc",
document.getElementsByTagName("BODY")[0].setAttribute('data-theme', 'dark'); "apple",
document.getElementById("monitor-info-container").style.backgroundColor = "#1E1E1E"; "archlinux",
"archlabs",
"artix",
"budgie",
"centos",
"coreos",
"debian",
"deepin",
"devuan",
"docker",
"elementary",
"fedora",
"ferris",
"flathub",
"freebsd",
"gentoo",
"gnu-guix",
"illumos",
"kali-linux",
"linuxmint",
"mageia",
"mandriva",
"manjaro",
"nixos",
"openbsd",
"opensuse",
"pop-os",
"raspberry-pi",
"redhat",
"rocky-linux",
"sabayon",
"slackware",
"snappy",
"solus",
"tux",
"ubuntu",
"void",
"zorin"].indexOf(str)
> -1) {
return str;
} }
if (['openwrt', 'linux', "immortalwrt"].indexOf(str) > -1) {
return 'tux';
}
if (str == 'amazon') {
return 'redhat';
}
if (str == 'arch') {
return 'archlinux';
}
return '';
}, },
redirectNetwork(id) { redirectNetwork(id) {
this.getMonitorHistory(id) this.getMonitorHistory(id)
.then(function(monitorInfo) { .then(function(monitorInfo) {
var vm = network.__vue__; var vm = app.__vue__;
vm.parseMonitorInfo(monitorInfo); vm.parseMonitorInfo(monitorInfo);
}) })
.catch(function(error){ .catch(function(error){
@ -272,13 +327,30 @@
this.option.legend.data = tLegendData; this.option.legend.data = tLegendData;
this.myChart.clear(); this.myChart.clear();
this.myChart.setOption(this.option); this.myChart.setOption(this.option);
},
this.option.title.text = monitorInfo.result[0].server_name;
this.option.series = tSeries;
this.option.legend.data = tLegendData;
this.myChart.clear();
this.myChart.setOption(this.option);
},
isWindowsPlatform(str) {
return str.includes('Windows')
},
renderChart() {
this.myChart = echarts.init(this.$refs.chartDom);
this.myChart.setOption(this.option);
}, },
resizeHandle () { resizeHandle () {
this.myChart.resize(); this.myChart.resize();
}, },
} },
beforeDestroy() {
this.myChart.dispose();
this.myChart = null;
},
}); });
</script> </script>
</body> </body>
<style> <style>
#network { #network {