项目整理:添加Cookie Cloud下载功能、优化前端界面、配置改为config.json、打包脚本、清理无用文件
This commit is contained in:
+31
-10
@@ -1,15 +1,36 @@
|
||||
"""
|
||||
配置文件
|
||||
配置文件 - 从 config.json 读取配置,支持环境变量覆盖
|
||||
"""
|
||||
# 后台服务地址
|
||||
BACKEND_URL = "http://localhost:5000"
|
||||
import json
|
||||
import os
|
||||
|
||||
# 浏览器配置
|
||||
BROWSER_TYPE = "edge" # edge 或 chrome
|
||||
HEADLESS_MODE = False # 是否无头模式
|
||||
_config = {}
|
||||
|
||||
# 检测间隔(秒)
|
||||
CHECK_INTERVAL = 30
|
||||
def _load_config():
|
||||
global _config
|
||||
config_path = os.path.join(os.path.dirname(__file__), 'config.json')
|
||||
defaults = {
|
||||
'backend_url': 'http://localhost:5000',
|
||||
'browser_type': 'edge',
|
||||
'headless_mode': False,
|
||||
'page_load_timeout': 30
|
||||
}
|
||||
if os.path.exists(config_path):
|
||||
with open(config_path, 'r', encoding='utf-8') as f:
|
||||
_config = {**defaults, **json.load(f)}
|
||||
else:
|
||||
_config = defaults
|
||||
|
||||
# 页面加载超时时间(秒)
|
||||
PAGE_LOAD_TIMEOUT = 30
|
||||
def get(key, default=None):
|
||||
if not _config:
|
||||
_load_config()
|
||||
return _config.get(key.upper(), _config.get(key, default))
|
||||
|
||||
# 兼容旧接口
|
||||
BACKEND_URL = os.environ.get('BACKEND_URL') or get('backend_url', 'http://localhost:5000')
|
||||
BROWSER_TYPE = os.environ.get('BROWSER_TYPE') or get('browser_type', 'edge')
|
||||
HEADLESS_MODE = os.environ.get('HEADLESS_MODE') or get('headless_mode', False)
|
||||
if isinstance(HEADLESS_MODE, str):
|
||||
HEADLESS_MODE = HEADLESS_MODE.lower() in ('true', '1', 'yes')
|
||||
CHECK_INTERVAL = int(os.environ.get('CHECK_INTERVAL') or get('check_interval', 30))
|
||||
PAGE_LOAD_TIMEOUT = int(os.environ.get('PAGE_LOAD_TIMEOUT') or get('page_load_timeout', 30))
|
||||
|
||||
Reference in New Issue
Block a user