4dae7c18 by 柴进

极速模式支持多张图协同出图,移除单张限制

1 parent 3c58ff8e
......@@ -114,17 +114,48 @@ class TaskQueueManager(QObject):
self.logger.info("TaskQueueManager 初始化完成")
def _load_db_config(self):
"""加载数据库配置"""
"""加载数据库配置(与 image_generator.py 相同的多路径逻辑)"""
try:
import json
import sys
import os
import platform
from pathlib import Path
config_file = Path("config.json")
config_paths = []
# 1. 用户配置目录(打包后优先)
if getattr(sys, 'frozen', False):
system = platform.system()
if system == 'Darwin':
user_config = Path.home() / 'Library' / 'Application Support' / 'ZB100ImageGenerator' / 'config.json'
elif system == 'Windows':
user_config = Path(os.getenv('APPDATA', Path.home())) / 'ZB100ImageGenerator' / 'config.json'
else:
user_config = Path.home() / '.config' / 'zb100imagegenerator' / 'config.json'
config_paths.append(user_config)
# 2. 可执行文件所在目录
config_paths.append(Path(sys.executable).parent / 'config.json')
# 3. PyInstaller _MEIPASS 目录
if hasattr(sys, '_MEIPASS'):
config_paths.append(Path(sys._MEIPASS) / 'config.json')
# 4. 当前工作目录(开发模式)
config_paths.append(Path('config.json'))
# 尝试所有路径
for config_file in config_paths:
if config_file.exists():
with open(config_file, 'r', encoding='utf-8') as f:
config = json.load(f)
self._db_config = config.get('db_config')
if self._db_config:
self.logger.info("数据库配置已加载")
self.logger.info(f"数据库配置已加载: {config_file}")
return
self.logger.warning("未找到 config.json,日志记录将被禁用")
except Exception as e:
self.logger.warning(f"加载数据库配置失败: {e}")
......