Files
django.remote/main.py
2025-08-31 11:00:32 +08:00

49 lines
1.6 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 PySide6.QtWidgets import QApplication, QMainWindow, QTabWidget
from PySide6.QtCore import QSize
from loguru import logger
from server_connection_tab import ServerConnectionTab
from remote_commands_tab import RemoteCommandsTab
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
logger.info("初始化主窗口")
self.setWindowTitle("服务器管理工具")
self.setMinimumSize(QSize(800, 600))
# 创建标签页组件
self.tabs = QTabWidget()
self.setCentralWidget(self.tabs)
# 添加服务器连接标签页
self.server_connection_tab = ServerConnectionTab()
self.tabs.addTab(self.server_connection_tab, "服务器连接")
# 添加远程命令标签页
self.remote_commands_tab = RemoteCommandsTab()
self.tabs.addTab(self.remote_commands_tab, "远程命令")
# 连接标签页切换信号
self.tabs.currentChanged.connect(self.on_tab_changed)
logger.info("主窗口初始化完成")
def on_tab_changed(self, index):
logger.info(f"切换到标签页: {index}")
# 当切换到远程命令标签页时传递SSH客户端
if index == 1: # 远程命令标签页的索引
ssh_client = self.server_connection_tab.get_ssh_client()
self.remote_commands_tab.set_ssh_client(ssh_client)
if __name__ == "__main__":
logger.add("app.log", rotation="10 MB")
logger.info("启动应用程序")
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec())