feat(project): 初始化项目结构和配置

- 添加.gitignore和.flaskenv环境配置文件
- 创建Flask应用基础架构,包括models、services、utils模块
- 配置数据库模型User和Setting,集成SQLAlchemy和Alembic迁移
- 添加前端Vue项目结构,包含Element Plus组件库
- 配置前后端API路由和蓝prints模块
- 实现书籍下载服务BookService功能模块
- 添加代码规范配置.editorconfig、.oxfmtrc.json、.oxlintrc.json
- 配置VSCode推荐插件和前端构建工具链
- 实现文件服务FileService和相关业务逻辑
This commit is contained in:
2026-04-19 15:43:45 +08:00
parent b9fad6344f
commit ade1b6c9b0
63 changed files with 9610 additions and 1 deletions
+46
View File
@@ -0,0 +1,46 @@
import os
from typing import Optional, Callable, List
class FolderService:
def __init__(
self,
paths: List[str] | str,
ignore_dirs: Optional[set] = None,
folder_callback: Optional[Callable] = None,
file_callback: Optional[Callable] = None,
empty_folder_callback: Optional[Callable] = None,
max_depth: Optional[int] = None
):
self.paths: List[str] = paths if type(paths) is not str else [paths]
self.ignore_dirs = ignore_dirs or set()
self.folder_callback = folder_callback
self.file_callback = file_callback
self.empty_folder_callback = empty_folder_callback
self.max_depth = max_depth
def _traverse_folder(self, path: Optional[str] = None, depth: Optional[int] = 0) -> None:
"""处理目录"""
for entry in os.scandir(path):
if entry.name in self.ignore_dirs:
continue
if entry.is_dir():
# 判断要加载的文件夹深度
if self.max_depth is not None and depth >= self.max_depth:
return
# 循环加载
self._traverse_folder(entry.path, depth + 1)
# 判断是空文件夹
if not os.listdir(entry.path) and self.empty_folder_callback:
self.empty_folder_callback(entry)
# 文件夹处理的回调
if self.folder_callback:
self.folder_callback(entry)
elif entry.is_file():
if self.file_callback:
self.file_callback(entry)
def process_folder(self) -> None:
for path in self.paths:
if os.path.exists(path):
self._traverse_folder(path)