最初一个版本,已经初步实现各种功能
主页连接 远程命令 django Gunicorn操作
This commit is contained in:
119
main.py
Normal file
119
main.py
Normal file
@@ -0,0 +1,119 @@
|
||||
import sys
|
||||
import os
|
||||
from loguru import logger
|
||||
from PySide6.QtWidgets import QApplication, QMainWindow, QTabWidget
|
||||
from PySide6.QtCore import QTimer
|
||||
|
||||
from server_connection_tab import ServerConnectionTab
|
||||
from remote_command_tab import RemoteCommandTab
|
||||
from django_tab import DjangoTab
|
||||
from gunicorn_tab import GunicornTab
|
||||
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setWindowTitle("服务器管理工具")
|
||||
self.setGeometry(100, 100, 800, 600)
|
||||
|
||||
# 创建标签页
|
||||
self.tab_widget = QTabWidget()
|
||||
|
||||
# 服务器连接标签
|
||||
self.server_tab = ServerConnectionTab()
|
||||
self.tab_widget.addTab(self.server_tab, "服务器连接")
|
||||
|
||||
# 远程命令标签
|
||||
self.remote_tab = RemoteCommandTab(self.server_tab)
|
||||
self.tab_widget.addTab(self.remote_tab, "远程命令")
|
||||
|
||||
# Django标签
|
||||
self.django_tab = DjangoTab(self.server_tab)
|
||||
self.tab_widget.addTab(self.django_tab, "Django")
|
||||
|
||||
# Gunicorn标签
|
||||
self.gunicorn_tab = GunicornTab(self.server_tab)
|
||||
self.tab_widget.addTab(self.gunicorn_tab, "Gunicorn")
|
||||
|
||||
self.setCentralWidget(self.tab_widget)
|
||||
|
||||
# 连接标签切换事件
|
||||
self.tab_widget.currentChanged.connect(self.on_tab_changed)
|
||||
|
||||
# 设置样式
|
||||
self.setStyleSheet("""
|
||||
QMainWindow {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
QTabWidget::pane {
|
||||
border: 1px solid #c4c4c3;
|
||||
background: white;
|
||||
}
|
||||
QTabBar::tab {
|
||||
background: #e1e1e1;
|
||||
border: 1px solid #c4c4c3;
|
||||
padding: 8px 16px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
QTabBar::tab:selected {
|
||||
background: white;
|
||||
border-bottom-color: white;
|
||||
}
|
||||
QPushButton {
|
||||
background-color: #0078d4;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 16px;
|
||||
border-radius: 4px;
|
||||
font-weight: bold;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background-color: #106ebe;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background-color: #005a9e;
|
||||
}
|
||||
QPushButton:disabled {
|
||||
background-color: #cccccc;
|
||||
color: #666666;
|
||||
}
|
||||
QLineEdit {
|
||||
border: 1px solid #c4c4c3;
|
||||
padding: 6px;
|
||||
border-radius: 3px;
|
||||
background-color: white;
|
||||
}
|
||||
QTextEdit {
|
||||
border: 1px solid #c4c4c3;
|
||||
background-color: #f8f8f8;
|
||||
font-family: 'Consolas', 'Monaco', monospace;
|
||||
}
|
||||
QProgressBar {
|
||||
border: 1px solid #c4c4c3;
|
||||
border-radius: 3px;
|
||||
text-align: center;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
QProgressBar::chunk {
|
||||
background-color: #0078d4;
|
||||
}
|
||||
""")
|
||||
|
||||
def on_tab_changed(self, index):
|
||||
"""标签切换事件处理"""
|
||||
tab_text = self.tab_widget.tabText(index)
|
||||
if tab_text == "Gunicorn":
|
||||
# 切换到Gunicorn标签时自动检测服务状态
|
||||
logger.info("切换到Gunicorn标签,自动检测服务状态")
|
||||
# 延迟执行以确保UI完全加载
|
||||
QTimer.singleShot(500, self.gunicorn_tab.check_service_status)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logger.add("app.log", rotation="1 day", retention="7 days")
|
||||
logger.info("应用程序启动")
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
window = MainWindow()
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
||||
Reference in New Issue
Block a user