refactor: 重构后端结构并迁移前端到 Vue3

This commit is contained in:
2026-05-15 11:46:21 +08:00
parent 9107378fcc
commit 9c5a5a54c6
165 changed files with 5057 additions and 62710 deletions
+44
View File
@@ -0,0 +1,44 @@
from fastapi import APIRouter
from app.config import CACHE_DIR
from app.utils.files import format_size, get_dir_size
router = APIRouter(tags=["cache"])
@router.get("/api/cache/size")
async def get_cache_size():
if not CACHE_DIR.exists():
return {
"success": True,
"size_bytes": 0,
"size_formatted": "0 B",
"file_count": 0,
"dir_count": 0,
}
total_size = 0
file_count = 0
dir_count = 0
try:
for item in CACHE_DIR.iterdir():
if item.name == "history.json":
continue
if item.is_dir():
dir_count += 1
elif item.is_file():
file_count += 1
total_size += get_dir_size(item)
except (PermissionError, OSError) as exc:
return {"success": False, "error": str(exc), "size_formatted": "计算失败"}
return {
"success": True,
"size_bytes": total_size,
"size_formatted": format_size(total_size),
"file_count": file_count,
"dir_count": dir_count,
}