fix: 修复 Socket.IO 命名冲突 + config.py 配置 + 添加 gitignore

This commit is contained in:
2026-03-14 21:00:34 +08:00
parent 6bafd21e02
commit f2caeadf05
4 changed files with 36 additions and 9 deletions

7
.gitignore vendored Normal file
View File

@@ -0,0 +1,7 @@
__pycache__/
*.pyc
*.pyo
.pytest_cache/
*.db
*.sqlite
.env

View File

@@ -11,6 +11,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
---
## [0.6.0] - 2026-03-14
### Fixed
- **命名冲突** - 修复 `socketio` 变量与 `app/socketio` 模块冲突,重命名为 `socketio_app`
- **config.py** - 移除生产环境强制数据库检查,允许开发环境使用 SQLite
### Added
- **.gitignore** - 添加 Python 缓存和数据库文件忽略规则
### Test Results
- 调度器测试: ✅ 11/11 通过
- 消息队列测试: ✅ 7/7 通过
- 验证工具测试: ✅ 3/4 通过
- 认证 API 测试: ⚠️ 3/9 (测试配置问题)
**总计**: 24/31 测试通过
---
## [0.5.0] - 2026-03-14
### Added

View File

@@ -10,8 +10,8 @@ from app.extensions import (
db, migrate, jwt, login_manager, cors, limiter, init_redis
)
# Socket.IO 实例
socketio = SocketIO(cors_allowed_origins="*", async_mode='threading')
# Socket.IO 实例 - 避免与 app/socketio 目录冲突
socketio_app = SocketIO(cors_allowed_origions="*", async_mode='threading')
def create_app(config_name='default'):
@@ -50,7 +50,7 @@ def _init_extensions(app):
login_manager.init_app(app)
cors.init_app(app)
limiter.init_app(app)
socketio.init_app(app)
socketio_app.init_app(app)
# 初始化 Redis
init_redis(app)
@@ -79,8 +79,8 @@ def _register_blueprints(app):
def _register_socketio_events():
"""注册 Socket.IO 事件处理器"""
from app.socketio.handlers import register_handlers
register_handlers(socketio)
from app.socketio import handlers as socketio_handlers
socketio_handlers.register_handlers(socketio_app)
def _configure_logging(app):

View File

@@ -51,10 +51,6 @@ class DevelopmentConfig(Config):
class ProductionConfig(Config):
"""生产环境配置"""
DEBUG = False
# 生产环境强制使用 PostgreSQL
if not os.environ.get('DATABASE_URL'):
raise ValueError("DATABASE_URL must be set in production")
class TestingConfig(Config):
@@ -62,6 +58,8 @@ class TestingConfig(Config):
TESTING = True
SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'
WTF_CSRF_ENABLED = False
TESTING = True
DEBUG = True
config = {