Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
fix network
Browse files Browse the repository at this point in the history
  • Loading branch information
xxzl0130 committed Oct 29, 2021
1 parent 95912bb commit 9c2b192
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
38 changes: 21 additions & 17 deletions ChipDataWindow/GetChipWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
#include "GetChipWindow.h"
#include "ui_GetChipWindow.h"
#include <QFile>
#include <QThread>

constexpr auto pacUrl = "http://static.xuanxuan.tech/GF/GF.pac";
constexpr auto serverHost = "https://codex.xuanxuan.tech:8080/";
static QString localHost = "http://127.0.0.1:8080";
static QString localHost = "http://127.0.0.1:8080/";
constexpr auto jsonPath = "chipJson";
#ifdef Q_OS_WIN
constexpr auto exeName = "GF_Tool_Server.exe";
Expand Down Expand Up @@ -190,25 +191,28 @@ void GetChipWindow::processError(QProcess::ProcessError error)

void GetChipWindow::processDataReady()
{
auto data = QString::fromUtf8(process_->readAllStandardOutput());
// 解析本地地址
if(data.indexOf(u8"代理地址") != -1)
while (process_->canReadLine())
{
auto lines = data.split("\n");
auto proxyList = lines[0].split(" ")[2].split(":");
this->localProxyAddr_ = proxyList[0];
this->localProxyPort_ = proxyList[1];
if(lines.size() > 1)
auto data = QString::fromUtf8(process_->readLine().trimmed());
if(data.startsWith(u8"代理地址"))
{
auto webList = lines[1].split(" ");
if(webList.size() > 2)
{
localHost = webList[2];
request_->setUrl(QUrl(QString(localHost) + localWebPort_ + "/" + jsonPath));
}
auto proxyList = data.split(" ")[2].split(":");
this->localProxyAddr_ = proxyList[0];
this->localProxyPort_ = proxyList[1];
setLocalProxy();
QMessageBox::information(this, trUtf8(u8"成功"), trUtf8(u8"本地代理程序启动成功!"));
}
else if(data.startsWith(u8"网页地址"))
{
auto webList = data.split(" ");
localHost = QString("http://127.0.0.1:%1/").arg(webList[2].split(":")[1]);
request_->setUrl(QUrl(localHost + jsonPath));
}
else if(data.contains(u8"失败"))
{
QMessageBox::warning(this, u8"失败", data);
return;
}
setLocalProxy();
QMessageBox::information(this, trUtf8(u8"成功"), trUtf8(u8"本地代理程序启动成功!"));
}
}

Expand Down
2 changes: 1 addition & 1 deletion ChipDataWindow/GetChipWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ protected slots:
QNetworkRequest* request_;
QNetworkAccessManager* accessManager_;
QProcess* process_;
QString localProxyAddr_, localProxyPort_, localWebPort_;
QString localProxyAddr_, localProxyPort_;
};
2 changes: 1 addition & 1 deletion CodeX/AboutDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

AboutDialog::AboutDialog(QWidget *parent)
: QDialog(parent),
version(2,3,2),
version(2,3,3),
ui(new Ui::AboutDialog()),
accessManager_(new QNetworkAccessManager(this))
{
Expand Down

0 comments on commit 9c2b192

Please sign in to comment.