mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-07-15 10:02:21 +08:00
fix: 截图加载失败
This commit is contained in:
parent
9b1b432e7c
commit
04aeac62f8
@ -58,8 +58,9 @@ void AppIntoPage::openUrl(const QUrl &url)
|
||||
// 获取图标
|
||||
QNetworkRequest request;
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
||||
qDebug() << api->getImgServerUrl() + SparkAPI::getArchDir() + url.path() + "/icon.png";
|
||||
request.setUrl(QUrl(api->getImgServerUrl() + SparkAPI::getArchDir() + url.path() + "/icon.png"));
|
||||
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);
|
||||
@ -74,20 +75,13 @@ void AppIntoPage::openUrl(const QUrl &url)
|
||||
manager->deleteLater(); });
|
||||
|
||||
// 获取截图
|
||||
QJsonParseError error;
|
||||
QJsonArray array = QJsonDocument::fromJson(info.value("img_urls").toString().toUtf8(), &error).array();
|
||||
QStringList imglist;
|
||||
foreach (const QJsonValue &value, array) {
|
||||
QString imgUrl = value.toString();
|
||||
imglist.append(imgUrl);
|
||||
}
|
||||
qDebug() << imglist;
|
||||
|
||||
for (int i = 0; i < imglist.size(); i++)
|
||||
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(imglist.value(i)));
|
||||
request.setUrl(QUrl(imgUrl));
|
||||
request.setRawHeader("User-Agent", "Mozilla/5.0");
|
||||
request.setRawHeader("Content-Type", "charset='utf-8'");
|
||||
manager->get(request);
|
||||
@ -95,17 +89,21 @@ void AppIntoPage::openUrl(const QUrl &url)
|
||||
{
|
||||
QByteArray jpegData = reply->readAll();
|
||||
QPixmap pixmap;
|
||||
pixmap.loadFromData(jpegData);
|
||||
pixmap.scaled(100, 100, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
image_show *img=new image_show(this);
|
||||
img->setImage(pixmap);
|
||||
//img->setScaledContents(true);
|
||||
QListWidgetItem* pItem = new QListWidgetItem();
|
||||
pItem->setSizeHint(QSize(280, 200));
|
||||
ui->listWidget->addItem(pItem);
|
||||
ui->listWidget->setItemWidget(pItem, img);
|
||||
if (pixmap.loadFromData(jpegData))
|
||||
{
|
||||
pixmap.scaled(100, 100, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
image_show *img = new image_show(this);
|
||||
img->setImage(pixmap);
|
||||
// img->setScaledContents(true);
|
||||
QListWidgetItem *pItem = new QListWidgetItem();
|
||||
pItem->setSizeHint(QSize(280, 200));
|
||||
ui->listWidget->addItem(pItem);
|
||||
ui->listWidget->setItemWidget(pItem, img);
|
||||
qDebug() << imgUrl;
|
||||
}
|
||||
|
||||
manager->deleteLater(); });
|
||||
manager->deleteLater();
|
||||
});
|
||||
}
|
||||
|
||||
// Check UOS
|
||||
|
Loading…
x
Reference in New Issue
Block a user