管理后台 server 使用蓝图模式,降低维护成本,降低修改功能时对其他模块的影响

This commit is contained in:
liuwei
2025-04-03 12:08:53 +08:00
parent 43a6d39b4c
commit 343fc2060f
2 changed files with 10 additions and 3 deletions

View File

@@ -3,7 +3,7 @@ from .auth import login_required
import logging
# 创建联系人管理蓝图
contacts_bp = Blueprint('contacts', __name__, url_prefix='/contacts')
contacts_bp = Blueprint('contacts', __name__)
logger = logging.getLogger("ContactsBlueprint")
# 联系人管理页面

View File

@@ -48,9 +48,9 @@ def api_wx_logs():
lines = request.args.get('lines', 100, type=int) # 默认显示最后100行
# 修正日志文件路径计算,获取项目根目录
# 从当前文件位置向上导航4层到项目根目录
# 从当前文件位置向上导航3层到项目根目录
# blueprints -> dashboard -> admin -> WeChatRobot
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..'))
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
if log_type == 'error':
log_file = os.path.join(project_root, 'wx_error.log')
@@ -67,6 +67,13 @@ def api_wx_logs():
log_content = list(deque(f, lines))
else:
logger.warning(f"日志文件不存在: {log_file}")
# 尝试列出项目根目录下的所有日志文件,帮助调试
try:
all_files = [f for f in os.listdir(project_root) if f.endswith('.log')]
logger.info(f"项目根目录下的日志文件: {all_files}")
except Exception as e:
logger.error(f"列出目录文件失败: {e}")
return jsonify({
"success": True,