feat: 完成macOS应用打包功能

This commit is contained in:
ruisu
2025-02-19 16:29:59 +08:00
parent 6a00193333
commit 0b6b3f13aa
7 changed files with 253 additions and 8 deletions

View File

@@ -7,6 +7,42 @@ from PyQt6.QtCore import Qt, QTimer, QPropertyAnimation
from PyQt6.QtGui import QIcon, QPixmap
import cursor_account_manager as backend
from logger import logging
import traceback
# 设置日志文件路径
def setup_logging():
try:
# 获取应用程序所在目录
if getattr(sys, 'frozen', False):
# 如果是打包后的应用程序
app_dir = os.path.dirname(sys.executable)
else:
# 如果是开发环境
app_dir = os.path.dirname(os.path.abspath(__file__))
# 创建日志目录
log_dir = os.path.join(app_dir, 'logs')
os.makedirs(log_dir, exist_ok=True)
# 设置日志文件路径
log_file = os.path.join(log_dir, 'app.log')
# 配置日志记录
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s [%(levelname)s] %(message)s',
handlers=[
logging.FileHandler(log_file, encoding='utf-8'),
logging.StreamHandler()
]
)
logging.info('日志系统初始化成功')
logging.info(f'日志文件路径: {log_file}')
except Exception as e:
print(f"设置日志系统时出错: {str(e)}")
print(traceback.format_exc())
class SuccessDialog(QDialog):
def __init__(self, message, parent=None):
@@ -154,7 +190,7 @@ class PasswordDialog(QDialog):
class CursorGUI(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Cursor账号管理器 v3.5.3")
self.setWindowTitle("听泉Cursor助手 v3.0.2")
self.setFixedSize(600, 600)
# 设置整体样式
@@ -488,7 +524,27 @@ class CursorGUI(QMainWindow):
QMessageBox.information(self, "提示", "更新功能开发中")
if __name__ == "__main__":
app = QApplication(sys.argv)
window = CursorGUI()
window.show()
sys.exit(app.exec())
try:
# 初始化日志系统
setup_logging()
# 记录启动信息
logging.info("=== 应用程序启动 ===")
logging.info(f"Python 版本: {sys.version}")
logging.info(f"操作系统: {sys.platform}")
app = QApplication(sys.argv)
window = CursorGUI()
window.show()
# 捕获未处理的异常
def handle_exception(exc_type, exc_value, exc_traceback):
logging.error("未捕获的异常:", exc_info=(exc_type, exc_value, exc_traceback))
sys.excepthook = handle_exception
sys.exit(app.exec())
except Exception as e:
logging.error(f"程序启动失败: {str(e)}")
logging.error(traceback.format_exc())
raise