Skip to content

Commit

Permalink
🐛 自检html修正
Browse files Browse the repository at this point in the history
  • Loading branch information
HibiKier committed Sep 6, 2024
1 parent 3b4c206 commit db9153f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 32 deletions.
9 changes: 6 additions & 3 deletions resources/template/check/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,15 @@ body {
.status-text {
font-family: 'fzrzFont';
color: #EC859F;
height: 90px;
display: flex;
height: 185px;
}

.status-text-title {
height: 25%;
/* height: 25%; */
display: flex;
/* justify-content: center; */
align-items: center;
font-size: 14px;
}

.tip {
Expand Down
16 changes: 4 additions & 12 deletions resources/template/check/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,10 @@
</div>
<div class="line"></div>
<div class="status-text">
<div>
<p class="status-text-title">CPU</p>
<p class="status-text-title">SYSTEM</p>
<p class="status-text-title">VERSION</p>
<p class="status-text-title">PLUGINS</p>
</div>
<div style="margin-left: 37px;">
<p class="status-text-title" style="font-size: 14px;line-height: 18.5px;">{{data.brand_raw}}</p>
<p class="status-text-title">{{data.system}}</p>
<p class="status-text-title">{{data.version}}</p>
<p class="status-text-title">{{data.plugin_count}} loaded</p>
</div>
<p class="status-text-title">CPU&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 12px;line-height: 18.5px;">{{data.brand_raw}}</span></p>
<p class="status-text-title">SYSTEM&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 13px;line-height: 18.5px;">{{data.system}}</span></p>
<p class="status-text-title">VERSION&nbsp;&nbsp;&nbsp;<span>{{data.version}}</span></p>
<p class="status-text-title">PLUGINS&nbsp;&nbsp;&nbsp;<span>{{data.plugin_count}} loaded</span></p>
</div>
</div>
<div class="tip">Create By Zhenxun</div>
Expand Down
10 changes: 5 additions & 5 deletions zhenxun/builtin_plugins/check/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from nonebot.rule import to_me
from nonebot.permission import SUPERUSER
from nonebot.plugin import PluginMetadata
from nonebot_plugin_session import EventSession
from nonebot_plugin_htmlrender import template_to_pic
from nonebot.rule import to_me
from nonebot_plugin_alconna import Alconna, Arparma, on_alconna
from nonebot_plugin_htmlrender import template_to_pic
from nonebot_plugin_session import EventSession

from zhenxun.configs.path_config import TEMPLATE_PATH
from zhenxun.configs.utils import PluginExtraData
from zhenxun.services.log import logger
from zhenxun.utils.enum import PluginType
from zhenxun.utils.message import MessageUtils
from zhenxun.configs.utils import PluginExtraData
from zhenxun.configs.path_config import TEMPLATE_PATH

from .data_source import get_status_info

Expand Down
31 changes: 19 additions & 12 deletions zhenxun/builtin_plugins/check/data_source.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import platform
from pathlib import Path
from dataclasses import dataclass
from pathlib import Path

import psutil
import cpuinfo
import nonebot
from pydantic import BaseModel
import psutil
from httpx import ConnectTimeout, NetworkError
from nonebot.utils import run_sync
from httpx import NetworkError, ConnectTimeout
from pydantic import BaseModel

from zhenxun.services.log import logger
from zhenxun.configs.config import BotConfig
from zhenxun.services.log import logger
from zhenxun.utils.http_utils import AsyncHttpx

BAIDU_URL = "https://www.baidu.com/"
Expand Down Expand Up @@ -105,11 +105,17 @@ def get_system_info(self):
"cpu_info": f"{self.cpu.usage}% - {self.cpu.freq}Ghz [{self.cpu.core} core]",
"cpu_process": psutil.cpu_percent(),
"ram_info": f"{self.ram.usage} / {self.ram.total} GB",
"ram_process": self.ram.usage / self.ram.total * 100,
"ram_process": (
0 if self.ram.total == 0 else (self.ram.usage / self.ram.total * 100)
),
"swap_info": f"{self.swap.usage} / {self.swap.total} GB",
"swap_process": self.swap.usage / self.swap.total * 100,
"swap_process": (
0 if self.swap.total == 0 else (self.swap.usage / self.swap.total * 100)
),
"disk_info": f"{self.disk.usage} / {self.disk.total} GB",
"disk_process": self.disk.usage / self.disk.total * 100,
"disk_process": (
0 if self.disk.total == 0 else (self.disk.usage / self.disk.total * 100)
),
}


Expand Down Expand Up @@ -142,10 +148,11 @@ async def __get_network_info():

def __get_version() -> str | None:
"""获取版本信息"""
with open(VERSION_FILE, encoding="utf-8") as f:
if text := f.read():
text.split(":")[-1]
return None
if VERSION_FILE.exists():
with open(VERSION_FILE, encoding="utf-8") as f:
if text := f.read():
return text.split(":")[-1]
return None


async def get_status_info() -> dict:
Expand Down

0 comments on commit db9153f

Please sign in to comment.