refactor: centralize configuration management with type-safe schema
Major changes: - Add dataclass-based configuration schema with validation (config/schema.py) - Create centralized config loader and default values (config/defaults.py, config/loader.py) - Remove duplicate database_config.py, merge into unified structure - Consolidate browser settings into ERP config - Add batch_size parameter support to extractor Bug fixes: - Fix settings save error by updating config paths (browser.* → erp.*) - Fix batch_size not being applied in data extraction Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,40 +1,23 @@
|
||||
"""
|
||||
用户配置模板
|
||||
用户配置模板(已废弃,保留用于向后兼容)
|
||||
|
||||
此文件包含用户配置的默认值和结构说明。
|
||||
实际配置保存在 config/user_settings.json
|
||||
此文件已迁移到:
|
||||
- config/schema.py - 配置结构定义
|
||||
- config/defaults.py - 默认配置值
|
||||
|
||||
请使用以下方式导入:
|
||||
```python
|
||||
from config.defaults import DEFAULT_APP_CONFIG
|
||||
from config.schema import AppConfig, ERPConfig, DatabaseConfig
|
||||
```
|
||||
"""
|
||||
|
||||
DEFAULT_SETTINGS = {
|
||||
"erp": {
|
||||
"url": "https://68.11.34.30:8082/",
|
||||
"username": "BLDpengqiangqiang",
|
||||
"password": "Cqbld123456.",
|
||||
"headless": True,
|
||||
"ignore_https_errors": True,
|
||||
"auto_close_browser": True
|
||||
},
|
||||
"database": {
|
||||
"server": "192.168.110.114",
|
||||
"database": "CompanyDB",
|
||||
"username": "peng",
|
||||
"password": "Cqbld123456."
|
||||
},
|
||||
"browser": {
|
||||
"headless": True,
|
||||
"ignore_https_errors": True,
|
||||
"auto_close": True
|
||||
},
|
||||
"paths": {
|
||||
"data_dir": "D:/python/playwrite/data/",
|
||||
"production_id_file": "ProductionID.txt",
|
||||
"default_output": "离散备料计划维护_合并.xlsx",
|
||||
"validation_output": "物料状态校验结果.xlsx"
|
||||
},
|
||||
"extraction": {
|
||||
"batch_size": 100,
|
||||
"verbose": True,
|
||||
"auto_convert": True,
|
||||
"merge_batches": True
|
||||
}
|
||||
}
|
||||
# 为了向后兼容,保留旧版本导入
|
||||
from config.defaults import DEFAULT_SETTINGS_DICT as DEFAULT_SETTINGS
|
||||
from config.schema import (
|
||||
AppConfig,
|
||||
ERPConfig,
|
||||
DatabaseConfig,
|
||||
PathConfig,
|
||||
ExtractionConfig,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user