瀏覽代碼

修改系统参数模块

zhoutao 2 月之前
父節點
當前提交
4547234e40
共有 5 個文件被更改,包括 54 次插入41 次删除
  1. 1 1
      gui8000.pro.user
  2. 34 27
      httpreq.cpp
  3. 0 1
      sysconfig.cpp
  4. 14 7
      sysconfig.ui
  5. 5 5
      ui_sysconfig.h

+ 1 - 1
gui8000.pro.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 12.0.1, 2025-01-02T11:13:54. -->
+<!-- Written by QtCreator 12.0.1, 2025-01-24T15:29:05. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>

+ 34 - 27
httpreq.cpp

@@ -6,57 +6,62 @@
 HttpReq::HttpReq(QObject *parent)
     : QObject{parent}
 {
-    m_pMainDlg = static_cast<MainDlg*>(parent);//保存主窗口指针
+    m_pMainDlg = static_cast<MainDlg *>(parent); // 保存主窗口指针
     init();
-
 }
 
-//模块初始化
-void HttpReq::init(){
+// 模块初始化
+void HttpReq::init()
+{
     m_pNetworkManager = new QNetworkAccessManager(this);
     return;
 }
 
-//配置网络参数
-quint8 HttpReq::configNetworkParam(QString strHostAddress, QString strPort){
-    //参数容错处理
-    if(strHostAddress.length() <= 0 || strPort.length() <= 0){
+// 配置网络参数
+quint8 HttpReq::configNetworkParam(QString strHostAddress, QString strPort)
+{
+    // 参数容错处理
+    if (strHostAddress.length() <= 0 || strPort.length() <= 0)
+    {
         return 1;
     }
 
-    //保存网络基地址参数
+    // 保存网络基地址参数
     m_strBaseUrl = strHostAddress + ":" + strPort + "/pcapi/bparam/";
 
     return 0;
 }
 
-//发送post请求
-//strApiName:API接口
-//jsonObject:json格式的数据
-//返回值,字符串
-QString HttpReq::sendPostReq(QString strApiName, QJsonObject jsonObject){
+// 发送post请求
+// strApiName:API接口
+// jsonObject:json格式的数据
+// 返回值,字符串
+QString HttpReq::sendPostReq(QString strApiName, QJsonObject jsonObject)
+{
     QString strBaseUrl = "";
     QNetworkReply *reply = NULL;
-    QEventLoop loop;// 创建一个局部事件循环
+    QEventLoop loop; // 创建一个局部事件循环
 
-    //组织网络地址
-    if(strApiName.length() <= 0){
+    // 组织网络地址
+    if (strApiName.length() <= 0)
+    {
         return QString();
     }
 
-    //网络地址
-    strBaseUrl = "http://" + m_strBaseUrl + strApiName;
+    // 网络地址
+    // strBaseUrl = "https://" + m_strBaseUrl + strApiName;
+    strBaseUrl = m_strBaseUrl + strApiName;
     QUrl hostUrl(strBaseUrl);
     QNetworkRequest request(hostUrl);
 
-    //设置请求头
+    // 设置请求头
     request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
 
-    //将json数据转成QByteArray数据
+    // 将json数据转成QByteArray数据
     QJsonDocument jsonDoc(jsonObject);
     QByteArray jsonData = jsonDoc.toJson();
 
-    //发送post请求,并等待返回
+    // 发送post请求,并等待返回
     reply = m_pNetworkManager->post(request, jsonData);
 
     // 将reply的finished信号连接到事件循环的quit槽,以便在请求完成时退出循环
@@ -65,12 +70,14 @@ QString HttpReq::sendPostReq(QString strApiName, QJsonObject jsonObject){
     // 执行事件循环,直到finished信号被触发
     loop.exec();
 
-    //检查返回结果
-    if (reply->error() == QNetworkReply::NoError) {
+    // 检查返回结果
+    if (reply->error() == QNetworkReply::NoError)
+    {
         return QString::fromUtf8(reply->readAll());
-        //return QString("上传数据成功");
-    } else {
+        // return QString("上传数据成功");
+    }
+    else
+    {
         return QString("上传数据失败");
     }
-
 }

+ 0 - 1
sysconfig.cpp

@@ -33,7 +33,6 @@ void sysconfig::configSignalSlot(){
 }
 
 void sysconfig::initUi(){
-    //ui->spinBoxHostPort->setValue(8090);
     selectAllItem();
     queryParam();
 }

+ 14 - 7
sysconfig.ui

@@ -87,7 +87,7 @@
             </size>
            </property>
            <property name="maxLength">
-            <number>30</number>
+            <number>32</number>
            </property>
            <property name="placeholderText">
             <string>http://www.xxx.com</string>
@@ -103,7 +103,7 @@
             </size>
            </property>
            <property name="text">
-            <string>IP或者域名</string>
+            <string>管理中心域名</string>
            </property>
           </widget>
          </item>
@@ -136,13 +136,13 @@
             </size>
            </property>
            <property name="minimum">
-            <number>1</number>
+            <number>80</number>
            </property>
            <property name="maximum">
-            <number>999999</number>
+            <number>65535</number>
            </property>
            <property name="value">
-            <number>8090</number>
+            <number>80</number>
            </property>
           </widget>
          </item>
@@ -216,14 +216,21 @@
      <item>
       <widget class="QLabel" name="label_10">
        <property name="text">
-        <string>1、同一个项目,系统参数仅需设置一次即可,设置后参数会被保存至本地电脑</string>
+        <string>1、同一个项目,系统参数仅需设置一次即可,设置后参数会被保存至本地电脑</string>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QLabel" name="label_6">
        <property name="text">
-        <string>2、管理中心URL和管理中心端口是网管服务器的地址与端口,在执行本地参数上传服务器时使用</string>
+        <string>2、管理中心URL:即http服务器的地址,可以是域名,也可以是ip</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>3、管理中心端口:即http服务器的监听端口,服务器需提前配置</string>
        </property>
       </widget>
      </item>

+ 5 - 5
ui_sysconfig.h

@@ -92,7 +92,7 @@ public:
         lineEditHostUrl = new QLineEdit(layoutWidget);
         lineEditHostUrl->setObjectName("lineEditHostUrl");
         lineEditHostUrl->setMinimumSize(QSize(500, 28));
-        lineEditHostUrl->setMaxLength(30);
+        lineEditHostUrl->setMaxLength(32);
 
         gridLayout->addWidget(lineEditHostUrl, 0, 2, 1, 1);
 
@@ -116,9 +116,9 @@ public:
         spinBoxHostPort = new QSpinBox(layoutWidget);
         spinBoxHostPort->setObjectName("spinBoxHostPort");
         spinBoxHostPort->setMinimumSize(QSize(500, 28));
-        spinBoxHostPort->setMinimum(1);
-        spinBoxHostPort->setMaximum(999999);
-        spinBoxHostPort->setValue(8090);
+        spinBoxHostPort->setMinimum(80);
+        spinBoxHostPort->setMaximum(65535);
+        spinBoxHostPort->setValue(80);
 
         gridLayout->addWidget(spinBoxHostPort, 1, 2, 1, 1);
 
@@ -206,7 +206,7 @@ public:
         groupBox->setTitle(QString());
         checkBoxHostUrl->setText(QString());
         label_3->setText(QCoreApplication::translate("sysconfig", "\347\256\241\347\220\206\344\270\255\345\277\203URL", nullptr));
-        lineEditHostUrl->setPlaceholderText(QCoreApplication::translate("sysconfig", "http://www.xxx.com", nullptr));
+        lineEditHostUrl->setPlaceholderText(QCoreApplication::translate("sysconfig", "https://www.xxx.com", nullptr));
         label_4->setText(QCoreApplication::translate("sysconfig", "IP\346\210\226\350\200\205\345\237\237\345\220\215", nullptr));
         checkBoxHostPort->setText(QString());
         label_5->setText(QCoreApplication::translate("sysconfig", "\347\256\241\347\220\206\344\270\255\345\277\203\347\253\257\345\217\243", nullptr));