feat: 更多的字体
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
<meta name="viewport" content="width=1080, initial-scale=1.0">
|
||||
<title>Liteyuki Stats</title>
|
||||
<link rel="stylesheet" href="css/fonts.css">
|
||||
|
||||
<style>
|
||||
|
||||
body {
|
||||
@ -53,7 +54,13 @@
|
||||
#disks-info {
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
|
||||
}
|
||||
|
||||
#motto-info {
|
||||
margin-bottom: 0;
|
||||
text-align: center;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.bot-icon {
|
||||
@ -95,12 +102,25 @@
|
||||
line-height: 50%;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.motto-text {
|
||||
font-size: 36px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.motto-author {
|
||||
font-size: 30px;
|
||||
font-style: italic;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@4.3.0/dist/echarts.min.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div class="info-box" id="hardware-info">
|
||||
<div class="pie-info" id="cpu-info">
|
||||
<div class="pie-chart" id="cpu-chart"></div>
|
||||
@ -116,233 +136,12 @@
|
||||
<div class="info-box" id="disks-info">
|
||||
</div>
|
||||
|
||||
<div class="info-box" id="motto-info">
|
||||
</div>
|
||||
|
||||
<!--储存数据div,不显示-->
|
||||
<div id="data" style="display: none">{{ data | tojson }}</div>
|
||||
<script>
|
||||
{
|
||||
// 环形图
|
||||
|
||||
let bgs = ["bg1.jpg", "bg2.jpg", "bg3.jpg", "bg4.jpg"]
|
||||
// 随机选择背景图片
|
||||
document.body.style.backgroundImage = `url(./img/${bgs[Math.floor(Math.random() * bgs.length)]})`;
|
||||
|
||||
|
||||
let cpuInfo = echarts.init(document.getElementById('cpu-chart'));
|
||||
let memInfo = echarts.init(document.getElementById('mem-chart'));
|
||||
let swapInfo = echarts.init(document.getElementById('swap-chart'));
|
||||
|
||||
let data = JSON.parse(document.getElementById('data').innerText);
|
||||
|
||||
let cpuData = data.cpu;
|
||||
let memData = data.mem;
|
||||
let swapData = data.swap;
|
||||
let diskData = data.disk;
|
||||
let sub_tag_data = {
|
||||
cpu: data.cpuTags,
|
||||
mem: data.memTags,
|
||||
swap: data.swapTags
|
||||
}
|
||||
for (let key in sub_tag_data) {
|
||||
console.log(key, sub_tag_data[key])
|
||||
let infoDiv = document.getElementById(key + '-info');
|
||||
sub_tag_data[key].forEach(tag => {
|
||||
let tagSpan = document.createElement('div');
|
||||
tagSpan.innerText = tag;
|
||||
tagSpan.className = 'chart-label';
|
||||
infoDiv.appendChild(tagSpan);
|
||||
});
|
||||
}
|
||||
cpuInfo.setOption(getPieOption(data.cpu_trans, cpuData));
|
||||
memInfo.setOption(getPieOption(data.mem_trans, memData));
|
||||
swapInfo.setOption(getPieOption(data.swap_trans, swapData));
|
||||
|
||||
|
||||
// 在disks-info中插入每个disk的div,用横向柱状图表示用量,每一行div显示一个disk,不加info-box
|
||||
diskData.forEach(disk => {
|
||||
let diskDiv = document.createElement('div');
|
||||
document.getElementById('disks-info').appendChild(diskDiv);
|
||||
let diskChart = document.createElement('div');
|
||||
diskChart.style.width = '100%';
|
||||
diskChart.style.height = '100px';
|
||||
diskDiv.appendChild(diskChart);
|
||||
let diskInfo = echarts.init(diskChart);
|
||||
// let diskTitle = disk.name + ' {{ FREE }} ' + disk.free + ' {{ TOTAL }} ' + disk.total;
|
||||
let diskTitle = `${disk.name} ${data.free_trans} ${disk.free} ${data.total_trans} ${disk.total}`;
|
||||
diskInfo.setOption(getBarOption(diskTitle, disk.percent));
|
||||
});
|
||||
|
||||
let botData = data.bot;
|
||||
// 清空bot-info
|
||||
let botInfos = document.getElementsByClassName('bot-info');
|
||||
while (botInfos.length > 0) {
|
||||
botInfos[0].remove();
|
||||
}
|
||||
botData.forEach(bot => {
|
||||
// 在hardware-info前面插入一个div
|
||||
let botDiv = document.createElement('div');
|
||||
botDiv.className = 'info-box bot-info';
|
||||
// 在body内的hardware-info前面插入botDiv
|
||||
document.body.insertBefore(botDiv, document.getElementById('hardware-info'));
|
||||
|
||||
let botIconBlock = document.createElement('div');
|
||||
let botIcon = document.createElement('img');
|
||||
botIcon.src = bot.icon;
|
||||
botIcon.className = 'bot-icon';
|
||||
botIconBlock.appendChild(botIcon);
|
||||
botDiv.appendChild(botIconBlock);
|
||||
|
||||
let botDetail = document.createElement('div');
|
||||
let botName = document.createElement('div');
|
||||
botName.className = 'bot-name';
|
||||
botName.innerText = bot.name;
|
||||
if (bot.self) {
|
||||
// 添加颜色
|
||||
botName.style.color = '#d0e9ff';
|
||||
}
|
||||
botDetail.appendChild(botName);
|
||||
|
||||
let botTags = document.createElement('div');
|
||||
botTags.className = 'bot-tag';
|
||||
botDetail.appendChild(botTags)
|
||||
|
||||
bot.tags.forEach((tag, index) => {
|
||||
if (!tag) {
|
||||
return;
|
||||
}
|
||||
let tagSpan = document.createElement('span');
|
||||
|
||||
tagSpan.innerText = tag;
|
||||
tagSpan.className = 'tag';
|
||||
if (bot.self) {
|
||||
// 添加颜色
|
||||
tagSpan.style.color = '#a2d8f4';
|
||||
}
|
||||
botTags.appendChild(tagSpan);
|
||||
if (index === bot.tags.length - 1) {
|
||||
tagSpan.setAttribute("suffix", "0")
|
||||
} else {
|
||||
tagSpan.setAttribute("suffix", "1")
|
||||
}
|
||||
});
|
||||
|
||||
botDiv.appendChild(botDetail);
|
||||
}
|
||||
)
|
||||
|
||||
function getPieOption(title, data) {
|
||||
return {
|
||||
animation: false,
|
||||
title: {
|
||||
text: title,
|
||||
left: 'center',
|
||||
top: 'center',
|
||||
textStyle: {
|
||||
//文字颜色
|
||||
color: '#fff',
|
||||
fontSize: 30
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
show: true,
|
||||
trigger: "item",
|
||||
backgroundColor: "#ffffff00",
|
||||
// {a}(系列名称),{b}(数据项名称),{c}(数值), {d}(百分比)
|
||||
},
|
||||
color: ['#a2d8f4', "#ffffff44", '#00a6ff'],
|
||||
series: [
|
||||
{
|
||||
name: 'info',
|
||||
type: 'pie',
|
||||
radius: ['80%', '100%'],
|
||||
center: ['50%', '50%'],
|
||||
itemStyle: {
|
||||
normal: {
|
||||
label: {
|
||||
show: false
|
||||
},
|
||||
labelLine: {
|
||||
show: false
|
||||
}
|
||||
},
|
||||
emphasis: {
|
||||
label: {
|
||||
show: true,
|
||||
textStyle: {
|
||||
fontSize: '50',
|
||||
fontWeight: 'bold'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
data: data
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
function getBarOption(title, percent) {
|
||||
// data为百分比,最大值为100
|
||||
return {
|
||||
background: '#d0e9ff',
|
||||
title: {
|
||||
text: title,
|
||||
left: '5%',
|
||||
top: 'center',
|
||||
textStyle: {
|
||||
color: '#fff',
|
||||
fontSize: 30
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
show: true,
|
||||
trigger: "item",
|
||||
backgroundColor: "#ffffff",
|
||||
},
|
||||
grid: {
|
||||
left: '0',
|
||||
right: '0',
|
||||
top: '10%',
|
||||
bottom: '10%'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'value',
|
||||
show: false
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
data: [''],
|
||||
show: false
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: 'Used',
|
||||
type: 'bar',
|
||||
stack: 'total',
|
||||
data: [percent],
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: '#a2d8f4',
|
||||
barBorderRadius: [50, 0, 0, 50]
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Free',
|
||||
type: 'bar',
|
||||
stack: 'total',
|
||||
data: [100 - percent],
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: '#d0e9ff',
|
||||
barBorderRadius: [0, 50, 50, 0]
|
||||
}
|
||||
},
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
<script src="js/motto.js"></script>
|
||||
<script type="text/javascript" src="js/stats.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user