You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
950 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"""
PyQt5前端主程序入口
"""
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox
from frontend.main_window import MainWindow
from frontend.utils.api_client import APIClient
def check_backend_connection():
"""检查后端连接"""
try:
client = APIClient()
client._get("/health")
return True
except Exception as e:
return False
def main():
"""主函数"""
app = QApplication(sys.argv)
# 检查后端连接
if not check_backend_connection():
QMessageBox.critical(None, "连接失败", "无法连接到后端服务器!\n"
"请确保后端服务已启动(运行 python backend/main.py\n"
"错误信息:后端服务未运行或无法访问")
sys.exit(1)
# 创建主窗口
window = MainWindow()
window.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()