feat: 完善 Web UI 细节
新增页面:
- session_detail.html - 会话详情独立页面
- channel_edit.html - 频道配置编辑独立页面
- 错误页面 (401/403/404/500)
功能优化:
- 添加错误处理器支持 HTML 响应
- 更新编辑按钮跳转独立页面
- 完善暗黑主题支持
作者: 小黑 🐶
This commit is contained in:
@@ -123,24 +123,34 @@ def _configure_logging(app):
|
||||
|
||||
def _register_error_handlers(app):
|
||||
"""注册错误处理器"""
|
||||
from flask import jsonify
|
||||
from flask import jsonify, render_template, request, render_template
|
||||
|
||||
@app.errorhandler(400)
|
||||
def bad_request(error):
|
||||
if request.accepts('text/html'):
|
||||
return render_template('errors/400.html', error=str(error)), 400
|
||||
return jsonify({'error': 'Bad Request', 'message': str(error)}), 400
|
||||
|
||||
@app.errorhandler(401)
|
||||
def unauthorized(error):
|
||||
if request.accepts('text/html'):
|
||||
return render_template('errors/401.html', error=str(error)), 401
|
||||
return jsonify({'error': 'Unauthorized', 'message': str(error)}), 401
|
||||
|
||||
@app.errorhandler(403)
|
||||
def forbidden(error):
|
||||
if request.accepts('text/html'):
|
||||
return render_template('errors/403.html', error=str(error)), 403
|
||||
return jsonify({'error': 'Forbidden', 'message': str(error)}), 403
|
||||
|
||||
@app.errorhandler(404)
|
||||
def not_found(error):
|
||||
if request.accepts('text/html'):
|
||||
return render_template('errors/404.html', error=str(error)), 404
|
||||
return jsonify({'error': 'Not Found', 'message': str(error)}), 404
|
||||
|
||||
@app.errorhandler(500)
|
||||
def internal_error(error):
|
||||
if request.accepts('text/html'):
|
||||
return render_template('errors/500.html', error=str(error)), 500
|
||||
return jsonify({'error': 'Internal Server Error', 'message': str(error)}), 500
|
||||
|
||||
Reference in New Issue
Block a user