mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2025-09-09 03:56:24 +00:00
🔥 小型重构
This commit is contained in:
2
src/resources/liteyuki_statistics/lang/zh-CN.lang
Normal file
2
src/resources/liteyuki_statistics/lang/zh-CN.lang
Normal file
@ -0,0 +1,2 @@
|
||||
stat.message=统计消息
|
||||
stat.rank=发言排名
|
3
src/resources/liteyuki_statistics/metadata.yml
Normal file
3
src/resources/liteyuki_statistics/metadata.yml
Normal file
@ -0,0 +1,3 @@
|
||||
name: 轻雪统计信息附件
|
||||
description: For Liteyuki statistic
|
||||
version: 2024.4.26
|
@ -0,0 +1,4 @@
|
||||
.sign-chart {
|
||||
height: 400px;
|
||||
background-color: rgba(255, 255, 255, 0.7);
|
||||
}
|
54
src/resources/liteyuki_statistics/templates/js/stat_msg.js
Normal file
54
src/resources/liteyuki_statistics/templates/js/stat_msg.js
Normal file
@ -0,0 +1,54 @@
|
||||
// 数据类型声明
|
||||
// import * as echarts from 'echarts';
|
||||
|
||||
let data = JSON.parse(document.getElementById("data").innerText) // object
|
||||
const signChartDivTemplate = document.importNode(document.getElementById("sign-chart-template").content, true)
|
||||
data.forEach((item) => {
|
||||
let signChartDiv = signChartDivTemplate.cloneNode(true)
|
||||
let chartID = item["name"]
|
||||
// 初始化ECharts实例
|
||||
// 设置id
|
||||
signChartDiv.querySelector(".sign-chart").id = chartID
|
||||
document.body.appendChild(signChartDiv)
|
||||
|
||||
let signChart = echarts.init(document.getElementById(chartID))
|
||||
|
||||
signChart.setOption(
|
||||
{
|
||||
animation: false,
|
||||
title: {
|
||||
text: item["name"],
|
||||
textStyle: {
|
||||
color: '#000000' // 设置标题文本颜色为红色
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: item["times"].map(timestampToTime),
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
min: Math.min(...item["counts"]),
|
||||
},
|
||||
|
||||
series: [
|
||||
{
|
||||
data: item["counts"],
|
||||
type: 'line',
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
function timestampToTime(timestamp) {
|
||||
let date = new Date(timestamp * 1000)
|
||||
let Y = date.getFullYear() + '-'
|
||||
let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
|
||||
let D = date.getDate() + ' '
|
||||
let h = date.getHours() + ':'
|
||||
let m = date.getMinutes() + ':'
|
||||
let s = date.getSeconds()
|
||||
return M + D + h + m + s
|
||||
}
|
25
src/resources/liteyuki_statistics/templates/js/stat_rank.js
Normal file
25
src/resources/liteyuki_statistics/templates/js/stat_rank.js
Normal file
@ -0,0 +1,25 @@
|
||||
let data = JSON.parse(document.getElementById("data").innerText) // object
|
||||
|
||||
const rowDiv = document.importNode(document.getElementById("row-template").content, true)
|
||||
|
||||
function randomHideChar(str) {
|
||||
// 随机隐藏6位以上字符串的中间连续四位字符,用*代替
|
||||
if (str.length <= 6) {
|
||||
return str
|
||||
}
|
||||
let start = Math.floor(str.length / 2) - 2
|
||||
return str.slice(0, start) + "****" + str.slice(start + 4)
|
||||
}
|
||||
data["ranking"].forEach((item) => {
|
||||
let row = rowDiv.cloneNode(true)
|
||||
let rowID = item["name"]
|
||||
let rowIconSrc = item["icon"]
|
||||
let rowCount = item["count"]
|
||||
|
||||
row.querySelector(".row-name").innerText = randomHideChar(rowID)
|
||||
row.querySelector(".row-icon").src = rowIconSrc
|
||||
row.querySelector(".row-count").innerText = rowCount
|
||||
|
||||
document.body.appendChild(row)
|
||||
})
|
||||
|
22
src/resources/liteyuki_statistics/templates/stat_msg.html
Normal file
22
src/resources/liteyuki_statistics/templates/stat_msg.html
Normal file
@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns="http://www.w3.org/1999/html">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Liteyuki Stats Message</title>
|
||||
<link rel="stylesheet" href="./css/card.css">
|
||||
<link rel="stylesheet" href="./css/fonts.css">
|
||||
<link rel="stylesheet" href="./css/stat_msg.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<template id="sign-chart-template">
|
||||
<div class="info-box sign-chart">
|
||||
</div>
|
||||
</template>
|
||||
<div class="data-storage" id="data">{{ data | tojson }}</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.5.0/echarts.min.js"></script>
|
||||
<script src="./js/stat_msg.js"></script>
|
||||
<script src="./js/card.js"></script>
|
||||
</body>
|
54
src/resources/liteyuki_statistics/templates/stat_rank.html
Normal file
54
src/resources/liteyuki_statistics/templates/stat_rank.html
Normal file
@ -0,0 +1,54 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns="http://www.w3.org/1999/html">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Liteyuki Stats Message</title>
|
||||
<link rel="stylesheet" href="./css/card.css">
|
||||
<link rel="stylesheet" href="./css/fonts.css">
|
||||
<link rel="stylesheet" href="./css/stat_rank.css">
|
||||
<style>
|
||||
.row {
|
||||
height: 100px;
|
||||
display: flex;
|
||||
background-color: rgba(255, 255, 255, 0.9);
|
||||
border-radius: 100px;
|
||||
margin-bottom: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.row-name {
|
||||
font-size: 40px;
|
||||
align-content: center;
|
||||
width: 100px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.row-icon {
|
||||
border-radius: 50%;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.row-count {
|
||||
align-content: center;
|
||||
font-size: 40px;
|
||||
/* 靠右*/
|
||||
margin-left: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<template id="row-template">
|
||||
<div class="row">
|
||||
<img src="./img/arrow-up.svg" alt="up" class="row-icon">
|
||||
<div class="row-name"></div>
|
||||
<div class="row-count"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="data-storage" id="data">{{ data | tojson }}</div>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.5.0/echarts.min.js"></script>
|
||||
<script src="./js/stat_rank.js"></script>
|
||||
<script src="./js/card.js"></script>
|
||||
</body>
|
Reference in New Issue
Block a user