From 6728892e022adbe1e7cb24709dbfa517b433b7fc Mon Sep 17 00:00:00 2001 From: Chenx Dust Date: Thu, 16 Jul 2026 14:24:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E8=B7=B3=E8=BF=87?= =?UTF-8?q?=E4=BB=A5=E5=90=8E=E7=9A=84=E7=9F=AD=E4=BF=A1=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zjuconnectcontroller/zjuconnectcontroller.cpp | 8 +++- zjuconnectcontroller/zjuconnectcontroller.h | 2 +- zjuconnectmode.cpp | 44 +++++++++++++++++-- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/zjuconnectcontroller/zjuconnectcontroller.cpp b/zjuconnectcontroller/zjuconnectcontroller.cpp index 74421c9..05b2b0c 100644 --- a/zjuconnectcontroller/zjuconnectcontroller.cpp +++ b/zjuconnectcontroller/zjuconnectcontroller.cpp @@ -48,9 +48,13 @@ ZjuConnectController::ZjuConnectController(QWidget* parent) : QObject(parent) { emit graphCaptcha(graphFile); } - else if (output.contains("Please enter the SMS verification code: ") || output.contains("Please enter your SMS code:")) + else if (output.contains("Please enter the SMS verification code: ")) { - emit smsCode(); + emit smsCode(true); + } + else if (output.contains("Please enter your SMS code:")) + { + emit smsCode(false); } else if (output.contains("Please enter your TOTP code:")) { diff --git a/zjuconnectcontroller/zjuconnectcontroller.h b/zjuconnectcontroller/zjuconnectcontroller.h index 6862ac6..d682f6d 100644 --- a/zjuconnectcontroller/zjuconnectcontroller.h +++ b/zjuconnectcontroller/zjuconnectcontroller.h @@ -84,7 +84,7 @@ signals: void graphCaptcha(const QString &graphFile); - void smsCode(); + void smsCode(bool showSkipSecondaryAuthOption); void totpCode(); diff --git a/zjuconnectmode.cpp b/zjuconnectmode.cpp index 6f521fc..f7e4a53 100644 --- a/zjuconnectmode.cpp +++ b/zjuconnectmode.cpp @@ -1,6 +1,10 @@ #include #include +#include #include +#include +#include +#include #include #include "mainwindow.h" @@ -89,11 +93,43 @@ void MainWindow::initZjuConnect() }); }); - connect(zjuConnectController, &ZjuConnectController::smsCode, this, [&]() { + connect(zjuConnectController, &ZjuConnectController::smsCode, this, [&](bool showSkipSecondaryAuthOption) { addLog("需要短信验证码"); - QString smsCode = QInputDialog::getText(this, "短信验证码", "请输入短信验证码:"); - addLog("短信验证码用户输入:" + smsCode); - emit WriteToProcess(smsCode.toLocal8Bit() + "\n"); + + QDialog smsCodeDialog(this); + smsCodeDialog.setWindowTitle("短信验证码"); + + auto *dialogLayout = new QVBoxLayout(&smsCodeDialog); + dialogLayout->addWidget(new QLabel("请输入短信验证码:", &smsCodeDialog)); + + auto *smsCodeLineEdit = new QLineEdit(&smsCodeDialog); + dialogLayout->addWidget(smsCodeLineEdit); + + auto *skipSecondaryAuthCheckBox = new QCheckBox("跳过以后的短信验证", &smsCodeDialog); + skipSecondaryAuthCheckBox->setVisible(showSkipSecondaryAuthOption); + dialogLayout->addWidget(skipSecondaryAuthCheckBox); + + auto *buttonBox = new QDialogButtonBox( + QDialogButtonBox::Ok | QDialogButtonBox::Cancel, &smsCodeDialog); + connect(buttonBox, &QDialogButtonBox::accepted, &smsCodeDialog, &QDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, &smsCodeDialog, &QDialog::reject); + dialogLayout->addWidget(buttonBox); + + QString smsCode; + bool skipSecondaryAuth = false; + if (smsCodeDialog.exec() == QDialog::Accepted) + { + smsCode = smsCodeLineEdit->text(); + skipSecondaryAuth = showSkipSecondaryAuthOption && skipSecondaryAuthCheckBox->isChecked(); + } + + addLog("短信验证码用户输入:" + smsCode + (skipSecondaryAuth ? " (跳过以后的短信验证)" : "")); + QByteArray smsCodeInput = smsCode.toLocal8Bit(); + if (skipSecondaryAuth) + { + smsCodeInput.prepend('$'); + } + emit WriteToProcess(smsCodeInput + "\n"); }); connect(zjuConnectController, &ZjuConnectController::totpCode, this, [&]() {