Merge pull request !105 from Pluto/dev
This commit is contained in:
shenmo 2022-08-29 16:06:31 +00:00 committed by Gitee
commit 6617522a7c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 22 additions and 12 deletions

View File

@ -292,18 +292,20 @@ void Widget::initConfig()
// 读取服务器URL并初始化菜单项的链接
QSettings readConfig(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
if(!readConfig.value("server/choose").toString().isEmpty())
if(!readConfig.value("server/choose").toString().isEmpty() && readConfig.value("server/updated").toString() == "TRUE")
{
ui->comboBox_server->setCurrentText(readConfig.value("server/choose").toString());
appinfoLoadThread.setServer(serverUrl = readConfig.value("server/choose").toString());
}
else
{
appinfoLoadThread.setServer(serverUrl = "https://d.store.deepinos.org.cn/"); // 默认URL
this->cdnSeverUrl = "https://cdn.d.store.deepinos.org.cn/";
appinfoLoadThread.setServer(serverUrl = this->cdnSeverUrl); // 默认URL
}
configCanSave = true; // 防止触发保存配置信号
// menuUrl[0] = "http://127.0.0.1:8000/#/darkprogramming";
qDebug() << "serverUrl: " << serverUrl;
menuUrl[0] = serverUrl + "store/#/";
menuUrl[1] = serverUrl + "store/#/network";
menuUrl[2] = serverUrl + "store/#/relations";
@ -1026,11 +1028,13 @@ void Widget::on_comboBox_server_currentIndexChanged(const QString &arg1)
{
appinfoLoadThread.setServer(arg1); // 服务器信息更新
const QString updatedInfo = "TRUE";
if(configCanSave)
{
// ui->label_setting1->show();
QSettings *setConfig = new QSettings(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
setConfig->setValue("server/choose", arg1);
setConfig->setValue("server/updated", updatedInfo);
}
}

View File

@ -43,7 +43,6 @@ class DownloadController;
namespace AeaQt {
class HttpClient;
}
class Widget : public DBlurEffectWidget
{
Q_OBJECT
@ -105,6 +104,7 @@ private slots:
public:
QUrl url;
QString cdnSeverUrl;
downloadlist download_list[LIST_MAX];
Ui::Widget *ui;

View File

@ -13,27 +13,29 @@ void SpkAppInfoLoaderThread::run()
emit requestResetUi();
httpClient = new AeaQt::HttpClient;
QString oriSeverUrl = "https://d.store.deepinos.org.cn";
QString cdnSeverUrl = "https://cdn.d.store.deepinos.org.cn";
QString downloadTimesUrl = targetUrl.toString();
downloadTimesUrl = downloadTimesUrl.replace("app.json","download-times.txt");
downloadTimesUrl = downloadTimesUrl.replace(oriSeverUrl, cdnSeverUrl);
downloadTimesUrl = downloadTimesUrl.replace("app.json", "download-times.txt");
httpClient->get(downloadTimesUrl)
.onResponse([this](QString downloadTimesFeedback)
{
qDebug() << "请求应用下载量信息 " << downloadTimesFeedback;
this->downdloadTimes = downloadTimesFeedback.replace("\n","");
this->downloadTimes = downloadTimesFeedback.replace("\n","");
})
.onError([this](QString errorStr)
{
qDebug() << "请求下载量失败:" << errorStr;
this->downdloadTimes = "0";
this->downloadTimes = "0";
})
.block()
.timeout(3*1000)
.exec();
httpClient->get(targetUrl.toString())
httpClient->get(targetUrl.toString().replace(oriSeverUrl, cdnSeverUrl))
.header("content-type", "application/json")
.onResponse([this](QByteArray json_array)
{
@ -48,8 +50,12 @@ void SpkAppInfoLoaderThread::run()
QString deburl = serverUrl;
deburl = deburl.left(urladdress.length() - 1);
urladdress = "https://d.store.deepinos.org.cn/"; // 使用图片专用服务器请保留这行,删除后将使用源服务器
urladdress = urladdress.left(urladdress.length() - 1);
QStringList url_ = targetUrl.toString().replace("//", "/").split("/");
urladdress = "https://" + url_[1];
// 使用 cdn 服务器
urladdress = "https://cdn.d.store.deepinos.org.cn"; // 使用图片专用服务器请保留这行,删除后将使用源服务器
for(int i = 3; i < downloadurl.size(); i++)
{
@ -66,7 +72,7 @@ void SpkAppInfoLoaderThread::run()
QString details;
details = tr("PkgName: ") + json["Pkgname"].toString() + "\n";
details += tr("Version: ") + json["Version"].toString() + "\n";
details += tr("Download Times: ") + this->downdloadTimes + "\n";
details += tr("Download Times: ") + this->downloadTimes + "\n";
if(!json["Author"].toString().trimmed().isEmpty())
{
details += tr("Author: ") + json["Author"].toString() + "\n";

View File

@ -23,7 +23,7 @@ protected:
private:
QUrl targetUrl;
QString serverUrl;
QString downdloadTimes;
QString downloadTimes;
bool finishedDownload = false;
int downloaderRetval = 0;