mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 21:02:04 +08:00
enhance: 微小的改进
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include <QFile>
|
||||
|
||||
#include <DSysInfo>
|
||||
#include <QAtomicInt>
|
||||
|
||||
AppIntoPage::AppIntoPage(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
@@ -21,11 +22,15 @@ AppIntoPage::AppIntoPage(QWidget *parent)
|
||||
{
|
||||
initUI();
|
||||
initConnections();
|
||||
QString headers = "Mozilla/5.0 Spark-Store/"+ QString(APP_VERSION)+" (Linux; "+QSysInfo::prettyProductName().toUtf8()+";)";
|
||||
QByteArray ba = headers.toLatin1(); // must
|
||||
rawHeaders=ba.data();
|
||||
}
|
||||
|
||||
AppIntoPage::~AppIntoPage()
|
||||
{
|
||||
delete ui;
|
||||
free(rawHeaders);
|
||||
}
|
||||
|
||||
void AppIntoPage::openUrl(const QUrl &url)
|
||||
@@ -53,36 +58,41 @@ void AppIntoPage::openUrl(const QUrl &url)
|
||||
ui->label_2->setText(info["More"].toString());
|
||||
|
||||
// 显示 tags
|
||||
QStringList taglist = info["Tags"].toString().split(";", QString::SkipEmptyParts);
|
||||
QStringList taglist = info["Tags"].toString().split(";", Qt::SkipEmptyParts);
|
||||
setAppinfoTags(taglist);
|
||||
|
||||
// 获取图标
|
||||
QNetworkRequest request;
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
||||
// 获取图标和截图
|
||||
QString pkgUrlBase = api->getImgServerUrl() + SparkAPI::getArchDir() + url.path();
|
||||
qDebug() << "Icon URL: " << pkgUrlBase + "/icon.png";
|
||||
request.setUrl(QUrl(pkgUrlBase + "/icon.png"));
|
||||
request.setRawHeader("User-Agent", "Mozilla/5.0");
|
||||
request.setRawHeader("Content-Type", "charset='utf-8'");
|
||||
manager->get(request);
|
||||
QObject::connect(manager, &QNetworkAccessManager::finished, [=](QNetworkReply *reply)
|
||||
{
|
||||
QByteArray jpegData = reply->readAll();
|
||||
iconpixmap.loadFromData(jpegData);
|
||||
iconpixmap.scaled(210, 200, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
ui->icon->setPixmap(iconpixmap);
|
||||
ui->icon->setScaledContents(true);
|
||||
// 创建网络请求管理器
|
||||
QNetworkAccessManager *iconManager = new QNetworkAccessManager(this);
|
||||
|
||||
// 获取图标
|
||||
QNetworkRequest iconRequest;
|
||||
iconRequest.setUrl(QUrl(pkgUrlBase + "/icon.png"));
|
||||
iconRequest.setRawHeader("User-Agent", rawHeaders);
|
||||
iconRequest.setRawHeader("Content-Type", "charset='utf-8'");
|
||||
|
||||
iconManager->get(iconRequest);
|
||||
QObject::connect(iconManager, &QNetworkAccessManager::finished, [=](QNetworkReply *reply)
|
||||
{
|
||||
QByteArray jpegData = reply->readAll();
|
||||
iconpixmap.loadFromData(jpegData);
|
||||
iconpixmap = iconpixmap.scaled(210, 200, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
ui->icon->setPixmap(iconpixmap);
|
||||
ui->icon->setScaledContents(true);
|
||||
|
||||
iconManager->deleteLater();
|
||||
reply->deleteLater();
|
||||
});
|
||||
|
||||
manager->deleteLater(); });
|
||||
|
||||
// 获取截图
|
||||
for (int i = 0; i < 5 /* 魔法数字,最多五个截图 */; i++)
|
||||
{
|
||||
QString imgUrl = pkgUrlBase + "/screen_" + QString::number(i + 1) + ".png";
|
||||
QNetworkRequest request;
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
||||
request.setUrl(QUrl(imgUrl));
|
||||
request.setRawHeader("User-Agent", "Mozilla/5.0");
|
||||
request.setRawHeader("User-Agent", rawHeaders);
|
||||
request.setRawHeader("Content-Type", "charset='utf-8'");
|
||||
manager->get(request);
|
||||
QObject::connect(manager, &QNetworkAccessManager::finished, [=](QNetworkReply *reply)
|
||||
@@ -105,6 +115,7 @@ void AppIntoPage::openUrl(const QUrl &url)
|
||||
manager->deleteLater();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Check UOS
|
||||
QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat);
|
||||
|
||||
Reference in New Issue
Block a user