4dae7c18 by 柴进

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

1 parent 3c58ff8e
...@@ -114,17 +114,48 @@ class TaskQueueManager(QObject): ...@@ -114,17 +114,48 @@ class TaskQueueManager(QObject):
114 self.logger.info("TaskQueueManager 初始化完成") 114 self.logger.info("TaskQueueManager 初始化完成")
115 115
116 def _load_db_config(self): 116 def _load_db_config(self):
117 """加载数据库配置""" 117 """加载数据库配置(与 image_generator.py 相同的多路径逻辑)"""
118 try: 118 try:
119 import json 119 import json
120 import sys
121 import os
122 import platform
120 from pathlib import Path 123 from pathlib import Path
121 config_file = Path("config.json") 124
122 if config_file.exists(): 125 config_paths = []
123 with open(config_file, 'r', encoding='utf-8') as f: 126
124 config = json.load(f) 127 # 1. 用户配置目录(打包后优先)
125 self._db_config = config.get('db_config') 128 if getattr(sys, 'frozen', False):
126 if self._db_config: 129 system = platform.system()
127 self.logger.info("数据库配置已加载") 130 if system == 'Darwin':
131 user_config = Path.home() / 'Library' / 'Application Support' / 'ZB100ImageGenerator' / 'config.json'
132 elif system == 'Windows':
133 user_config = Path(os.getenv('APPDATA', Path.home())) / 'ZB100ImageGenerator' / 'config.json'
134 else:
135 user_config = Path.home() / '.config' / 'zb100imagegenerator' / 'config.json'
136 config_paths.append(user_config)
137
138 # 2. 可执行文件所在目录
139 config_paths.append(Path(sys.executable).parent / 'config.json')
140
141 # 3. PyInstaller _MEIPASS 目录
142 if hasattr(sys, '_MEIPASS'):
143 config_paths.append(Path(sys._MEIPASS) / 'config.json')
144
145 # 4. 当前工作目录(开发模式)
146 config_paths.append(Path('config.json'))
147
148 # 尝试所有路径
149 for config_file in config_paths:
150 if config_file.exists():
151 with open(config_file, 'r', encoding='utf-8') as f:
152 config = json.load(f)
153 self._db_config = config.get('db_config')
154 if self._db_config:
155 self.logger.info(f"数据库配置已加载: {config_file}")
156 return
157
158 self.logger.warning("未找到 config.json,日志记录将被禁用")
128 except Exception as e: 159 except Exception as e:
129 self.logger.warning(f"加载数据库配置失败: {e}") 160 self.logger.warning(f"加载数据库配置失败: {e}")
130 161
......