config_editor/main.py
2026-01-19 08:01:58 +00:00

39 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'''项目入口启动程序'''
import sys
from PyQt6.QtWidgets import QApplication
from login.login_dialog import LoginDialog
from main_window import ConfigEditor
def main():
app = QApplication(sys.argv)
app.setStyle('Fusion')
# 创建登录对话框
login_dialog = LoginDialog()
def on_login_success(username, user_config_path):
"""登录成功回调"""
# 注意:这里传递的是 user_config_path这是账密文件路径
# 而 ConfigEditor 需要的是要编辑的配置文件路径
print(f"[调试] 登录成功: 用户名={username}, 账密文件={user_config_path}")
# 创建主窗口,传递账密文件路径和用户名
# 主窗口会自己加载要编辑的配置文件
editor = ConfigEditor(user_config_path, username)
editor.show()
# 连接信号
login_dialog.login_success.connect(on_login_success)
# 显示登录对话框
result = login_dialog.exec()
# 如果登录对话框被取消(用户点击退出),则退出程序
if result == 0:
sys.exit(0)
# 登录成功后,启动应用程序的主事件循环
sys.exit(app.exec())
if __name__ == '__main__':
main()