mirror of
https://github.com/hyb-oyqq/FRAISEMOE-Addons-Installer-NEXT.git
synced 2025-12-16 11:50:29 +00:00
- 在主窗口中添加优雅的线程清理逻辑,确保在退出时安全停止所有后台线程,避免潜在的资源泄漏。 - 更新离线模式管理器和哈希线程,增强对线程引用的管理,确保在操作完成后及时清理引用。 - 改进补丁检测器,支持在离线模式下的补丁状态检查,提升用户体验和系统稳定性。 - 增强日志记录,确保在关键操作中提供详细的调试信息,便于后续排查和用户反馈。
62 lines
2.3 KiB
Python
62 lines
2.3 KiB
Python
import sys
|
|
import os
|
|
import datetime
|
|
from PySide6.QtWidgets import QApplication, QMessageBox
|
|
from main_window import MainWindow
|
|
from core.managers.privacy_manager import PrivacyManager
|
|
from utils.logger import setup_logger
|
|
from config.config import LOG_FILE, APP_NAME
|
|
from utils import load_config
|
|
|
|
if __name__ == "__main__":
|
|
# 设置主日志
|
|
logger = setup_logger("main")
|
|
logger.info("应用启动")
|
|
|
|
# 检查配置中是否启用了调试模式
|
|
config = load_config()
|
|
debug_mode = config.get("debug_mode", False)
|
|
|
|
# 如果调试模式已启用,确保立即创建主日志文件
|
|
if debug_mode:
|
|
try:
|
|
# 确保log目录存在
|
|
log_dir = os.path.dirname(LOG_FILE)
|
|
if not os.path.exists(log_dir):
|
|
os.makedirs(log_dir, exist_ok=True)
|
|
logger.info(f"已创建日志目录: {log_dir}")
|
|
|
|
# 创建新的日志文件(使用覆盖模式)
|
|
with open(LOG_FILE, 'w', encoding='utf-8') as f:
|
|
current_time = datetime.datetime.now()
|
|
formatted_date = current_time.strftime("%Y-%m-%d")
|
|
formatted_time = current_time.strftime("%H:%M:%S")
|
|
f.write(f"--- 新调试会话开始于 {os.path.basename(LOG_FILE)} ---\n")
|
|
f.write(f"--- 应用版本: {APP_NAME} ---\n")
|
|
f.write(f"--- 日期: {formatted_date} 时间: {formatted_time} ---\n\n")
|
|
|
|
logger.info(f"调试模式已启用,日志文件路径: {os.path.abspath(LOG_FILE)}")
|
|
except Exception as e:
|
|
logger.error(f"创建日志文件失败: {e}")
|
|
|
|
app = QApplication(sys.argv)
|
|
|
|
try:
|
|
privacy_manager = PrivacyManager()
|
|
except Exception as e:
|
|
logger.error(f"初始化隐私协议管理器失败: {e}")
|
|
QMessageBox.critical(
|
|
None,
|
|
"隐私协议加载错误",
|
|
f"无法加载隐私协议管理器,程序将退出。\n\n错误信息:{e}"
|
|
)
|
|
sys.exit(1)
|
|
|
|
if not privacy_manager.show_privacy_dialog():
|
|
logger.info("用户未同意隐私协议,程序退出")
|
|
sys.exit(0)
|
|
|
|
logger.info("隐私协议已同意,启动主程序")
|
|
window = MainWindow()
|
|
window.show()
|
|
sys.exit(app.exec()) |