2022-04-26 14:45:04 +08:00
|
|
|
from datetime import datetime
|
2023-04-01 01:50:34 +08:00
|
|
|
from typing import Any, Dict, List, Optional, Union
|
2022-04-04 20:33:37 +08:00
|
|
|
|
2023-04-01 01:50:34 +08:00
|
|
|
import nonebot
|
|
|
|
|
from fastapi import APIRouter
|
|
|
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
|
from pydantic import BaseModel
|
2022-04-04 20:33:37 +08:00
|
|
|
|
|
|
|
|
app = nonebot.get_app()
|
|
|
|
|
|
2022-06-05 19:51:23 +08:00
|
|
|
origins = ["*"]
|
2022-04-04 20:33:37 +08:00
|
|
|
|
|
|
|
|
app.add_middleware(
|
|
|
|
|
CORSMiddleware,
|
|
|
|
|
allow_origins=origins,
|
|
|
|
|
allow_credentials=True,
|
|
|
|
|
allow_methods=["*"],
|
|
|
|
|
allow_headers=["*"],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RequestResult(BaseModel):
|
2022-04-26 14:45:04 +08:00
|
|
|
"""
|
|
|
|
|
好友/群组请求管理
|
|
|
|
|
"""
|
2023-04-01 01:50:34 +08:00
|
|
|
|
2022-04-04 20:33:37 +08:00
|
|
|
oid: str
|
|
|
|
|
id: int
|
|
|
|
|
flag: str
|
|
|
|
|
nickname: Optional[str]
|
|
|
|
|
level: Optional[int]
|
|
|
|
|
sex: Optional[str]
|
|
|
|
|
age: Optional[int]
|
|
|
|
|
from_: Optional[str]
|
|
|
|
|
comment: Optional[str]
|
|
|
|
|
invite_group: Optional[int]
|
|
|
|
|
group_name: Optional[str]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RequestParma(BaseModel):
|
2022-04-26 14:45:04 +08:00
|
|
|
"""
|
|
|
|
|
操作请求接收数据
|
|
|
|
|
"""
|
2023-04-01 01:50:34 +08:00
|
|
|
|
2022-04-04 20:33:37 +08:00
|
|
|
id: int
|
|
|
|
|
handle: str
|
|
|
|
|
type: str
|
|
|
|
|
|
|
|
|
|
|
2022-04-26 14:45:04 +08:00
|
|
|
class SystemStatus(BaseModel):
|
|
|
|
|
"""
|
|
|
|
|
系统状态
|
|
|
|
|
"""
|
2023-04-01 01:50:34 +08:00
|
|
|
|
2022-04-26 14:45:04 +08:00
|
|
|
cpu: int
|
|
|
|
|
memory: int
|
|
|
|
|
disk: int
|
|
|
|
|
check_time: datetime
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SystemNetwork(BaseModel):
|
|
|
|
|
"""
|
|
|
|
|
系统网络状态
|
|
|
|
|
"""
|
2023-04-01 01:50:34 +08:00
|
|
|
|
2022-04-26 14:45:04 +08:00
|
|
|
baidu: int
|
|
|
|
|
google: int
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SystemFolderSize(BaseModel):
|
|
|
|
|
"""
|
|
|
|
|
资源文件占比
|
|
|
|
|
"""
|
2023-04-01 01:50:34 +08:00
|
|
|
|
2022-04-26 14:45:04 +08:00
|
|
|
font_dir_size: float
|
|
|
|
|
image_dir_size: float
|
|
|
|
|
text_dir_size: float
|
|
|
|
|
record_dir_size: float
|
|
|
|
|
temp_dir_size: float
|
|
|
|
|
data_dir_size: float
|
|
|
|
|
log_dir_size: float
|
|
|
|
|
check_time: datetime
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SystemStatusList(BaseModel):
|
|
|
|
|
"""
|
|
|
|
|
状态记录
|
|
|
|
|
"""
|
2023-04-01 01:50:34 +08:00
|
|
|
|
2022-04-26 14:45:04 +08:00
|
|
|
cpu_data: List[Dict[str, Union[float, str]]]
|
|
|
|
|
memory_data: List[Dict[str, Union[float, str]]]
|
|
|
|
|
disk_data: List[Dict[str, Union[float, str]]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SystemResult(BaseModel):
|
|
|
|
|
"""
|
|
|
|
|
系统api返回
|
|
|
|
|
"""
|
2023-04-01 01:50:34 +08:00
|
|
|
|
2022-04-26 14:45:04 +08:00
|
|
|
status: SystemStatus
|
|
|
|
|
network: SystemNetwork
|
|
|
|
|
disk: SystemFolderSize
|
|
|
|
|
check_time: datetime
|