Skip to content

Commit 5575a17

Browse files
committed
[chore]: 更新项目依赖和构建配置,优化代码结构,新增SFTP上传功能
- 将项目全局Qt版本从6.8.1升级至6.9.0(涉及GitHub Actions、CMake配置、打包脚本等) - 重构HttpClient模块: - 新增`httpclient_unittest.cc`单元测试文件 - 调整CMake目标名称和QMake项目配置 - 移除冗余的`reply->setParent(this)`调用 - 优化服务器组件代码规范: - 统一构造函数初始化列表格式 - 补充缺失的`QDebug`头文件包含 - 更新打包系统配置: - 修改macOS/Linux/Windows平台的Qt路径配置 - 新增paramiko依赖支持SFTP大文件分块上传 - 实现文件传输进度显示和格式化字节单位功能
1 parent 2a468d2 commit 5575a17

18 files changed

Lines changed: 116 additions & 35 deletions

File tree

.github/actions/install-dependencies/action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ inputs:
1313
qt_ver:
1414
description: 'qt version'
1515
required: false
16-
default: '6.8.1'
16+
default: '6.9.0'
1717
type: string
1818

1919
runs:
@@ -32,7 +32,6 @@ runs:
3232
if: startsWith(runner.os, 'macOS')
3333
shell: bash
3434
run: |
35-
brew install ninja
3635
ninja --version
3736
cmake --version
3837
clang --version

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
},
55
"cmake.generator": "Ninja",
66
"cmake.environment": {
7-
"PATH": "C:\\Qt\\6.8.1\\msvc2022_64\\bin;${env:PATH};"
7+
"PATH": "C:\\Qt\\6.9.0\\msvc2022_64\\bin;${env:PATH};"
88
}
99
}

HttpClient/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
set(PROJECT_SOURCES main.cpp httpclient.cc httpclient.hpp)
1+
set(PROJECT_SOURCES httpclient_unittest.cc httpclient.cc httpclient.hpp)
22

3-
qt_add_executable(HttpClient MANUAL_FINALIZATION ${PROJECT_SOURCES})
4-
target_link_libraries(HttpClient PRIVATE Qt::Network Qt::Concurrent Qt::Test)
5-
qt_finalize_executable(HttpClient)
3+
qt_add_executable(httpclient_unittest MANUAL_FINALIZATION ${PROJECT_SOURCES})
4+
target_link_libraries(httpclient_unittest PRIVATE Qt::Network Qt::Concurrent
5+
Qt::Test)
6+
qt_finalize_executable(httpclient_unittest)

HttpClient/HttpClient.pro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ DEFINES += QT_DEPRECATED_WARNINGS
1616
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
1717

1818
SOURCES += \
19-
httpclient.cc \
20-
main.cpp
19+
httpclient.cc \
20+
httpclient_unittest.cc
2121

2222
HEADERS += \
2323
httpclient.hpp

HttpClient/httpclient.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ QNetworkReply *HttpClient::sendRequest(Method method,
117117
d_ptr->methodToString(method),
118118
QJsonDocument(body).toJson(
119119
QJsonDocument::Compact));
120-
reply->setParent(this);
121120
connect(reply, &QNetworkReply::finished, this, &HttpClient::onReplyFinish);
122121
connect(reply, &QNetworkReply::errorOccurred, this, &HttpClient::onErrorOccurred);
123122
connect(reply, &QNetworkReply::sslErrors, this, &HttpClient::onSslErrors);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,4 @@ private slots:
210210

211211
QTEST_MAIN(HttpClientTest)
212212

213-
#include "main.moc"
213+
#include "httpclient_unittest.moc"

MulServer/accepter.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#include "accepter.h"
22
#include "tcpserver.h"
33

4-
Accepter::Accepter(quint16 port_, QObject *parent)
5-
:QThread(parent)
6-
,port(port_)
7-
{
4+
#include <QDebug>
85

9-
}
6+
Accepter::Accepter(quint16 port_, QObject *parent)
7+
: QThread(parent)
8+
, port(port_)
9+
{}
1010

1111
Accepter::~Accepter()
1212
{
13-
if(isRunning()){
13+
if (isRunning()) {
1414
quit();
1515
wait();
1616
}
@@ -24,8 +24,9 @@ void Accepter::run()
2424
connect(tcpServer.data(), &TcpServer::message, this, &Accepter::message);
2525
connect(tcpServer.data(), &TcpServer::maxCount, this, &Accepter::maxCount);
2626
connect(tcpServer.data(), &TcpServer::clientCount, this, &Accepter::clientCount);
27-
if(!tcpServer->listen(QHostAddress::Any, port)){
28-
qDebug() << "TcpServer online failure: " << tcpServer->errorString() << QThread::currentThreadId();
27+
if (!tcpServer->listen(QHostAddress::Any, port)) {
28+
qDebug() << "TcpServer online failure: " << tcpServer->errorString()
29+
<< QThread::currentThreadId();
2930
return;
3031
}
3132
qDebug() << "TcpServer online: " << QThread::currentThreadId();

MulServer/tcpserver.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#include "tcpserver.h"
22
#include "thread.h"
33

4+
#include <QDebug>
5+
46
TcpServer::TcpServer(QObject *parent)
5-
:QTcpServer(parent)
7+
: QTcpServer(parent)
68
{
79
qRegisterMetaType<qintptr>("qintptr");
810
qRegisterMetaType<QAtomicInt>("QAtomicInt");

ReactorServer/accepter.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
#include "accepter.h"
22
#include "tcpserver.h"
33

4-
Accepter::Accepter(quint16 port_, int num_, QObject *parent)
5-
:QThread(parent)
6-
,port(port_)
7-
,num(num_)
8-
{
4+
#include <QDebug>
95

10-
}
6+
Accepter::Accepter(quint16 port_, int num_, QObject *parent)
7+
: QThread(parent)
8+
, port(port_)
9+
, num(num_)
10+
{}
1111

1212
Accepter::~Accepter()
1313
{
14-
if(isRunning()){
14+
if (isRunning()) {
1515
quit();
1616
wait();
1717
}
@@ -25,8 +25,9 @@ void Accepter::run()
2525
connect(tcpServer.data(), &TcpServer::message, this, &Accepter::message);
2626
connect(tcpServer.data(), &TcpServer::maxCount, this, &Accepter::maxCount);
2727
connect(tcpServer.data(), &TcpServer::clientCount, this, &Accepter::clientCount);
28-
if(!tcpServer->listen(QHostAddress::Any, port)){
29-
qDebug() << "TcpServer online failure: " << tcpServer->errorString() << QThread::currentThreadId();
28+
if (!tcpServer->listen(QHostAddress::Any, port)) {
29+
qDebug() << "TcpServer online failure: " << tcpServer->errorString()
30+
<< QThread::currentThreadId();
3031
return;
3132
}
3233
qDebug() << "TcpServer online: " << QThread::currentThreadId();

ReactorServer/tcpserver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include "subreactor.h"
33
#include "thread.h"
44

5+
#include <QDebug>
6+
57
class TcpServerPrivate
68
{
79
public:

0 commit comments

Comments
 (0)