📝 新增全球统计

This commit is contained in:
snowy 2024-08-01 12:23:56 +08:00
parent 6ba983fae3
commit 850dd75822
7 changed files with 88 additions and 5 deletions

View File

@ -1,11 +1,16 @@
import {defineClientConfig} from "vuepress/client"; import {defineClientConfig} from "vuepress/client";
import resourceStoreComp from "./components/ResStore.vue"; import resourceStoreComp from "./components/ResStore.vue";
import pluginStoreComp from "./components/PluginStore.vue"; import pluginStoreComp from "./components/PluginStore.vue";
//导入element-plus import dashComp from "./components/Dash.vue";
import ElementPlus from 'element-plus'; import ElementPlus from 'element-plus';
export default defineClientConfig({ export default defineClientConfig({
enhance: ({app, router, siteData}) => { enhance: ({app, router, siteData}) => {
app.component("dashComp", dashComp);
app.component("resourceStoreComp", resourceStoreComp); app.component("resourceStoreComp", resourceStoreComp);
app.component("pluginStoreComp", pluginStoreComp); app.component("pluginStoreComp", pluginStoreComp);
app.use(ElementPlus); app.use(ElementPlus);

View File

@ -0,0 +1,38 @@
<script setup lang="ts">
import {ref} from "vue";
let total = ref(0);
let online = ref(0);
fetch("https://api.liteyuki.icu/count")
.then(res => res.json())
.then(data => {
total.value = data.register;
})
.catch(err => console.error(err));
fetch("https://api.liteyuki.icu/online")
.then(res => res.json())
.then(data => {
online.value = data.online;
})
.catch(err => console.error(err));
</script>
<template>
<div class="info-box">
<h1>Dashboard</h1>
<div class="info">
<div class="info-item">
<h2>Total</h2>
<p>{{ total }}</p>
</div>
<div class="info-item">
<h2>Online</h2>
<p>{{ online }}</p>
</div>
</div>
</div>
</template>
<style scoped>
</style>

View File

@ -11,6 +11,7 @@ export default defineUserConfig({
head: [ head: [
// 设置 favor.ico.vuepress/public 下 // 设置 favor.ico.vuepress/public 下
["script", {src: "/js/style.js", "type": "module"}], ["script", {src: "/js/style.js", "type": "module"}],
["script", {src: "/js/get_data.js", "type": "module"}],
['link', {rel: 'icon', href: 'https://cdn.liteyuki.icu/favicon.ico'},], ['link', {rel: 'icon', href: 'https://cdn.liteyuki.icu/favicon.ico'},],
['link', {rel: 'stylesheet', href: 'https://cdn.bootcdn.net/ajax/libs/firacode/6.2.0/fira_code.min.css'}], ['link', {rel: 'stylesheet', href: 'https://cdn.bootcdn.net/ajax/libs/firacode/6.2.0/fira_code.min.css'}],

View File

@ -0,0 +1 @@

View File

@ -1,10 +1,15 @@
function applyStyle() { function applyStyle() {
// 先检测页面中是否有macos-tab有则不再添加
let tabs = document.body.querySelectorAll('.macos-tab')
if (tabs.length > 0) {
return
}
let lineNumbers = document.body.querySelectorAll('[class^="language-"].line-numbers-mode') let lineNumbers = document.body.querySelectorAll('[class^="language-"].line-numbers-mode')
lineNumbers.forEach((item) => { lineNumbers.forEach((item) => {
// 插入现成的html文本 // 插入现成的html文本
let title = item.getAttribute('data-title') let title = item.getAttribute('data-title')
let tabStr = let tabStr =
"<div class='tab' style='display: flex; background-color: #d0e9ff'>" + "<div class='tab macos-tab' style='display: flex; background-color: #d0e9ff'>" +
" <div class='tab-buttons'>" + " <div class='tab-buttons'>" +
" <div class='tab-button' style='background-color: #FF5F57'></div>" + " <div class='tab-button' style='background-color: #FF5F57'></div>" +
" <div class='tab-button' style='background-color: #FFBD2E'></div>" + " <div class='tab-button' style='background-color: #FFBD2E'></div>" +
@ -19,4 +24,8 @@ function applyStyle() {
} }
applyStyle() applyStyle()
// 定时器每隔1s检查一次
setInterval(() => {
applyStyle()
}, 1000)

View File

@ -9,7 +9,7 @@ bgImageDark:
bgImageStyle: bgImageStyle:
background-attachment: fixed background-attachment: fixed
heroText: LiteyukiBot heroText: LiteyukiBot
tagline: LiteyukiBot 轻雪机器人基于NoneBot2构建的综合应用型聊天机器人 tagline: LiteyukiBot 轻雪机器人基于NoneBot2构建的综合应用型聊天机器人<br><h4>总实例:<span id="total">0</span>&nbsp;&nbsp;&nbsp;&nbsp;当前在线:<span id="online">0</span></h4>
actions: actions:
- text: 快速部署 - text: 快速部署
@ -79,4 +79,32 @@ highlights:
details: 如果你有多个 Python 环境,请使用 <code>pythonx -m pip install -r requirements.txt</code> details: 如果你有多个 Python 环境,请使用 <code>pythonx -m pip install -r requirements.txt</code>
- title: 使用 <code>python main.py</code> 启动项目。 - title: 使用 <code>python main.py</code> 启动项目。
copyright: © 2021-2024 SnowyKami All Rights Reserved copyright: © 2021-2024 SnowyKami All Rights Reserved
--- ---
<script>
function updatePageData() {
fetch("https://api.liteyuki.icu/count")
.then(res => res.json())
.then(data => {
let total = document.getElementById("total");
if(total !== null) {
total.innerText = data.register;
}
})
.catch(err => console.error(err));
fetch("https://api.liteyuki.icu/online")
.then(res => res.json())
.then(data => {
let online = document.getElementById("online");
if(online !== null) {
online.innerText = data.online;
}
})
.catch(err => console.error(err));
}
updatePageData();
setInterval(updatePageData, 1000);
</script>

View File

@ -4,4 +4,5 @@ icon: box
order: 1 order: 1
category: 使用手册 category: 使用手册
--- ---
<resourceStoreComp />
<resourceStoreComp />